■ Simplified Python Beginner Tutorial
1. Introduction to Python
Python is a programming language that is simple, powerful, and widely used. You can build
web apps, games, automation scripts, and even Artificial Intelligence applications.
2. Writing Your First Program
Let's start with the famous Hello World program:
print("Hello, World!")
3. Variables & Data Types
Variables are used to store data. Python supports several data types:
name = "Alice" # string
age = 25 # integer
height = 5.6 # float
is_student = True # boolean
4. Input & Output
You can take input from users and display it back:
name = input("Enter your name: ")
print("Hello", name)
5. Math Operations
Python can do math easily:
a = 10
b = 3
print(a + b) # addition → 13
print(a - b) # subtraction → 7
print(a * b) # multiplication → 30
print(a / b) # division → 3.333
print(a % b) # remainder → 1
print(a ** b) # power → 1000
6. If-Else Statements
Control the flow of your program:
age = int(input("Enter your age: "))
if age >= 18:
print("You are an adult ■")
elif age >= 13:
print("You are a teenager ■")
else:
print("You are a child ■")
7. Loops
Loops help repeat tasks.
For Loop:
for i in range(5):
print("Number:", i)
While Loop:
count = 1
while count <= 5:
print("Count:", count)
count += 1
8. Functions
Functions are reusable blocks of code:
def greet(name):
print("Hello", name)
greet("Alice")
greet("Python Learner")
9. Lists
Lists can store multiple values:
fruits = ["apple", "banana", "mango"]
print(fruits[0]) # apple
print(fruits[1]) # banana
for fruit in fruits:
print(fruit)
10. Practice Exercises
■ Try these on your own:
1. Write a program to check if a number is even or odd.
2. Create a loop to print numbers from 1 to 10.
3. Write a function that takes two numbers and returns their sum.
4. Make a list of 5 friends’ names and print them.
11. Mini Projects
■ Number Guessing Game:
import random
number = random.randint(1, 10)
guess = int(input("Guess a number between 1 and 10: "))
if guess == number:
print("■ Correct!")
else:
print("■ Wrong! The number was", number)
■ Simple Calculator:
a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
print("Sum:", a + b)
print("Difference:", a - b)
print("Product:", a * b)
print("Division:", a / b)