Python Basics Exercise
create a simple ecserciese for class 8th students of pthon programmind on basic concept of
variables , print function artinh basic introduction data or taking input any number .
Got it🙂 Here’s a simple, classroom-friendly Python exercise set for Class 8 students, focused only
on basics: variables, print(), arithmetic, data types, and input().
You can give this as a worksheet or lab activity.
🐍 Python Basics Exercise Sheet
Class: 8
Topic: Variables, Print Function, Data Types & Input
Time: 30–40 minutes
🔹 Exercise 1: Understanding Variables
👉 Task:
Create variables and print their values.
Question:
1. Create a variable name and store your name in it.
2. Create a variable age and store your age.
3. Print both using the print() function.
Expected Output (Example):
pgsql
My name is Rishi
My age is 13
🔹 Exercise 2: Using Print Function
👉 Task:
Use the print() function to display a message.
Question:
Write a program to print:
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 1/8
vbnet
Welcome to Python Programming
Python is easy to learn
🔹 Exercise 3: Basic Arithmetic Operations
👉 Task:
Perform simple calculations using variables.
Question:
1. Take two numbers a = 10 and b = 5.
2. Print:
Addition
Subtraction
Multiplication
Division
Hint:
python
a = 10
b = 5
🔹 Exercise 4: Introduction to Data Types
👉 Task:
Identify different data types.
Question:
Create variables of the following types and print them:
1. Integer (example: number of students)
2. Float (example: height)
3. String (example: school name)
Bonus Question:
Use type() to check the data type.
🔹 Exercise 5: Taking Input from User
👉 Task:
Take input and print it.
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 2/8
Question:
1. Ask the user to enter their name.
2. Print a greeting message.
Example Output:
yaml
Enter your name: Aman
Hello Aman
🔹 Exercise 6: Input + Arithmetic
👉 Task:
Take numbers from the user and calculate.
Question:
1. Take two numbers from the user.
2. Print their sum.
Hint:
python
a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
⭐ Challenge Question (Optional)
👉 Try this:
Take one number from the user and print:
Double of the number
Square of the number
✅ Teacher Notes (for you)
Use IDLE / Thonny
Explain: int(), float(), input()
Let students run each program one by one
If you want, I can also:
✅ Make this into a printable PDF worksheet
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 3/8
✅ Provide answer key
✅ Create MCQs + practical questions
Just tell me 👍
also provide concpets to learn them data types and thier uses in varibles and taking input
Perfect 👍
Here is a very clear, Class-8 friendly explanation of concepts that you can teach before giving the
exercises.
Language is simple, with small examples, exactly suitable for beginners.
🐍 Python Concepts for Class 8
Topic: Data Types, Variables & Taking Input
🔹 1. What is a Variable?
A variable is a name used to store data in a program.
📌 Think of it like a container that holds information.
Example:
python
age = 13
name = "Aman"
Here:
age stores a number
name stores text
🔹 2. What are Data Types?
Data Type tells Python what type of data is stored in a variable.
👉 Python needs data types to:
Understand the value
Perform correct operations
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 4/8
Avoid errors
🔹 3. Common Data Types in Python (Class 8 Level)
🔸 (a) Integer ( int)
Used for whole numbers (no decimal).
📌 Examples:
Age
Roll number
Number of students
python
age = 14
students = 35
🔸 (b) Float ( float)
Used for decimal numbers.
📌 Examples:
Height
Weight
Temperature
python
height = 5.6
temperature = 36.5
🔸 (c) String ( str)
Used for text or words.
📌 Examples:
Name
School name
City
python
name = "Rishi"
school = "RDS Memorial Public School"
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 5/8
⚠ Strings are always written inside quotes ( " ").
🔸 (d) Boolean ( bool) (Basic idea only)
Used for True or False values.
python
is_student = True
🔹 4. Checking Data Type using type()
Python provides type() to check the data type.
python
a = 10
print(type(a))
Output:
javascript
<class 'int'>
🔹 5. Taking Input from User
Python uses input() to take input from the user.
python
name = input("Enter your name: ")
print(name)
📌 Important:
input() always takes data as string
🔹 6. Converting Input into Numbers
Since input is always string, we must convert it.
Convert to Integer
python
age = int(input("Enter your age: "))
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 6/8
Convert to Float
python
height = float(input("Enter your height: "))
🔹 7. Why Conversion is Important?
❌ Wrong:
python
a = input("Enter number: ")
b = input("Enter number: ")
print(a + b)
Output:
yaml
1020
✔ Correct:
python
a = int(input("Enter number: "))
b = int(input("Enter number: "))
print(a + b)
Output:
30
🔹 8. Using Variables with Input
Example Program:
python
name = input("Enter your name: ")
age = int(input("Enter your age: "))
print("Hello", name)
print("Your age is", age)
🔹 9. Summary Table (Easy to Remember)
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 7/8
Data Type Used For Example
int Whole numbers 10, 25
float Decimal numbers 5.6, 3.14
str Text "Hello"
bool True/False True
🌟 Teaching Tip (Very Useful)
Explain like this to students:
Variable = Box
Data Type = Type of item in the box
📦 Number box → / float
📦 Text box →
int
str
If you want, I can also:
📘 Create concept notes PDF
🧠 Make MCQs based on data types
🧪 Provide lab activity sheet
📝 Create exam-oriented questions
Just say the word 😊
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 8/8