Skip to content

Instantly share code, notes, and snippets.

@pknowledge
Created September 1, 2018 18:50
Show Gist options
  • Save pknowledge/5bcc9c0446115ee7ac45478ee8d7aed9 to your computer and use it in GitHub Desktop.
Save pknowledge/5bcc9c0446115ee7ac45478ee8d7aed9 to your computer and use it in GitHub Desktop.
Python Tutorial for Beginners-if..elif..else statements + nested IF statements
# Python Tutorial for Beginners-if..elif..else statements + nested IF statements
#------------nested IF statements--------
x = 10
if x >= 0:
print("x is positive ")
if (x%2) == 0:
print("x is even")
else:
print("x is odd")
else:
print("x is negative")
#-------------if..elif..else statements-------------
name = input("Enter a Name: ")
if name == "Max":
print("Name Entered is : ", name)
elif name == "Max":
print("Name Entered is : ", name)
elif name == "Roy":
print("Name Entered is : ", name)
elif name == "Eli":
print("Name Entered is : ", name)
else:
print("The Name entered is invalid")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment