🚀 Middle School
| IGCSE • Computer Science

Python Basics

Variables.

1 Lesson 1 MCQ 1 Mnemonic
+25
XP
Available to earn
1
Lesson

Python Basics — Lesson

Hook: When Cricket Meets Coding!

Imagine you are the captain of your school cricket team. You want to keep track of runs scored by each player in a simple way. Instead of writing it down on paper, what if you could ask your computer to do it for you? Just like a cricket scoreboard shows runs, balls, and wickets, Python can help you keep score with just a few lines of code! Let’s learn how Python, one of the friendliest programming languages, can make this happen.

Core Concepts: Python Basics Explained

1. What is Python?
Python is a popular programming language used worldwide for building apps, games, websites, and even Bollywood movie animations! It’s easy to read and write, making it perfect for beginners.
2. Writing Your First Python Code:
The simplest Python program prints a message on the screen using the print() function.
Code Output
print("Hello, Cricket Fans!") Hello, Cricket Fans!
3. Variables: Storing Information
Variables are like your cricket players’ jerseys — they hold important information. For example, to store the runs scored by a player:
Code Explanation
runs = 45 Stores the number 45 in the variable named runs.
4. Data Types in Python
Python has different types of data, like numbers and words. Here are some common types:
Data Type Example Description
int runs = 100 Whole numbers (integers)
float average = 45.5 Decimal numbers
str player = "Virat" Text (strings)
5. Comments: Writing Notes in Code
Comments help you or others understand the code. Python ignores anything after #.
# This is a comment explaining the code
runs = 50  # runs scored by the player
print(runs)
  

Key Formulas / Rules

Rule 1: Printing Output
Use print() to display messages or variables.

print("Hello World")
print(variable_name)
Rule 2: Variable Naming
- Variable names can contain letters, numbers, and underscores.
- Must start with a letter or underscore.
- No spaces or special characters.
- Case sensitive: Runs and runs are different.
Rule 3: Comments
Anything after # is ignored by Python.
Use comments to explain your code.

Did You Know?

Python was named after the British comedy group “Monty Python”! Its creator, Guido van Rossum, wanted a fun and easy language — just like a comedy show. So, when you write Python code, you’re actually coding with a little humor in mind!

Exam Tips: Score Like a Pro!

  • Indentation matters: Python uses spaces to group code. Always indent blocks properly (usually 4 spaces).
  • Check spelling: Variable names are case sensitive. Writing Runs instead of runs can cause errors.
  • Use print statements: To show output, always use print(). Forgetting it means nothing will display.
  • Understand data types: Don’t put numbers inside quotes if you want to do math with them. For example, runs = 50 (number) vs runs = "50" (text).
  • Practice writing comments: It helps the examiner understand your logic and can earn you extra marks.
  • Board exam pattern: Be ready to write short code snippets (3-5 lines), explain what code does, and fix simple errors.
2
MCQ Practice

Python Basics — Mcq

3
Memory Trick

Python Basics — Mnemonic

Mnemonic 1: "P.Y.T.H.O.N" for Python Basics 🐍

  • P - Print: Show output on screen 🖥️
  • Y - Yahan variables bante hain (Variables are made here) 🧮
  • T - Type matters: Data types like int, str, float 📊
  • H - Help from indentation: Blocks of code aligned properly ↔️
  • O - Operators: +, -, *, / for maths and logic ➕➖✖️➗
  • N - New lines with loops & ifs: Control flow ka funda 🔄

Remember: "Python se Programming Ho Nahi" (Python makes programming easy!) 😄

Mnemonic 2: "CRICKET" to remember Python Data Types 🏏

  • C - Class (Object) - Python is object-oriented too! 🎯
  • R - Range - Numbers from start to end (like runs in cricket!) 🏃‍♂️
  • I - Integer - Whole numbers like runs scored (50, 100) 🔢
  • C - Complex - Maths with real & imaginary parts (like a tricky spin bowler!) 🎩
  • K - Key (Dictionary) - Like player names & jersey numbers 🏏📋
  • E - Element (List) - Collection of items (like team players list) 📋
  • T - Text (String) - Words & sentences (like commentary!) 🗣️

Fun phrase: "Cricket khelte khelte Python sikho!" (Learn Python while playing cricket!) 🏏🐍

Mnemonic 3: "INDIA" for Python Program Structure 🇮🇳

  • I - Indentation zaroori hai (Indentation is important!) ↪️
  • N - Name your variables clearly (Jaise 'score', 'runs') 🏏
  • D - Data types samjho (Understand data types) 📊
  • I - Input lo user se (Take input from user) 👩‍💻👨‍💻
  • A - Always test your code (Code ko run karke check karo) ✅

Yaad rakhna: "INDIA jaisi team, Python mein bhi jeetegi!" (A team like India will win in Python too!) 🇮🇳🐍

Interactive

Mission: Master This Topic!

Reinforce what you learned with fun activities

🎯

Ready to Battle? Test Your Knowledge!

Practice MCQs, build combos, climb the leaderboard!

Start Practice

Loading...

Hey! 🔥 Your 7-day streak is at risk. Complete one quick quest today?

Streak broken? No worries. Recover with bonus XP by completing a quest now.