Converting numbers to text and back
Now you know how to store numbers and how to store text. Being able to convert the two into each other will come in handy. For that, we will use type conversions.
Now we are going to combine strings with integer numbers.
name = 'Emily Smith' born = _____ ____ = '15' text = ____ + ' was born in the year ' + _____ year = born + _____ text year
Insert into the following items into the code, so that all statements are working:
- Can you leave
- What do
What is the result of the following statements?
9 + 9 9 + '9' '9' + '9'
Change the statements above by adding int() or str() to each of them, so that the result is 18 or '99', respectively.
Explain the result of the following operations?
9 * 9 9 * '9' '9' * 9
Write Python statements that create the following string:
The Challenge: A data record with types
|year of birth||2000||integer|
Write the values from each row of the table into string or integer variables, then combine them to a single one-line string.