# 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")
at 4:18 you explained how to make the older than 100 statement dominant but what if - and this is more useful practically- S.o wanted to print that statement " You are too old to sign up" but that statement is only a joke and the user gets signed in anyway that's question 1 question 2 is whats the difference bet. intput ( x): and int(input( x) : they both get auto printed While I was looking for a way to add a variable give it a value and only gets printed if input response == x/x Question 3 is how do I fix this code of mine... # Online Python - IDE, Editor, Compiler, Interpreter age = int(input("Enter your age:")) if age >= 18: print("You are now signed up!") elif age = 99: int(input("Are you sure?") input answer = "Yes" print("Alright we dont judge!") else: print("Thats what I thought") else: print("You arent old enough ;(" ) just tryna exercise my brain here lol EDIT* you answered my third question in the video lol I paused the video to make this exercise for myself lmao
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
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
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")
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
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🧡
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
# 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 :>
name = input("Type in your name. :") if name == "": print("TYPE YOUR NAME!!") elif name == " ": print("Your name is a space?? Bro what.") else: print("Alright. Thank you!") age = int(input("Type in your age to sign up. :")) if age >= 100: print("You serious?") elif age >= 50: print("Sorry, but your too old for this job.") elif age >= 18: print("Your hired!") else: print("Your underaged.") Thanks for teaching me!
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
a = int(input("Enter a number: ")) b = int(input("Enter a number: ")) c = int(input("Enter a number: ")) if a>b & a>c: print(f"{a} is greater") elif b>a & b>c: print(f"{b} is greater") else: print(f"{c} is greater") #To find the greatest among three numbers
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!")
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?
name = input ("whats your name?") print ("nice im python") age = input ("age?") print ("cool") # here is a challenge to everyone who wanna solve this problem # would you like to learn coding? make a user input with yes or no but make it so only with IF or ELSE nothing else! # for example see below choice = input ("would like to learn coding? yes or no?:") if choice: no print("thats sad")
#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")
see this code.. code should be working right????????🤧🤧 👇👇 print("would you like to try") response = input("press 'Y' for yes and 'N' or no: ") if response.upper == "y": print("I'll get you ready") elif response.upper == "n": print("Come back next time!!") else: print("you press the wrong button") please correct me sombody
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()
# if else and elif statements #exercise 1 response = input("would you like some coffee? (Y/N): ") if response == "Y": menu = int(input("which flavour of coffee would you have? (1/2/3): ")) elif response == 1: print("here is your 1 coffee") elif response == 2: print("here is your 2 coffee") elif response == 3: print("here is your 3 coffee")
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
*sorry for my bed england* / guess1 = int(input("Enter a digit. You have 3 chance to guess it. İf its same as mine, you win! ENTER: ")) number = 5 if guess1 == number: print(f"yes, it was {number}. lucky bastard... you win! ") else: guess2 = int(input(f"HAH LOSER, It's not {guess1}. Let's try it again (enter): ")) if guess2 == number: print(f"yes, it was {number}. You win!") else: guess3 = int(input(f"Nope, loser. It's not {guess1} or {guess2}. You're last chance (enter): ")) if guess3 == number: print(f"Yes, it was {number}. You finally won! Be proud of yourself, with your wrong answers, loser.") else: print(f"Unfortunately, it's not {guess1}, {guess2} or {guess3}. It was... actually forget about it, bye.") / wrong code was look like this: / guess1 = int(input("Enter a digit. You have 3 chance to guess it. İf its same as mine, you win! ENTER: ")) number = 5 if guess1 == number: print(f"yes, it was {number}. lucky bastard... you win! ") else: guess2 = int(input(f"HAH LOSER, It's not {guess1}. Let's try it again (enter): ")) if guess2 == number: print(f"yes, it was {number}. You win!") else: guess3 = int(input(f"Nope, loser. It's not {guess1} or {guess2}. You're last chance (enter): ")) if guess3 == number: print(f"Yes, it was {number}. You finally won! Be proud of yourself, with your wrong answers, loser.") else: print(f"Unfortunately, it's not {guess1}, {guess2} or {guess3}. It was... actually forget about it, bye.") /
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")
# 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")
In example 1 you could do
if age>=18 and age
Thank you
Man, you have taught me so much with these excellent videos, thank you.
No food 🥲
at 4:18 you explained how to make the older than 100 statement dominant but what if - and this is more useful practically- S.o wanted to print that statement " You are too old to sign up" but that statement is only a joke and the user gets signed in anyway
that's question 1
question 2 is whats the difference bet.
intput ( x):
and
int(input( x) :
they both get auto printed While I was looking for a way to add a variable give it a value and only gets printed if input response == x/x
Question 3 is how do I fix this code of mine...
# Online Python - IDE, Editor, Compiler, Interpreter
age = int(input("Enter your age:"))
if age >= 18:
print("You are now signed up!")
elif age = 99:
int(input("Are you sure?")
input answer = "Yes"
print("Alright we dont judge!")
else:
print("Thats what I thought")
else:
print("You arent old enough ;(" )
just tryna exercise my brain here lol
EDIT* you answered my third question in the video lol I paused the video to make this exercise for myself lmao
Don’t stop making videos dude, ur one of the best teachers on here man 👏
Best learning to code channel. Breaks it down so well.
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
shouldn't it be (Num%2)?
yes
@@johndank2209
num = int(input("Enter your number:"))
if (num%2) == 0:
print("Number is even.")
else:
print("Number is odd.")
print("Thank you Bro! You're GOLD!")
Thank you Bro! You're GOLD!
Typeface error : line 1
Idiot
Python in youtube 😅@@PDsChannel0112
@@PDsChannel0112 print("you all are gold")
@@sketchwithviren85you all are gold
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
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")
do you have any idea how to get the input line to check the condition of if else statements
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
awesome explanations dude everything was clear and concise as a beginner, keep up the work subbed
this comment is now 1 year old, can you tell me your progress so far?
thank you guy on the internet
Thanks for sharing. I always recommend you to the crew at the YMCA comp club I run. How do you get that colorful terminal text?
NICELY DONE BRO...❤
Good job! What about types of arrays?
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🧡
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
# 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 :>
name = input("Type in your name. :")
if name == "":
print("TYPE YOUR NAME!!")
elif name == " ":
print("Your name is a space?? Bro what.")
else:
print("Alright. Thank you!")
age = int(input("Type in your age to sign up. :"))
if age >= 100:
print("You serious?")
elif age >= 50:
print("Sorry, but your too old for this job.")
elif age >= 18:
print("Your hired!")
else:
print("Your underaged.")
Thanks for teaching me!
Your the best
Awesome as always, bro!
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
why is your comment there on every single video of brocode?
Thank you very much, sir, I wish my lecturer were like you. please do another video on how to create multiple-choice quizzes.
Bro can you do this series for html css and web programming. It would be so beneficial for me
he has one, full HTML / CSS and a javascript to go with it
@@NotTheHeroStudios thanks for answer
a = int(input("Enter a number: "))
b = int(input("Enter a number: "))
c = int(input("Enter a number: "))
if a>b & a>c:
print(f"{a} is greater")
elif b>a & b>c:
print(f"{b} is greater")
else:
print(f"{c} is greater")
#To find the greatest among three numbers
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!")
Import math is useless
Free Lessons. love the vids u are the man
Watched it. Liked it.
you are too good at this thank u sm
NICELY DONE...❤
Much appreciated
# if statements are condition checkers if the condition is true it will execute the indented line of code
import math
# variables
shape = input("enter a shape: ")
if shape == "circle":
radius = int(input("enter a radius: "))
radius_2 = radius * radius
area_circle = radius_2 * math.pi
area_circle = round(area_circle)
print(f"your circle is {area_circle}cm²")
elif shape == "square":
width = int(input("enter a number: "))
area_square = width * width
print(f"your square is {area_square}cm²")
elif shape == "rectangle":
length = int(input("enter length: "))
width1 = int(input("enter width: "))
area_rectangle = length * width1
print(f"your rectangle is {area_rectangle}cm²")
elif shape == "triangle":
base = int(input("enter the length of your base: "))
height = int(input("enter the height: "))
area_triangle = base * height / 2
print(f"your triangle is {area_triangle}cm²")
else:
print("invalid shape")
this helps me !
Thanks this helps, am now subscribed
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?
Bro, you're the best.
hey bro thanks for these awsome videos!
cool
name = input ("whats your name?")
print ("nice im python")
age = input ("age?")
print ("cool")
# here is a challenge to everyone who wanna solve this problem
# would you like to learn coding? make a user input with yes or no but make it so only with IF or ELSE nothing else!
# for example see below
choice = input ("would like to learn coding? yes or no?:")
if choice: no
print("thats sad")
best of best
🤘Great Content!
Thank youuuuu this is very helpful
This was easy to learn thank you
you are the goatttt
you can also do! elif age != 18
print("You are to young!")
thanks Bro
i love u bhai❤
#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")
fully explained!
Beo ur the best.
thank you
Thank you
thanks man
Love it bro!
Ure a goat straight to the point
the one i've been searching not here
what if it's something like
if (num >12 - 15)
print("the number is between 12-15")
thank you bro
see this code.. code should be working right????????🤧🤧
👇👇
print("would you like to try")
response = input("press 'Y' for yes and 'N' or no: ")
if response.upper == "y":
print("I'll get you ready")
elif response.upper == "n":
print("Come back next time!!")
else:
print("you press the wrong button")
please correct me sombody
Thank you ❤️
Love u so much ❤
Correct me if I'm wrong but
Java
if ( _condition_ ) {
_Code_
}
Python
if _condition_ :
_Tab_ _Code_
In VS, using Python, how do I get that box at the bottom of the editor where I enter my age?
Thank you Bro!
🎩 off to Bro Code..
Where were these videos when i was dying doing my assignment at 4 am?
thx 4 vid bro !
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()
Now it is clear
bri saves the day
hey bro. Can you teach me depth first search and breadth first search in Python?
hi bro
can you explain how to program a pid control for a spike prime robot?
thx
p.s can you reply to my comment?
print("Love u Bro Code☻♥")
# if else and elif statements
#exercise 1
response = input("would you like some coffee? (Y/N): ")
if response == "Y":
menu = int(input("which flavour of coffee would you have? (1/2/3): "))
elif response == 1:
print("here is your 1 coffee")
elif response == 2:
print("here is your 2 coffee")
elif response == 3:
print("here is your 3 coffee")
else:
print("you can fck off respectively")
print("u saved my life")
2:02 thats what that website said💀
PLEASE do function and return please please please
print type(type(int))) what is input please tell me ?
Input is what allows you to add your age in this example.
My if/else code seems broken! I am still Bi-Polar!!!!! Help, please!!
For the algo
GLife
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
*sorry for my bed england*
/
guess1 = int(input("Enter a digit. You have 3 chance to guess it. İf its same as mine, you win! ENTER: "))
number = 5
if guess1 == number:
print(f"yes, it was {number}. lucky bastard... you win! ")
else:
guess2 = int(input(f"HAH LOSER, It's not {guess1}. Let's try it again (enter): "))
if guess2 == number:
print(f"yes, it was {number}. You win!")
else:
guess3 = int(input(f"Nope, loser. It's not {guess1} or {guess2}. You're last chance (enter): "))
if guess3 == number:
print(f"Yes, it was {number}. You finally won! Be proud of yourself, with your wrong answers, loser.")
else:
print(f"Unfortunately, it's not {guess1}, {guess2} or {guess3}. It was... actually forget about it, bye.")
/
wrong code was look like this:
/
guess1 = int(input("Enter a digit. You have 3 chance to guess it. İf its same as mine, you win! ENTER: "))
number = 5
if guess1 == number:
print(f"yes, it was {number}. lucky bastard... you win! ")
else:
guess2 = int(input(f"HAH LOSER, It's not {guess1}. Let's try it again (enter): "))
if guess2 == number:
print(f"yes, it was {number}. You win!")
else:
guess3 = int(input(f"Nope, loser. It's not {guess1} or {guess2}. You're last chance (enter): "))
if guess3 == number:
print(f"Yes, it was {number}. You finally won! Be proud of yourself, with your wrong answers, loser.")
else:
print(f"Unfortunately, it's not {guess1}, {guess2} or {guess3}. It was... actually forget about it, bye.")
/
*_This is inefficient…_* but I guess you already have learned more to improve it given that this is a 3 week old comment.
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")