Computer Applications
What are selection statements ? How are they useful ?
Python Control Flow
4 Likes
Answer
A statement that carries out a set of instructions depending upon a condition's result is known as a selection or conditional statement. Python provides selection statements in the form of if and if-else statements.
These statements enable a program to carry out a set of instructions depending upon a condition's result. For example,
num = 5
if num >= 0 :
print "Positive"
else :
print "Negative"
Answered By
2 Likes
Related Questions
What will the output of following code ?
for i in range(1, 0) : print i
- 0
- 1
- No output
- Error in code
What is the output of following code ?
while 3 >= 3 : print 3
- 3 is printed once
- 3 is printed three times
- 3 is printed infinitely until program is closed
- Error in code
What are looping statements ? How are they useful ?
Differentiate between if and if-else statements.