name ="Jean Golding"print("Name:", name, type(name))
Name: Jean Golding <class 'str'>
Note that
It’s important that when writing numbers in your scripts, you do not put quotation marks around them, otherwise they will be recognized by the Python interpreter as strings. There is a difference between 3.14159 and “3.14159”, the first is a number and the second is just a pair of characters.
pi =3.14159print("pi:", pi, type(pi))
pi: 3.14159 <class 'float'>
pi ="3.14159"print("pi:", pi, type(pi))
pi: 3.14159 <class 'str'>
Boolean Types
Description
Type
Example
boolean values (True or False)
bool
a = True
a =23b =2c = a != bprint("C:", c, type(c))
C: True <class 'bool'>
Exercise
Without using Python, can you tell what is the data type of these variables?
x =32number_of_participants ="1017"Friday =Truey =float(1)a =10<8