Python for Beginners
1. What is Python?
Python is a high-level, interpreted programming language known for its simple and readable
syntax. It’s used in web development, data science, automation, AI/ML, and more.
Why learn Python?
• Easy to read and write
• Huge community support
• Versatile across industries (AI, finance, web, etc.)
2. Setting Up Python & IDEs
Install Python:
• Visit python.org → Download → Install
• Make sure to check “Add Python to PATH” during installation
Choose an IDE or Code Editor:
• Beginner-friendly IDEs:
o IDLE (comes with Python)
o Thonny (super simple for beginners)
o VS Code (recommended for growth)
o PyCharm Community Edition
3. Syntax & Data Types
Variables
python
CopyEdit
name = "Alice"
age = 25
is_student = True
Data Types
Type Example
int age = 25
float price = 19.99
str name = "Alice"
bool is_valid = True
list fruits = ["apple", "banana"]
dict person = {"name": "Alice", "age": 25}
Input & Output
python
CopyEdit
name = input("Enter your name: ")
print("Hello", name)
4. Control Flow: If, Loops
If-Else Statements
python
CopyEdit
age = 18
if age >= 18:
print("Adult")
else:
print("Minor")
Loops
For Loop:
python
CopyEdit
for i in range(5):
print(i) # 0 to 4
While Loop:
python
CopyEdit
x=0
while x < 5:
print(x)
x += 1
5. Writing Functions & Basic Projects
Functions
python
CopyEdit
def greet(name):
return f"Hello, {name}!"
print(greet("Alice"))
Mini Projects Ideas
• Calculator: Perform basic arithmetic
• To-Do List: Add and remove tasks using a list
• Number Guessing Game:
python
CopyEdit
import random
number = random.randint(1, 10)
guess = int(input("Guess a number 1-10: "))
if guess == number:
print("Correct!")
else:
print(f"Wrong! The number was {number}")