Page 287 - AI Ver 1.0 Class 9
P. 287
Variable has:
• A name that follows the rules of identifier naming conventions and is case sensitive.
• A value that can be integer, float, string, boolean, etc.
Unlike other programming languages, variables in Python are not created before. They are created automatically
when a value is assigned to it using an = operator. A variable assigned with a value of one type can be re-
assigned a new value of a different type as shown below:
>>>a = 20
>>>a
20
>>>a = "hello"
>>>a
'hello'
There are different ways of assigning values to different variables in Python:
• Method1: Assigning different values to different variable on different lines.
>>>a = 5
>>>b = 10.5
>>>c = "hello"
• Method2: Assigning different values to different variable on same line.
>>>a = 5; b = 10.5; c = "hello"
OR
>>>a, b, c = 5, 10.5, "hello"
• Method3: Assigning same values to different variable on same line.
>>>a = b = c = 10
Brainy Fact
Python is a case-sensitive language where uppercase and lowercase characters have different
meanings. Name and name are two different variables.
Data Types
Data types specify the kind of a value a variable can store. It helps us to identify the kind of operation that can
be performed on that specific data type. Every value in Python has a data type. Some of the standard built-in
data types of Python are:
Data Types
Numbers Sequences Sets Maps
int float complex string list tuple dictionary
Introduction to Python 285

