Ask Question

A line of code that begins with the while needs to end which symbol?

#

"

:

.

+5
Answers (1)
  1. 13 October, 02:56
    0
    A line of code that begins with the "while" needs to end with ":" symbol

    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"
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “A line of code that begins with the while needs to end which symbol? # " : . ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers