CS-Python Notes

About Python

1. Introduction to Python

  • Python is a high-level, interpreted, and object-oriented programming language.

  • Developed by Guido van Rossum in 1991.

  • It is free, open-source, and platform-independent.

  • Python is known for simple syntax and readability.

Features:

  1. Easy to learn and use

  2. Portable and extensible

  3. Interpreted and interactive

  4. Rich library support

  5. Supports GUI and database connectivity

2. Data Types in Python

Data Type Description Example
int Whole numbers 10, -5
float Decimal numbers 3.14, -0.5
str String or text “Hello”
bool Boolean values True, False
list Ordered, mutable collection [1,2,3]
tuple Ordered, immutable collection (1,2,3)
set Unordered, unique elements {1,2,3}
dict Key-value pairs {‘a’:1, ‘b’:2}

3. Variables

  • Variable is a name that stores a value.

  • Created automatically when a value is assigned.

     Rules:

  • Must start with a letter or underscore.

  • Case-sensitive (Ageage).

  • No spaces or special characters.

4. Operators

Operators are special symbols or keywords used to perform operations on variables and values. They help in computations, comparisons, and logic building in a program.

Types of Operators:

  1. Arithmetic: +, -, *, /, //, %, **

  2. Relational: ==, !=, >, <, >=, <=

  3. Logical: and, or, not

  4. Assignment: =, +=, -=, etc.

  5. Membership: in, not in

  6. Identity: is, is not

LIST in Python

DBMS -SQL Notes