1. In Python the precedence order is first NOT then AND and in last OR. Evaluate and predict the output of the following:
2. What is the output in the following program and can you explain why?
3. What is the output of the following two for loops (python) program?
for i in range(2):
for i in range(4,6):
4. The following program returns the output '1,2,3,4'. What is the function 'filter' doing?
5. Can you predict the output of the following program?
6. In this program the output is: L*oo#frph#e|#wkhq1 …the code ciphers the plain text and specifically ….
7. Python is a low level language and C is an extremely high level language.
8. The following code snippet is in the language 'C' that you may not have come across. Can you predict the output?
9. In the python interpreter, why doesn't 0.2 + 0.1 = 0.3?
10. In the following program the output is 1,2,3,4. What is the -1 doing?
for i in [1, 2, 3, 4][::-1]:
Actually, the output is 4,3,2,1 and the [::-1] reverses the list
The -1 starts at the end of the list, but then prints it out in order
Actually, the output is 1,3,2,4, as the -1 is a randomiser which produces the list output in random
The -1 ensures that the list is printed in order as it starts from the beginning (-1 index)