Questions
Questions
Single choice

Question at position 8 If the missing lines are filled in correctly, the program should continuously take in input a character which will be concatenated to a word. However, if the character entered is in the list of vowels, it is NOT included in the concatenation, and the program ends. Below is an example output of the program, where bolded text is input to the program: Enter a character: TEnter a character: HEnter a character: EWord: TH [table] 1  vowels = ['A', 'E', 'I', 'O', 'U']2 word = ''3 keep_running = True4 5  while keep_running:6 character = input('Enter a character: ')7 if character in vowels:8 # code WILL go inside IF9 # code MAY go here10 # …11 # …12 print('Word:', word) [/table] Which of the following options is the correct missing code? (Code filled in has been bolded.) 7 if character in vowels:8 word = word + character9 else:10 keep_running = False7 if character in vowels:8 keep_running = False9 else:10 word = word + character7 if character in vowels:8 keep_running = False9 word = word + character7 if character in vowels:8 if keep_running:9 word = word + character10 else:11 keep_running = FalseClear my selection

Options
A.7     if character in vowels: 8          word = word + character 9      else: 10         keep_running = False
B.7     if character in vowels: 8          keep_running = False 9      else: 10         word = word + character
C.7     if character in vowels: 8          keep_running = False 9      word = word + character
D.7     if character in vowels: 8          if keep_running: 9              word = word + character 10         else: 11             keep_running = False
View Explanation

View Explanation

Verified Answer
Please login to view
Step-by-Step Analysis
Reframing the scenario in my own words helps set up the evaluation: the program reads characters, appends non-vowels to the word, and stops when a vowel is entered. The missing code must implement this behavior inside the loop, using the existing variables vowels and word. Option 1: 7 if character in vowels: 8 word = word + character 9 else: 10 keep_running = False This option concatenates the input character to the word when the character is a......Login to view full explanation

Log in for full answers

We've collected over 50,000 authentic exam questions and detailed explanations from around the globe. Log in now and get instant access to the answers!

More Practical Tools for Students Powered by AI Study Helper

Join us and instantly unlock extensive past papers & exclusive solutions to get a head start on your studies!