76.1k views
1 vote
A line of code that begins with the while needs to end which symbol?

#
"
:
.

2 Answers

4 votes

Answer:

: is the right answer

User Rakeeb Rajbhandari
by
3.6k points
3 votes

A line of code that begins with the "while" needs to end with ":" symbol

Step-by-step explanation:

In python, the while loop statement has ":" at the end of the line.

Syntax:

while expression:

code(s) or statement(s)

Example:

cnt = 0

while (cnt < 5):

print 'cnt:', cnt

cnt = cnt + 1

Like other programming languages, while loop works in the same way except that in python it comes alone with "else" statement. When the condition is false, "else" statement gets executed.

Example:

#!/usr/bin/python

cnt = 0

while cnt < 5:

print cnt, " is less than 5"

cnt = cnt + 1

else:

print cnt, " is not less than 5"

User Kevpie
by
4.2k points