Strong Typing in Python
The peculiarity of Python is strong typing objects. This means that we cannot directly interact with objects of different types. For example, we cannot add a number and a string:
num = 12
txt = 'ab'
print(num + txt) # will display an error
To solve this problem, you need to convert both objects to the same type. You will learn how to do this in the following lessons.
Without running the code, determine what will be output to the console screen:
tst1 = 5
tst2 = 10
print(tst1 + tst2)
Without running the code, determine what will be output to the console screen:
tst1 = 5
tst2 = '10'
print(tst2 - tst1)
Without running the code, determine what will be output to the console screen:
tst1 = '123'
tst2 = '456'
print(tst1 + tst2)