Saturday, May 3, 2025

Python Tutorial for Kids

 

Python Tutorial for Beginners

(Fun & Easy Steps to Learn Python!) 🐍✨

Python is a simple yet powerful programming language used for games, websites, data science, and more! Let’s learn the basics.


1. Installing Python

  1. Download Python from python.org.

  2. Run the installer and check "Add Python to PATH".

  3. Open IDLE (Python’s built-in editor) or use VS Code.


2. Your First Python Program

Let’s write a simple program!

python
Copy
Download
print("Hello, World!")  

Run it:

  • Save as hello.py

  • Press F5 in IDLE or run in terminal:

    bash
    Copy
    Download
    python hello.py

Output:

Copy
Download
Hello, World!

3. Variables & Data Types

Variables store data. Python has:

TypeExample
int5-10
float3.14-0.5
str"Hello"'a'
boolTrueFalse
python
Copy
Download
name = "Alice"  
age = 10  
height = 4.5  
is_student = True  

print(name, "is", age, "years old.")  

4. User Input

Ask for input with input():

python
Copy
Download
name = input("What’s your name? ")  
print("Hi,", name + "!")  

Output:

Copy
Download
What’s your name? Bob  
Hi, Bob!  

5. Math Operations

OperatorExampleResult
+5 + 27
-5 - 23
*5 * 210
/5 / 22.5
**5 ** 225 (5 squared)
python
Copy
Download
x = 10  
y = 3  
print(x + y)  # Output: 13  

6. Conditional Statements (ifelse)

Make decisions in code!

python
Copy
Download
age = int(input("How old are you? "))  

if age >= 18:  
    print("You’re an adult!")  
elif age >= 13:  
    print("You’re a teenager!")  
else:  
    print("You’re a kid!")  

7. Loops

for Loop

Repeat code a set number of times.

python
Copy
Download
for i in range(5):  
    print("Hello!", i)  

Output:

Copy
Download
Hello! 0  
Hello! 1  
Hello! 2  
Hello! 3  
Hello! 4  

while Loop

Repeat until a condition is False.

python
Copy
Download
count = 0  
while count < 3:  
    print("Counting:", count)  
    count += 1  

Output:

Copy
Download
Counting: 0  
Counting: 1  
Counting: 2  

8. Lists (Like a Toy Box!)

Store multiple items in one variable.

python
Copy
Download
toys = ["car", "doll", "ball"]  
print(toys[0])  # Output: car  

toys.append("robot")  # Add new toy  
print(toys)  # Output: ['car', 'doll', 'ball', 'robot']  

9. Functions (Reusable Code Blocks)

python
Copy
Download
def greet(name):  
    print("Hello,", name)  

greet("Alice")  # Output: Hello, Alice  

10. Mini-Project: Guess the Number!

python
Copy
Download
import random  

secret_num = random.randint(1, 10)  
guess = 0  

while guess != secret_num:  
    guess = int(input("Guess a number (1-10): "))  
    if guess < secret_num:  
        print("Too low!")  
    elif guess > secret_num:  
        print("Too high!")  

print("You got it! The number was", secret_num)  

What’s Next?

🚀 Try These:

  • Make a simple calculator (+-*/).

  • Create a story generator (using random).

  • Learn Turtle Graphics (draw shapes with code!).