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:
-
Easy to learn and use
-
Portable and extensible
-
Interpreted and interactive
-
Rich library support
-
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 (
Age≠age). -
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:
-
Arithmetic:
+,-,*,/,//,%,** -
Relational:
==,!=,>,<,>=,<= -
Logical:
and,or,not -
Assignment:
=,+=,-=, etc. -
Membership:
in,not in -
Identity:
is,is not
