Class : Grade 6
Subject: Computer Science
Topic: Introduction to Python
SUB TOPIC: Data types and variables
Introduction to Python
Data types and variables
Learning Objective:
Identify the different data types in python.
Demonstrate the rules for valid variables.
Create programs using it
Key
Points
Data types :Used to store different types of data, there are
different data types like numbers, strings.
String - Always write in double quotes
Numbers - Can be placed within or without quotes
Variables in
Python
Identify the rules for writing valid variable name and create
programs using it
Variables in
Python
Identify the rules for writing valid variable name and create
programs using it
Rules for naming a
variable
• A variable name must start with a letter or underscore.
• A variable name cannot start with a number.
• Variable names are case-sensitive (age, Age and AGE are
three different variables)
• Variable name can be of any length.
• No special symbols allowed in variable name
• It can be the combination of lowercase letter(a-z),upper case
letter(A-Z),digits(0-9) and underscore(_).
• Keywords cannot be used as variables.
Assigning values to
variable
• Storing a value in memory and the operator is (=).
• For example:
a=5 assigning an integer value.
b=12.5 assigning a floating-point value.
c=”Ram” assigning a string value
Common
Question
WAP to print your school name using variables
A=“IHS”
print(A)
A is the variable name
IHS is the variable value and IHS is a string value
Data types and variables
1. Write a program to print your name using variables
2. Write a program to print your name, age using variables
3. Write a program to enter any two subjects an its marks and
find total using variables.