Python for Grade 6 and 7
Chapter 1: Introduction to Python
Python is a high-level programming language.
It is easy to learn and understand.
Python is used to create games, websites,
apps, and robots.
Features of Python
Simple and easy to read
Free and open-source
Works on different operating systems
Supports graphics and games
LET’S RUN PYTHON
1. Download Python: Go to [Link]
and download the latest version for your
operating system.
2. Choose an Editor: I recommend
downloading VS Code.
3. Install the Python Extension: Inside VS
Code, go to the “Extensions” icon on the
left (it looks like four squares) and
search for “Python” by Microsoft. Install
it.
4. Create a file: Create a new file named
[Link].
5. Run it: Type print(“Hello!”), save the
file, and click the Play button in the top
right.
*YOU CAN ALSO RUN PYTHON ONLINE
Programiz Online Compiler: A highly
accessible and beginner-friendly Python 3
compiler.
OnlineGDB: Great for debugging and testing
code.
Starting Python
First Python Program
print("Hello, World!")
Output:
Hello, World!
The print() Function
It displays text or numbers on the screen.
print("Welcome to Python")
print(10)
---
Variables
Variables are used to store information.
name = "Rita"
age = 11
Display Variables
print(name)
print(age)
Output:
Rita
11
Data Types
Data Type Example
Integer (int) 25
Float 3.14
String (str) "Hello"
Boolean (bool) True, False
Example:
num = 10
pi = 3.14
name = "Rita"
---
Input from User
name = input("Enter your name: ")
print("Hello", name)
---
Operators
Arithmetic Operators
Operator Meaning
+ Addition
- Subtraction
* Multiplication
/ Division
% Remainder
Example:
a = 10
b=5
print(a + b)
print(a - b)
print(a * b)
print(a / b)
---
Decision Making
if Statement
marks = 80
if marks >= 40:
print("Pass")
if-else Statement
marks = 35
if marks >= 40:
print("Pass")
else:
print("Fail")
Loops for Loop
for i in range(1, 6):
print(i)
Output:
1
2
3
4
5
while Loop
count = 1
while count <= 5:
print(count)
count += 1
---
Lists
A list stores multiple values.
fruits = ["Apple", "Mango", "Banana"]
print(fruits)
Access List Items
print(fruits[0])
Output:
Apple
Functions
Functions help us reuse code.
def greet():
print("Good Morning")
greet()
Function with Argument
def greet(name):
print("Hello", name)
greet("Rita")
---
Simple Programs
*Add Two Numbers
a = 12
b=8
print("Sum =", a + b)
Check Even or Odd
num = 10
if num % 2 == 0:
print("Even Number")
else:
print("Odd Number")
Important Terms
Program: A set of instructions for a computer.
Variable: Stores data.
Loop: Repeats a task.
Function: A reusable block of code.
List: Stores multiple items.
Quick Revision
✅ print() → Display output
✅ input() → Take input
✅ Variable → Store data
✅ Operators → Perform calculations
✅ if-else → Make decisions
✅ Loops → Repeat actions
✅ List → Store many values
✅ Function → Reuse code