Consider the statements below
John = 5 friend_name = John print friend_name print type(friend_name)
What is printed?
Variable friend_name gets the value of integer 5. If we wanted friend_name to contain the string “John”, we would have to write friend_name = “John”. Make sure students understand the type of each variable in situations when multiple types are being used.
A common mistake when using a string and an integer:
my_number = '5' # a string '5' count = 5 # an integer 5
What is the value of the expression (my_number == count)? We are comparing a string containing ‘5’ with an integer having value 5. The result will be False.
We can add integers and the + operator also exists for strings (it concatenates two strings).
What does count + my_number produce? 10 or 55? It produces a TypeError as shown below.