0% found this document useful (0 votes)
4 views13 pages

Variablesand Datatypes

This document outlines the objectives for teaching variables and data types in Python, including understanding variable usage, identifying data types, and writing code. It explains the rules for naming variables and provides examples of correct and incorrect variable names. The document also includes questions to reinforce learning and a recap of the key concepts covered.

Uploaded by

Hina Shaikh
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)
4 views13 pages

Variablesand Datatypes

This document outlines the objectives for teaching variables and data types in Python, including understanding variable usage, identifying data types, and writing code. It explains the rules for naming variables and provides examples of correct and incorrect variable names. The document also includes questions to reinforce learning and a recap of the key concepts covered.

Uploaded by

Hina Shaikh
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

Topic: Variables and Datatypes

AITCHISON COLLEGE
PREP SCHOOL
ICT Department
Objectives
Students will be able to:

• Understand the use of variable in programming

• Identify different data types in python

• Learn the syntax of defining variables

• Write code with use of different data types


Variables
Variables are the reserved memory locations to store the values in a
program. Value of variable changes during execution of program.
For example:
RollNo= 45
Data Type:
Data type represents the type of value and determines how the value can be
used in a python program. The common data types available in python are:
∙ Integer type
∙ Float Type
∙ String type
∙ Boolean type
Variable Names
A variable can have a short name (like x and y) or a more descriptive name
(age, carname, total_volume).
Rules for Python variables:
• A variable name must start with a letter or the underscore character
• A variable name cannot start with a number

• A variable name can only contain alpha-numeric characters and


underscores (A-z, 0-9, and _ )
• Variable names are case-sensitive (age, Age and AGE are three different
variables)
Variable Name Examples
• Correct variable names:
myvar = "John"
my_var = "John"
_my_var = "John"
myVar = "John"
MYVAR = "John"
myvar2 = "John“
• Incorrect variable names:
2myvar = "John"
my-var = "John"
my var = "John"
Question 1
Which of these represents how the value will be used?

a) Operators

b) Data Type
c) Variable
d) All of the above
Question 2
The named memory locations are called :

a) Data Types

b) Operators
c) Variables
d) All of the above
Question 3

x=5 print (type(x))

int
Question 4

x=“Hello World” print (type(x))

str
Question 5

x=20.5 print (type(x))

float
Question 6

x=True print (type(x))

bool
Recap
In this lesson, we have discussed:

• Use of variables

• Identify different data types

• Syntax to define variable

• Application of Data types in python


Thank You

You might also like