A smart-thermostat system uses the Python code snippet below to monitor room temperature:
temp = float(input("Enter temperature: "))
if temp < 18.0:
print("Heating On")
else:
print("Heating Off")
The program needs to be modified so that it repeats exactly five times using definite (count-controlled) iteration.
Select the option that does this correctly.
count = 0
while count < 5:
temp = float(input("Enter temperature: "))
if temp < 18.0:
print("Heating On")
else:
print("Heating Off")
count = count + 1
for count in range(1, 5):
temp = float(input("Enter temperature: "))
if temp < 18.0:
print("Heating On")
else:
print("Heating Off")
for count in range(5):
temp = float(input("Enter temperature: "))
if temp < 18.0:
print("Heating On")
else:
print("Heating Off")
count = 5
while count > 0:
temp = float(input("Enter temperature: "))
if temp < 18.0:
print("Heating On")
else:
print("Heating Off")
count = count - 1
298 exam-style questions on AQA GCSE Computer Science Programming concepts. Each one has a worked solution and a mark scheme showing where the marks go.