Variable names must start with a letter or underscore.
Variable names cannot start with a number.
A variable name can only contain letters, numbers, and underscores (A - z, 0-9, and _).
Variable names are case sensitive (num, Num and NUM are three different variables).
Reserved words (keywords) cannot be used to name a variable.
number = 10 # variable number of integer type assigns the value 10
pi = 3.14 # floating point pi is assigned the value 3.14
word = "Hello" # variable word of string type assigns the value "Hello"
print(number, pi, word) # output values of variables
How define the data type of variable.
The function type() shows the data type of variables.
int(string) – convert string to int float(string) – convert string to float int(float) – convert floating point number to an integer str(int) – convert integer to string str(float) – convert floating point number to string
Questions:
1. What does it mean "data type"?
2. Name four data types.
3. Provide examples for each data type.
Exercises:
Ex.1 Data types in Python (Author: Mr. Halil Mali - CS teacher of NIS Uralsk)