If statements in Python are easy (if, elif, else) 🤔

preview_player
Показать описание
#python

Python if elif else control flow

00:00:00 if statements
00:01:27 else statements
00:02:19 elif statements
00:04:22 exercise 1
00:05:45 exercise 2
00:06:37 booleans
00:08:03 conclusion
Рекомендации по теме
Комментарии
Автор

# 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")

BroCodez
Автор

Don’t stop making videos dude, ur one of the best teachers on here man 👏

Tony.Vibez.
Автор

Best learning to code channel. Breaks it down so well.

PLP
Автор

print("Thank you Bro! You're GOLD!")

daydarasensei
Автор

Age=int(input ( " enter your age:"))
If age <21:
Print("your age is too young to marry")
Elif 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

anjali
Автор

If nice = "best"
Print("This man is better than my teacher i learned what he explained here easier than what i did in that 3 hour lesson")
Else:
Print("make sure to suscribe to this goat")

luvjotbhachu
Автор

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")

aryansharma
Автор

age=int(input("Enter your age: "))
if age<18 and age>0:
print("You aren't eligible to take driving license")
elif age >18 and age<60:
print("You are eligible to take driving license")
elif age>60:
print("Being a aged person, you aren't eligible for driving license")
else:
print("You haven't been born

MystikPrae
Автор

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

jetty
Автор

money = 288
print(f"Current Money: {money}$")
x = int(input("How much money do you want to withdraw from the bank? "))

if x <= money:
money -= x
print(f"You are withdrawing {x} dollars. You have {money}$ left.")
else:
print("Please try a different amount. You are trying to withdraw more money than you have.")

deboupgaming
Автор

awesome explanations dude everything was clear and concise as a beginner, keep up the work subbed <3

braydenfrith
Автор

4:12 I set mine to 'Retirement home successfully called!' 😂

FedoraKing
Автор

I like the fact that you always write it's easy.

mademesmile
Автор

In VS, using Python, how do I get that box at the bottom of the editor where I enter my age?

jim
Автор

Thank you Mister Bro Code!
You're a legend!

watchtheskies
Автор

entertained me while teaching me 10/10 vid

amirahsmith
Автор

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?

fbushphone
Автор

Question..
If we have 2 if functions and each have either an elif and else. E g
def function(n)
X = 7
If n > 0:
X+= 1
elif n < 0:
X-=1
Return x
If n > 0:
X += 1
Else:
X = 9
Return x

What is the priority output? As in if both if conditions are met then which would x become, would it go to elif or else? Is there an order of precedence or something?

Yamazakura
Автор

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?

lordender_kitty_official
Автор

price= int(input("Enter the price of the stock??: "))


if 2000 <= price <= 3000:
print ("Stock is in overbought zone")
elif price <= 1000 :
print ("Stock is in underbought zone")
elif price >= 1500:
print ("add to watchlist.")
else:
print("Don't add in watchlist.")

MangeshKumbhare-omgg
visit shbcf.ru