0% found this document useful (0 votes)
17 views4 pages

Data Types in Python

This document outlines a series of Python programming tasks for Grade 7 students, covering topics such as data types, string operations, boolean values, comparison operators, user input, and a mini project. Each task includes a question and corresponding code to demonstrate the concept. Students are instructed to save their work in appropriately named files.

Uploaded by

jesnariyas1992
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views4 pages

Data Types in Python

This document outlines a series of Python programming tasks for Grade 7 students, covering topics such as data types, string operations, boolean values, comparison operators, user input, and a mini project. Each task includes a question and corresponding code to demonstrate the concept. Students are instructed to save their work in appropriately named files.

Uploaded by

jesnariyas1992
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

MIS CS GRADE 7

Name: ……………………… Python Programming


Sec: ………. Data Types
1. Open IDLE Python 3.13 and create a new file and complete following task
and run the code
Task 1 – Integers and Floats - save the file integer and floats
Question:
Create two integer variables and two float variables. Perform addition,
subtraction, and multiplication, then print the results.
Code:
num1 = 8
num2 = 3
num3 = 2.5
num4 = 4.5
add_result = num1 + num3
sub_result = num2 - num4
mul_result = num1 * num2
print("Addition:", add_result)
print("Subtraction:", sub_result)
print("Multiplication:", mul_result)
Task 2 – Strings - save the file as strings
Question:
Create variables for your name and school name.
Print a sentence introducing yourself.
Code:
name = "Sara"
school = "Merryland International School"
print("Hello, my name is", name, "and I study at", school + ".")

1|Page
MIS CS GRADE 7

Task 2 - String Operations - save the file as string operations


Question:
Create a string and print its first letter, last letter, and the total number of
characters.

Code:
word = "Programming"
print("First letter:", word[0])
print("Last letter:", word[-1])
print("Total letters:", len(word))
Task 4 – Boolean Values - save the file as boolean values
Question:
Create two boolean variables and print messages depending on their values.
Code:
is_student = True
has_passed = False
print("Student status:", is_student)
print("Passed exam:", has_passed)
if has_passed:
print("Congratulations! You passed the exam.")
else:
print("Keep trying, you will do better next time!")
Task 5 – Comparison Operators -save the file as operators
Question:
Compare two integers and print whether one is greater, smaller, or equal.
Code:
x = 12
y = 10
print("x > y:", x > y)
print("x < y:", x < y)

2|Page
MIS CS GRADE 7

print("x == y:", x == y)
Task 6 – User Input and Type Conversion - save the file as input
Question:
Ask the user for their age. Convert it to integer and show how old they will be
next year.
Code:
# Task 6
age = int(input("Enter your age: "))
print("Next year you will be", age + 1, "years old.")
Task 7 – Mixed Data Types - save the file as data types
Question:
Create and print variables of all four data types: integer, float, string, and
boolean.
Code:
# Task 7
name = "Ali"
age = 13
height = 1.55
is_student = True
print(name, "is", age, "years old,", height, "meters tall, and student status is",
is_student)
Task 8 – Simple Calculator - save the file as calculator
Question:
Create two numbers and print their sum, difference, product, and quotient.
Code:
a = 10
b=3
print("Sum:", a + b)
print("Difference:", a - b)
print("Product:", a * b)

3|Page
MIS CS GRADE 7

print("Quotient:", a / b)
Task 9 – Boolean Logic - save the file as boolean task
Question:
Use boolean values to decide if you will get wet or stay dry.
Code:
is_raining = True
have_umbrella = False
if is_raining and not have_umbrella:
print("You will get wet!")
else:
print("You are safe from the rain!")
Task 10 – Mini Project: Student Information - save the file student info
Question:
Ask the user for their name, age, height, and student status, then print all
details.
Code:
name = input("Enter your name: ")
age = int(input("Enter your age: "))
height = float(input("Enter your height in meters: "))
is_student = input("Are you a student? (True/False): ")
print("\n--- Student Information ---")
print("Name:", name)
print("Age:", age)
print("Height:", height)
print("Student Status:", is_student)

4|Page

You might also like