Grade VI Computer Science

Chapter 7: Introduction to Python

Session 2: Variables, Script Mode, Data Types, print() and input()

1. Session Overview

Class VI
Subject Computer Science
Chapter Chapter 7: Introduction to Python
Session 2
Topic Variables in Python; Script Mode; Data Types; print(); input()
Suggested Duration 40–45 minutes
Session Focus: Students move from simply understanding Python syntax to writing small interactive programs that store, display and accept data.

2. Research Record

Curriculum Research

The session develops foundational programming skills required for students to write simple Python programs involving variables, data, output and user input.

Content Research

Learner Research

Grade VI students benefit from connecting programming concepts with familiar ideas such as names, ages, marks, colours and favourite subjects.

Prerequisites

Likely Misconceptions

3. Learning Objectives

By the end of the session, students will be able to:

4. Variables in Python

A variable is a name used to refer to a value stored in a program.

For example:

name = "Riya"
age = 11
marks = 85

Here, name, age and marks are variables.

Important: The = symbol is the assignment operator in Python. It assigns the value on the right to the variable on the left.

5. Naming Variables

Some basic rules for variable names are:

Valid Invalid
student_name student name
age2 2age
marks class

6. Working in Script Mode

Script Mode allows us to write a complete Python program in a file and execute the program together.

A typical workflow is:

  1. Open the Python IDE.
  2. Create a new Python file.
  3. Write the program.
  4. Save the file with a .py extension.
  5. Run the program.
  6. Observe the output.
  7. Correct errors if necessary.
Why Script Mode? It is useful for writing, saving, editing and repeatedly executing complete Python programs.

7. Data Types in Python

A data type tells us what kind of value is being stored.

Data Type Meaning Example
int Whole number 25
float Decimal number 25.5
str Text/string "Python"
bool True or False True

Examples

age = 12
height = 4.8
name = "Aarav"
is_student = True

8. Using the print() Function

The print() function displays information on the screen.

print("Hello Python!")

Output:

Hello Python!

Printing Variables

name = "Aarav"
age = 11

print(name)
print(age)

Printing Multiple Values

name = "Aarav"
age = 11

print("Name:", name)
print("Age:", age)

9. Using the input() Function

The input() function allows a Python program to accept information entered by the user.

name = input("Enter your name: ")

print("Hello", name)

If the user enters:

Anant

The program displays:

Hello Anant
Important: Values received using input() are strings by default. When numeric input is required, type conversion may be necessary.

10. Taking Numeric Input

To convert input into an integer, use int().

age = int(input("Enter your age: "))

print("Next year you will be", age + 1)

For decimal numbers, use float().

height = float(input("Enter your height: "))

print("Your height is", height)

11. Complete Example: Student Introduction

name = input("Enter your name: ")
age = int(input("Enter your age: "))
school = input("Enter your school: ")

print("Student Name:", name)
print("Age:", age)
print("School:", school)
Think: Which variables store text? Which variable stores a number?

12. Teaching Strategy

Stage Teacher Action Student Action
Recall Review Python and basic commands. Answer oral questions.
Demonstrate Create variables and display them. Observe and predict output.
Explain Introduce data types and Script Mode. Record and discuss concepts.
Guided Practice Demonstrate print() and input(). Write programs with guidance.
Independent Practice Provide a programming problem. Develop and run the program.

13. Classroom Activity

Activity: My Introduction Program

Students create a program that asks for:

  • Name
  • Age
  • Class
  • Favourite subject
  • Favourite colour

The program should display all the information neatly.

14. Computer Lab Activity

Task 1: Personal Information

Write a Python program that accepts your name, age and favourite subject and displays them.

Task 2: Age Calculator

Ask the user for their current age and display their age after one year.

Task 3: Marks

Accept marks in two subjects and display the marks entered.

15. Predict the Output

Question 1

x = 10
y = 20

print(x)
print(y)

Question 2

name = "Python"

print("I am learning", name)

Question 3

age = 12

print(age + 1)

Students should explain their answers before running the programs.

16. Assessment

Assessment Method Evidence of Learning
Oral Questioning Variables, data types, Script Mode and functions.
Worksheet Identify data types and predict outputs.
Practical Observation Create, save and execute a Python script.
Programming Task Write an interactive program using input() and print().

17. Quick Check

  1. What is a variable?
  2. What does the assignment operator = do?
  3. What is Script Mode?
  4. Name four common Python data types.
  5. What is the purpose of print()?
  6. What is the purpose of input()?
  7. What type of value does input() return by default?
  8. Why do we use int() with numeric input?

18. Homework

  1. Write a Python program to store your name, age and class in variables and display them.
  2. Write a program that accepts the user's name and displays a welcome message.
  3. Write a program that accepts two numbers and displays them.
  4. Identify the data type of each: 25, 25.5, "Computer", True.
  5. Explain the difference between print() and input().

19. Extension Challenge 🚀

Create a program that asks the user for the length and breadth of a rectangle and displays its area.

length = float(input("Enter length: "))
breadth = float(input("Enter breadth: "))

area = length * breadth

print("Area =", area)

Challenge: Can you modify the program to calculate the perimeter as well?

20. Summary

In this session, students learned how Python programs store information using variables, how complete programs can be written and executed in Script Mode, and how different data types represent different kinds of values.

Students also learned to display information using print() and accept user input using input(). They were introduced to int() and float() for converting input into numeric values.

21. Teacher Reflection