Question
PLZ ANSWER ALL QUESTIONS Question 4 Write a program that asks the user for their name and how many times to print it. If I
PLZ ANSWER ALL QUESTIONS
Question 4
Write a program that asks the user for their name and how many times to print it. If I enter Bob and 4 it should print:
Bob Bob Bob Bob
Which loop correctly does this?
Group of answer choices
a. name = input("Enter your name: ") num = int(input("Enter a positive number: ")) c = 0 while (c > num): print (name) c = c + 1
b. name = input("Enter your name: ") num = int(input("Enter a number: ")) c = 0 while (c < num): print(name) c = c + 1
c. name = input("Enter your name: ") num = int (input("Enter a number: ")) c = 1 while (num <= name): print (name) c = c + 1
d. name = input("Enter your name: ") num = int(input("Enter a number: ")) c = 0 while(c <= num): print (name)
Question 6
Consider the following code:
val = 0 while (val > 10): val = val + 1 print (val)
What is the error?
a. The loop will not stop because val never changes.
b. It should be val < 10
c. The loop will not stop since val is counting the wrong direction.
d. There is no error.
Question 7
For a loop to stop, the loop control variable must ______________.
a. decrease in value
b. be a certain specified input
c. be a boolean
d. be a certain value
Question 8
In a(n) _______________ loop, you know ahead of time how many times the loop will repeat.
a. count variable
b. initialization
c. condition
d. user input
Question 9
Which range function will print all odd numbers between 11 and 33?
a. range (11, 34)
b. range (11, 34, 2)
c. range (11, 33, 2)
d. range (11, 33)
Question 10
What is output by the following code:
for x in range (5, 10): print (x * 3, end=" ")
a. 8 9 10 11 12 13
b. 15 18 21 24 27 30
c. 15 18 21 24 27
d. 5 6 7 8 9
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started