Computer Science Class - 12 Notes
Python
Python is a high-level, interpreted programming language known for its simple, readable syntax and broad versatility. It supports multiple programming paradigms, including procedural, object-oriented, and functional programming. Python is widely used in web development, data analysis, artificial intelligence, automation, and software development due to its large standard library and a vast ecosystem of third-party packages.
Keywords & Identifiers
Keywords are reserved words. Each keyword has a specific meaning to the python interpreter, and we can use a keyword in our program only for the purpose for which it has been defined.
Identifier : In programing languages, identifiers are names used to identify a variable, function or other entities in a program.
Common Keywords : True, def, and, del.
Variables
Container for storing data. It allocates memory to store data values.
Operators in Python
- Arithmetic Operator
- Comparison Operator
- Logical Operator
- Assigment Operator
- Identity Operator
- Membership Operator
Flow Control
- Selection - Conditional ( if, elif, else )
- Repetition - loops ( for, while )
for loops are used to traverse through a sequence.
Data Structures
String
Sequence of characters.
Created using a single quote, double quote, triple quotes.
Characters in string can be accessed using indexes.
String Operations
- Concatenation
- Repetition
- Membership
- Slicing
String Functions
- len
- title
- count
- split
- partition
List
- sequence data type
- store multiple values
- can store different data types.
Tuple
- sequence data type
- store multiple values
- can store different data types.
- Tuple is immutable
Dictionary
- Items are stored as key value pairs.
- keys are unique.
Functions
Code block that is executed on call. Functions can take in positional and keyword arguments.