xxxxxxxxxx
# IF ELSE ELIF
print('What is age?')
age = int(input('number:')) # user gives number as input
if age > 18:
print('go ahead drive')
elif age == 18:
print('come personaly for test')
else:
print('still underage')
xxxxxxxxxx
#if else loop in python
#simple example
age = int(input("What is your age: "))
if age < 18:
print("You can't vote")
#if you enter your age less than 18 it will print you can't vote
else:
print("you can vote")
#if you enter your age greater than 18 it will print you can vote
xxxxxxxxxx
# IF ELSE ELIF
age=int(input("Enter your age:"))
if age<=18:
print("sorry your are not eligible for vote")
elif age>=18:
print("u are eligible for vote")
else:
print("in some how the previou's condition fails else part will run")
xxxxxxxxxx
# plz suscribe to my youtube channel -->
# https://www.youtube.com/channel/UC-sfqidn2fKZslHWnm5qe-A
#if else conditions in python
a = "if else conditions are inportant"
if "else" in a:
print("Word is in a")
else:
print("word is not in a")
xxxxxxxxxx
word = input('Word: ') # This will ask you to print a word
if word == 'hello': # <- If your response is: 'hello'
print('world') # <- It will output: 'world'
elif word == 'world': # If the response is: 'world'
print("Hey, that's my line >:(") # It will print this
else:
print("Hey buster you gonna say hello or not?")
# If sombody prints ANYTHING ELSE other than 'hello' or 'world'
# It will output that print statment above!
#Hope this helped you!
xxxxxxxxxx
number = float(input("Number:"))
if number > 0:
print('Number is positive.')
print('The if statement is easy')
xxxxxxxxxx
# Prompt the user to enter a number
number = input("Enter a number: ")
# Check if the number is greater than 10
if int(number) > 10:
print("The number is greater than 10")
else:
print("The number is not greater than 10")
xxxxxxxxxx
if __name__ == '__main__':
n = int(input())
mod = n % 2
if mod == 1:
print('Weird')
elif 2 <= n <= 5:
print('Not Weird')
elif 6 <= n <= 20:
print('Weird')
elif n > 20:
print('Not Weird')