In: Computer Science
Read the following code:
x = 1
while(x < 26)
print(x)
x = x + 1
There is an error in the while loop. What should be fixed?
Add a colon to the end of the statement Begin the statement with the keyword count Change the parentheses around the test condition to quotation marks Use quotation marks around the relational operator
Question 2(Multiple Choice Worth 5 points)
(03.03 LC)
Python uses __________ to determine whether the condition of a
while loop is true or false.
algebra artificial intelligence Boolean logic input
Question 3(Multiple Choice Worth 5 points)
(03.03 LC)
What is the proper syntax for writing a while loop in Python?
Begin the statement with the keyword repeat End the statement with a semicolon Place the test condition outside of parentheses Use relational operators to indicate test conditions
Question 4(Multiple Choice Worth 5 points)
(03.03 LC)
What is the purpose of using a while loop in Python?
To repeat an action when the condition is false To repeat an action when the exact number of repetitions is known To repeat an action when the exact number of repetitions is unknown To repeat an action when the condition is not stated
Question 5(Multiple Choice Worth 5 points)
(03.03 MC)
Read the following code:
n = 2
while(n < 5):
print(n)
n = n + 1
What output would be produced for the given values of n?
0 1 2 3 4 1 2 3 4 5 2 3 4 2 3 4 5
Read the following code:
x = 1
while(x < 26)
print(x)
x = x + 1
There is an error in the while loop. What should be fixed?
Add a colon to the end of the statement
Begin the statement with the keyword count
Change the parentheses around the test condition to quotation
marks
Use quotation marks around the relational operator
Answer: add a colon to the end of the statement
Question 2(Multiple Choice Worth 5 points)
(03.03 LC)
Python uses __________ to determine whether the condition of a while loop is true or false.
algebra
artificial
intelligence
Boolean
logic
input
ANSWER: Boolean
Question 3(Multiple Choice Worth 5 points)
(03.03 LC)
What is the proper syntax for writing a while loop in Python?
Begin the statement with the keyword repeat
End the statement with a semicolon
Place the test condition outside of parentheses
Use relational operators to indicate test conditions
ANSWER: Use relational operators to indicate test conditions
Question 4(Multiple Choice Worth 5 points)
(03.03 LC)
What is the purpose of using a while loop in Python?
To repeat an action when the condition is false
To repeat an action when the exact number of repetitions is
known
To repeat an action when the exact number of repetitions is
unknown
To repeat an action when the condition is not stated
ANSWER: To repeat an action when the exact number of repetitions is unknown
Question 5(Multiple Choice Worth 5 points)
(03.03 MC)
Read the following code:
n = 2
while(n < 5):
print(n)
n = n + 1
What output would be produced for the given values of n?
0 1 2 3 4
1 2 3 4 5
2 3 4
2 3 4 5
ANSWER: 2, 3, 4
NOTE: please put proper gap's and space's from next time
Thanks and regards
if you like the answer please give a thumbs up
if you have a problem, feel free to comment.