Python Programming For Beginners - Learn Python Programming in 24 Hours by Learning UpSkill
Author: Learning, UpSkill [Learning, UpSkill] , Date: April 16, 2020
, Views: 373
IF ELSE STATEMENT:
Like other languages in Python too we can combine else statement with if statement. An else statement contains the block of code that executes if the conditional expression in if statement resolves to 0 or a false value.
The else statement is an optional statement and there could be at most only one else statement following if .
Syntax:
if (expression):
statement(s)
else:
statement(s)
Let’s move to an example: Get an input from a user and check whether it is even or odd.
A = int(input(“Enter the number”))
if A %2==0:
print “The number is even”
else:
print “The number is odd”
Copyright Disclaimer:
This site does not store any files on its server. We only index and link
to content provided by other sites. Please contact the content providers
to delete copyright contents if any and email us, we'll remove relevant
links or contents immediately.