Page 234 - Ai_V1.0_Class9
P. 234
Unlike other programming languages, variables in Python are not created before use. They are created
automatically when a value is assigned to them by using the assignment operator (=).
A variable assigned 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 variables in Python:
• Method1: Assigning different values to different variables on different lines.
>>>a = 5
>>>b = 10.5
>>>c = "hello"
• Method2: Assigning different values to different variables on same line.
>>>a = 5; b = 10.5; c = "hello"
OR
>>>a, b, c = 5, 10.5, "hello"
• Method3: Assigning same value to different variables 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 None Boolean Sequences Sets Maps
int float complex string list tuple dictionary
• Numbers: Data with a numeric value falls into this category. It can be integer, float and complex. Python will
automatically convert a number from one type to another if needed. Following are some number types:
232 Artificial Intelligence Play (Ver 1.0)-IX

