Python Output Worksheet
1. What is the output of the following code?
python
Copy code
print(10 + 5)
2. What is the output of the following code?
python
Copy code
print(2 * 3)
3. What is the output of the following code?
python
Copy code
print("Hello, " + "World!")
4. What is the output of the following code?
python
Copy code
print(5 / 2)
5. What is the output of the following code?
python
Copy code
print(5 // 2)
6. What is the output of the following code?
python
Copy code
a = 10
b = 20
print(a + b)
7. What is the output of the following code?
python
Copy code
x = 5
y = x + 2
print(y)
8. What is the output of the following code?
python
Copy code
if 5 > 2:
print("Five is greater than two!")
9. What is the output of the following code?
python
Copy code
if 3 < 1:
print("Three is less than one")
else:
print("Three is not less than one")
10. What is the output of the following code?
python
Copy code
if 10 == 10:
print("Ten is equal to ten")
else:
print("Ten is not equal to ten")
11. What is the output of the following code?
python
Copy code
if 7 != 7:
print("Seven is not equal to seven")
else:
print("Seven is equal to seven")
12. What is the output of the following code?
python
Copy code
a = 15
b = 20
if a < b:
print("a is less than b")
else:
print("a is not less than b")
13. What is the output of the following code?
python
Copy code
x = 5
if x > 0 and x < 10:
print("x is between 0 and 10")
else:
print("x is not between 0 and 10")
14. What is the output of the following code?
python
Copy code
a = True
b = False
print(a and b)
15. What is the output of the following code?
python
Copy code
a = True
b = False
print(a or b)
16. What is the output of the following code?
python
Copy code
x = 10
y = 5
print(not (x < y))
17. What is the output of the following code?
python
Copy code
a = 2
b = 3
c = 4
if a < b and b < c:
print("a < b < c")
else:
print("Condition not met")
18. What is the output of the following code?
python
Copy code
num = 15
if num % 2 == 0:
print("Even")
else:
print("Odd")
19. What is the output of the following code?
python
Copy code
a = 5
b = 10
if a + b > 10:
print("Sum is greater than 10")
else:
print("Sum is not greater than 10")
20. What is the output of the following code?
python
Copy code
score = 85
if score >= 90:
print("Grade A")
elif score >= 80:
print("Grade B")
elif score >= 70:
print("Grade C")
else:
print("Grade D")
21 What will be the output from the code given below?
python
Copy code
x, y, z = 5, 7, 9
y, x, z = y + 3, x + 3, z + 3
print(x, y, z)
22 What will be the output from the code given below?
python
Copy code
a, b, c = 12, 15, 18
c, a, b = c // 3, a // 3, b // 3
print(a, b, c)
23 What will be the output from the code given below?
python
Copy code
i, j, k = 6, 2, 4
k, i, j = k * 2, i * 2, j * 2
print(i, j, k)
24 What will be the output from the code given below?
python
Copy code
m, n, o = 14, 28, 42
n, m, o = n - 7, m - 7, o - 7
print(m, n, o)
25 What will be the output from the code given below?
python
Copy code
u, v, w = 3, 6, 9
v, u, w = v % 3, u % 3, w % 3
print(u, v, w)