# if = Do some code IF condition is True # else = Do something else if above condition/s are False # ---------------------- # EXAMPLE 1 # ---------------------- age = int(input("Enter your age: ")) if age >= 100: print("You are too old to sign up") elif age >= 18: print("You are now signed up") elif age < 0: print("You haven't been born yet") else: print("You must be 18+ sign up") # ---------------------- # EXAMPLE 2 # ---------------------- response = input("Do you want food (Y/N)?: ") if response == "Y": print("Have some food") else: print("No food for you!") # ---------------------- # EXAMPLE 3 # ---------------------- name = input("Enter your name: ") if name == "": print("You did not enter your name!") else: print(f"Hello {name}") # ---------------------- # EXAMPLE 4 # ---------------------- online = False if online : print("You are online") else: print("You are offline")
Just started watching this series and you are an amazing teacher, very easy to follow along and information is sticking pretty well. Not forgetting what I've learnt from you so far. Well done man, these lessons still helping people out a year after being uploaded
Age=int(input ( " enter your age:")) If age 60: Print("your age is too old to marry") Else: Print("you both are perfect match each other") Even or odd Num=int(input ("enter your number:") If (num%2)==0: Print("number is even") Else: Print("number is odd") If statement Num=int(input("enter your number:") If ( num%2)==0
bro you should have posted a community post asking people to "join me to learn python everyday" since you are updating the python playlist. But still thanks for the content and teaching sir, LOVE from INDIA🧡
age=int(input("Enter your age: ")) if age0: print("You aren't eligible to take driving license") elif age >18 and age60: print("Being a aged person, you aren't eligible for driving license") else: print("You haven't been born
I have always believed that education is the ultimate code to crack. Thanks to Bro Code, I have been able to unlock some of the most complex programming languages and computer science concepts with ease. Your videos have been instrumental in helping me level up my skills. So, from the bottom of my heart (and stack), thank you for being the best educational channel out there. Keep up the good work, Bro Code! Your dedication to educating the masses about programming languages and computer science has been truly inspiring. I would love to connect with you and learn more about your journey and how you became one of the best educational channels out there. again, thank you for being a constant source of knowledge and inspiration for us all. You're the real MVP, Most Valuable Programmer
in java you can write && as well as || in the condition to check if multiple conditions are met or if one or the other of multiple conditions are met. does python have that kind of thing as well or would you have to do something like nesting if statements?
age = int(input("What is your age: ")) if age >= 18: print("You are an adult") elif age == 17: print("come back next year") else: print("you are underage")
# 1 United States Dollar equals = 81.49 Indian Rupee enterrupee = float(input("How many dollars do you want to convert into rupee: ")) onedollar = enterrupee * 81.55 print("Answer is" + " " + str(onedollar)) this is a dollar to rupee converter :>
money = 288 print("Current Money: 288$") x = int(input("How much money do you want to withdraw from a bank?")) if x > 288: print("You cant withdraw more money than you have.") if x
Guys try this! age = int(input("How old are you... BOI? ")) def age_questionary(): if age >= 100: print("OMG LMAO! Alright gramps you're signed up. Have fun old man.") elif age >= 18: print("Congrats! You're good to go... BOI. ") elif age < 0: print("You're kidding right? ") else: print("oh come on... YOU NEED TO BE 18+ TO SIGN UP YOU ANIMAL!!! ") print("GET LOST PETER PAN!") age_questionary()
Here's some code I made with if/elif/else statements in python: import math children = int(input("How many children do you have?: ")) if children == 0: print("Haven't you been married for 19 years?") elif children > 9: print("May God bless you!") elif children > 4: print("That's quite a few kids you got there.") elif children < 0: print("NO YOU DON'T!") else: print(f"Nice, I have {children} kids too!")
#Simple account login name = input("Enter your name: ") if name == "": print("Invalid response") print("Must be 18+ to join") age = int(input("Enter your age: ")) if age >= 125: print("Invalid response") elif age >= 18: print(f"Name: {name}") print(f"Age: {age}") elif age < 0: print("Invalid response") else: print("You are not old enough") response = input("Is the information above correct? (Y/N): ") if response == "Y": print("Account Confirmed") elif response == "N": print("Restart") else: print("Invalid response")
True False tuc = True #Available if tuc: #Coz this condition is true so it will print the intended text. print("It is available.") else: print("Not available!") It is available tuc = False #Not Available if tuc: #Coz this condition is false so it will print the else part. print("It is available.") else: print("Not available!") Not available! online = True if online : #Coz this condition is true so it will print the intended text. print("You are online") else: print("You are offline") You are online online = False if online : #Coz this condition is false so it will print the else. print("You are online") else: print("You are offline") You are offline
I have a prom today, this is a typical conversation that will occur many times. anwser = input("Bro are you drinking?: ") if anwser.lower() == "yes": a = input("Vodka or beer?: ") if a.lower() == "vodka": print("Good choice man") print("*Passes you the bottle* ") if a.lower() == "beer": print("Are you serious man?:") elif anwser.lower() == "no": you_sure = input("Are you sure? YOU WON'T DRINK WITH ME??? : ") if you_sure.lower() == "i will": a = input("That's a good choice, you want beer or vodka?: ") if a.lower() == "vodka": print("Good choice man") print("*Passes you the bottle* ") if a.lower() == "beer": print("Are you serious man?:") if you_sure.lower() == "no": print("Damnit go to hell.") else: print("You are wasted already")