Python Programs – Guess the Output (Practice Questions)
Program 1
x=8
y=3
z=x+y*2
print(z)
Output:
___________________________________________________________________________________________________[1]
Explanation:
______________________________________________________________________________________________________[1]
Program 2
temperature = 35
if temperature > 30:
print("Hot")
elif temperature == 30:
print("Warm")
else:
print("Cold")
Output:
____________________________________________________________________________________________[1]
Explanation:
______________________________________________________________________________________________________[1]
Program 3
numbers = [1, 2, 3, 4, 5]
total = 0
for number in numbers:
total += number * 2
print(total)
Output: __________________________________________________________________________________ [1]
Explanation:
______________________________________________________________________________________________________[1]
Program 4
nums = [10, 15, 20, 25, 30]
total = 0
for n in nums:
if n % 2 == 0:
total += n
print(total)
Output:
Explanation:
__________________________________________________________________________________________________[1]
Program 5
data = [3, 6, 2, 9, 12, 1]
count = 0
for item in data:
if item > 5:
count += 1
print(count)
Output:
______________________________________________________________________________________________________[1]
Explanation:
_____________________________________________________________________________________________________[1]
Program 6
a = 10
b = 20
c = a * b - 5
d = c / 2
print(d)
print(c)
Output:
________________________________________________________ [1]
Explanation:
________________________________________________________________________
______________________________________________________ [1]
Program 7
x=6
y=2
z=x*y+4-y
print(z)
Output:
____________________________________________________________________________________________________ [1]
Explanation:
_________________________________________________________________________________________________________
______________________________________________________________________________[1]
Program 9
a = 10
b=3
c=a%b+b*2
print(c)
Output:
____________________________________________________________________________________________________ [1]
Explanation:
_________________________________________________________________________________________________________
______________________________________________________________________________[1]
Program 10
p=8
q = p // 3
r=q+p%3
print(r)
Output:
____________________________________________________________________________________________________ [1]
Explanation:
_________________________________________________________________________________________________________
______________________________________________________________________________[1]