In: Computer Science
Python
Without running / testing the following code, predict what the following program prints on the screen.
freeze = int(32)
boil = int(212)
freeze = 0
boil = 100
print(freeze, boil)
1)
freeze = int(32)
boil = int(212)
freeze = 0
boil = 100
print(freeze, boil)
Ans: The output of the above program will be:
0 100
Explanation of output:
2)
Steps:
Screenshot of code:
Sample Outputs:
Code to copy:
# prompt user to enter a number in range 1 to 7
# save int of input into variable n
n = int(input("Input A number between 1 and 7 (both including) : "))
# check if n is 1
if(n==1):
# print Monday if 1
print("Monday")
# check if n is 2
elif(n==2):
# print Tuesday if 2
print("Tuesday")
# check if n is 3
elif(n==3):
# print Wednesday if 3
print("Wednesday")
# check if n is 4
elif(n==4):
# print Thursday if 4
print("Thursday")
# check if n is 5
elif(n==5):
# print Friday if 5
print("Friday")
# check if n is 6
elif(n==6):
# print Saturday if 6
print("Saturday")
# check if n is 7
elif(n==7):
# print monday if n is not in range 1-7
print("Sunday")
# if n is not any of the numbers checked above
else:
# print invalid numbers
print("Invalid number for day of week")