Python Programming for Absolute Beginners
1. Introduction to Programming and Python
Programming is the process of giving instructions to a computer to perform tasks. Python is a versatile and
beginner-friendly programming language. It is widely used in web development, data science, AI, and more.
Why Learn Python?
- Simple syntax, easy to learn.
- Large community and libraries.
- High demand in the job market.
Download Python: Visit https://www.python.org/ to download and install Python on your system.
2. Python Basics - Variables, Data Types, and Operators
Variables are containers for storing data values.
Example:
name = "Ali"
age = 25
height = 5.8
Data Types:
- int: Integer (e.g., 10, 20)
- float: Decimal (e.g., 10.5, 2.5)
Python Programming for Absolute Beginners
- str: String (e.g., "Hello")
- bool: Boolean (e.g., True, False)
Operators:
- Arithmetic: +, -, *, /
- Comparison: ==, !=, >, <
Example:
x = 10
y = 20
print(x + y) # Output: 30
3. Control Flow - If-Else Statements and Loops
If-Else Statements allow you to make decisions in your code.
Example:
age = 18
if age >= 18:
print("You are an adult.")
else:
print("You are a minor.")
Loops allow repetitive tasks.
For Loop Example:
for i in range(5):
Python Programming for Absolute Beginners
print(i)
While Loop Example:
count = 0
while count < 5:
print(count)
count += 1