The program in Figure 1 needs to be changed so that it repeats four times using definite (count-controlled) iteration.
Figure 1
word = input("Enter a word: ")
if len(word) > 5:
print(word.upper())
else:
print(word.lower())
Select one option that does this correctly.
count = 1
while count <= 4:
word = input("Enter a word: ")
if len(word) > 5:
print(word.upper())
else:
print(word.lower())
count = count + 1
for i in range(0, 4):
word = input("Enter a word: ")
if len(word) > 5:
print(word.upper())
else:
print(word.lower())
for i in range(0, 5):
word = input("Enter a word: ")
if len(word) > 5:
print(word.upper())
else:
print(word.lower())
count = 4
while count > 0:
word = input("Enter a word: ")
if len(word) > 5:
print(word.upper())
else:
print(word.lower())
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.