Python Programming - Unit 1
Unit 1: Introduction to Python
1. Python Variables:
A variable is like a container to store information. For example, if you write x = 10, the computer
remembers that x has the value 10. You can change the value anytime by assigning a new value.
2. Python Basic Operators:
Operators are symbols that tell Python to do some task. For example: + (Addition): 5 + 3 = 8 -
(Subtraction): 9 - 4 = 5 * (Multiplication): 6 * 2 = 12 / (Division): 8 / 2 = 4 % (Modulus): 10 % 3 = 1
(gives remainder)
3. Understanding Python Blocks:
A block is a group of code written together for a specific purpose. In Python, blocks are created
using indentation (spaces). For example, in an if statement, the indented code is the block that
runs if the condition is true.
4. Python Data Types:
Python can store different kinds of values: int: Whole numbers like 5, 20, -10 float: Decimal
numbers like 3.14, 2.5 str: Text (string) like "Hello" bool: True or False
5. Declaring and Using Numeric Data Types:
Declaring means creating a variable. For example: x = 10 (an integer) y = 3.5 (a float) You can use
these variables in calculations like z = x + y.