Skip to content

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.

x = 5
name = "dan"

Operators in Python

  1. Arithmetic Operator
  2. Comparison Operator
  3. Logical Operator
  4. Assigment Operator
  5. Identity Operator
  6. Membership Operator

Flow Control

  1. Selection - Conditional ( if, elif, else )
  2. 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

  1. Concatenation
  2. Repetition
  3. Membership
  4. 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.