14. Record what happens when the following statements are executed:
(a) print (n-17)
(b) print (8+9)
(d) print (4.2, "hello", 6-2, "world", 15/2.0)
Answers
(a) print(n - 17)
There are two possible assumptions.
The first is that it will likely show an error.
>>> print(n - 17)
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
print(n - 17)
NameError: name 'n' is not defined
This is because no value has been assigned to 'n', and hence, the operation cannot take place.
The second is if we assume that 'n' has a numeric value.
If that were the case, then 17 would get subtracted from the number and the resultant value will be displayed.
For instance, if the value of 'n' was 27,
>>> print(n - 17) #27 - 17
10
10 would be the answer.
(b) print(8 + 9)
>>> print(8 + 9) #addition of the number 8 and 9
17
(c) print(4.2, "hello", 6 - 2, "world", 15/2.0)
>>> print(4.2, "hello", 6 - 2, "world", 15/2.0)
4.2 hello 4 world 7.5
Any value placed in quotes will be treated as a text value.