Тёмный

Control Flow in Python - If Elif Else Statements 

Programming with Mosh
Подписаться 3,9 млн
Просмотров 282 тыс.
50% 1

Learn how to use if elif else statements in Python to control the flow of your programs.
🔥Subscribe for more videos like this: goo.gl/6PYaGF
🔥Python tutorial for beginners: • Python Tutorials for B...
Python Exercises for Beginners:
programmingwithmosh.com/pytho...
Python Cheat Sheet:
programmingwithmosh.com/pytho...
Want to learn more from me? Check out my blog and courses:
programmingwithmosh.com
/ programmingwithmosh
/ moshhamedani

Опубликовано:

 

5 ноя 2018

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 159   
@victorjo7918
@victorjo7918 Год назад
Finally somebody talks about indenting,every detail counts.Very nice tutorial with a bonus quiz at the end.
@YoTone21
@YoTone21 8 месяцев назад
Exactly! I was struggling just now wondering what happened when my text mirrored the “correct answer” literally back spaced to indent my way vs coddys way and it worked
@ziniazinia4707
@ziniazinia4707 3 года назад
U have teached a 10000000000x greater than my teacher🤣🤣🤣🤣🤣
@YTtopPAULO
@YTtopPAULO 2 года назад
kurdy?
@muzankibutsujigaming7784
@muzankibutsujigaming7784 2 года назад
@@YTtopPAULO tf that mean bro ?
@YTtopPAULO
@YTtopPAULO 2 года назад
@@muzankibutsujigaming7784 ?
@seako.mp4
@seako.mp4 2 года назад
@@muzankibutsujigaming7784 Fr bro💀
@bigbrain01
@bigbrain01 Год назад
Herr mahn 😂
@azizt6773
@azizt6773 Год назад
Mosh, you are a legend im gonna enroll in your program in September this year. I'm happy that I've stumbled across you
@tahaahmed627
@tahaahmed627 4 года назад
Amazing tutorials . . . I am learning so much about python so easily!
@asshivam8117
@asshivam8117 Год назад
ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-zO9Z4inmLzM.html Topic : Control Flow and User Input in Python Department : CSE By Aditya(IIT DELHI) Notes available in Description Like, Share and Comment on the video Subscribe to the Ninepointers RU-vid Channel
@RFUQUA26
@RFUQUA26 9 месяцев назад
I came for if statements and learned a lot more, thanks for the video.
@rbgpro4
@rbgpro4 2 года назад
thank you so much for this you literally explained it way better than my teacher
@Slopki16
@Slopki16 2 года назад
Thank you sooooo much for this video!!!! Im making new project and i have to problems with if else and after looking 4 sec of your video i get it and fixed it.
@talinanderson611
@talinanderson611 Год назад
Thanks for your super informative tutorials! It really helps in my class. Mr.Hutter makes it too hard!
@wisdomdavid4923
@wisdomdavid4923 Год назад
I love you mosh! Thank you ...all the way from Nigeria
@isabellawilliams52
@isabellawilliams52 9 месяцев назад
Genuinely helpful with the indenting tip.
@isaacmatos2079
@isaacmatos2079 Год назад
You’re great bro, greetings from Dominican Republic
@sheikhmkrifat7749
@sheikhmkrifat7749 2 года назад
I am not so good in English , in 15:38 can you tell me how "Bag"> "apple" . They both are string , and how can you define one string is greater than another one? Thank You
@wambuasammy9161
@wambuasammy9161 2 года назад
yes...let him answer this one
@howpunny3570
@howpunny3570 2 года назад
i think he means that because bag starts with b (second letter of the alphabet) and apple starts wtih a (first letter of the alphabet) and because b = 2nd it also equals 2, a = 1st it also equals 1, and 2 is more than 1, therefore bag is greater than apple? then since cat is greater than bag, cat = c = 3rd letter of the alphabet = 3 > bag = 2nd letter of the alphabet = 2
@sheikhmkrifat7749
@sheikhmkrifat7749 2 года назад
@@howpunny3570 Thank you very much brother .
@nobelalan2728
@nobelalan2728 4 года назад
Thank you very much for the simple illustration
@ketexazeez1723
@ketexazeez1723 2 года назад
Awesome 👌. You are a true educator
@Tanookiiii
@Tanookiiii 2 года назад
THANK YOU FOR HELPING MY STRUGGLE
@Science-Made-Easy
@Science-Made-Easy 2 года назад
Mosh has made my life easier, you are the world's no.1 programmer and you are an excellent teacher... Thank You Very Much @MoshHamedani
@asshivam8117
@asshivam8117 Год назад
ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-zO9Z4inmLzM.html Topic : Control Flow and User Input in Python Department : CSE By Aditya(IIT DELHI) Notes available in Description Like, Share and Comment on the video Subscribe to the Ninepointers RU-vid Channel
@crstophermartinez8662
@crstophermartinez8662 Год назад
Thanks man for helping become a little more knowledgeable
@w8448
@w8448 3 месяца назад
Thank you very much, you're a wonderful teacher.
@adeyinkaadekanmi6586
@adeyinkaadekanmi6586 Год назад
You are a good instructor
@lasc1991
@lasc1991 3 года назад
Hey Mosh, you are a good teacher !! Explain very well .
@BahoraAvazova
@BahoraAvazova 3 месяца назад
thank you bro for a great tutorial lesson
@royaebadi-gi5gt
@royaebadi-gi5gt 8 месяцев назад
your tutorials are comprehensive and straightforward so that beginners can grasp it easily.
@sibongilemalama
@sibongilemalama Год назад
It has made me to understand python very well 🥳🥳
@TheMeditationHub2023
@TheMeditationHub2023 10 месяцев назад
You are the BEST!
@user-nb3ue4nh3t
@user-nb3ue4nh3t 5 месяцев назад
Thanks 👍 you are a good teacher 😊
@leynahoang3141
@leynahoang3141 2 года назад
you’re helping me with my comp sci midterm 😭😭
@imanibillahismail8526
@imanibillahismail8526 Год назад
Thank you Mosh👍
@StrigWilson
@StrigWilson 3 года назад
I'm a total noob but I've always been into computers, covid put me out of a job so here I am! Thanks man i appreciate people like you helping me get certs, because school isn't an option for me financially
@rishipatel4753
@rishipatel4753 2 года назад
got a job yet?
@StrigWilson
@StrigWilson 2 года назад
@@rishipatel4753 just started a help desk position last month! Keep on the grind man
@asshivam8117
@asshivam8117 Год назад
ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-zO9Z4inmLzM.html Topic : Control Flow and User Input in Python Department : CSE By Aditya(IIT DELHI) Notes available in Description Like, Share and Comment on the video Subscribe to the Ninepointers RU-vid Channel
@GreenlackX
@GreenlackX 2 года назад
Thank you so much 😊
@Inte8ranD
@Inte8ranD 5 месяцев назад
Thanks, Mosh....@Programming with Mosh
@Satyajit5858
@Satyajit5858 3 года назад
Nice explaination sir
@shakeel0atmeal273
@shakeel0atmeal273 Год назад
Thank you my friend 🙏🙏🙏
@sanzay.
@sanzay. 3 года назад
15:10 what did u mean by sorting in case of bag>apple and bag>cat? Didn't understand this part!
@habiba-cz4mc
@habiba-cz4mc 2 года назад
Your explanation is better than my TA
@dailysiva2582
@dailysiva2582 3 года назад
*Really awesome*
@osho2810
@osho2810 3 года назад
Great Sir
@marwanmarwan5810
@marwanmarwan5810 4 года назад
Sir Mosh.... you are awsome !
@ItzTyrax
@ItzTyrax Год назад
is there a way to apply this to labels? Say I have a label with the variable name LED so LED = Label(0,200,200) then maybe check the VALUE like LED.value is above say 25 It changes the position?
@todormetzov1235
@todormetzov1235 Год назад
thank you 🎉 ❤
@futurism010
@futurism010 2 года назад
No any words to express for you @MoshHamedani🤭!
@hazemalawawdeh9318
@hazemalawawdeh9318 4 года назад
You are a smart person boi
@YoTone21
@YoTone21 8 месяцев назад
You are the best thank you!! I was going over if else statements using coddy tech, and they failed to explain indentation is important. Literally as soon as I indented the damn code worked smh 😂😂
@julbeeyaren8483
@julbeeyaren8483 8 месяцев назад
Mosh is my favourite Tutor so far. I panic if I can't find his video on a topic I want 🤣
@alexanderhanks9051
@alexanderhanks9051 Год назад
Thanks
@MuhammadAhmed-vi2xt
@MuhammadAhmed-vi2xt 5 лет назад
Sir Mosh please make course on Django 2.1.3 because you already maked course on python now please make on django and its my humble request to you.
@rajabhishek2936
@rajabhishek2936 5 лет назад
Love it.....
@rajabhishek2936
@rajabhishek2936 5 лет назад
@@programmingwithmosh I complete core python sir.
@mcblackk_x5011
@mcblackk_x5011 2 года назад
wow teachers on purpose dont teach this way cuz they don't care, great video!!!
@ramlaaal
@ramlaaal 3 года назад
sir what theme do you use in vs code
@SeifCookz
@SeifCookz 2 года назад
whats the app you used for this tutorial?
@mohammadanarul624
@mohammadanarul624 4 года назад
thank you so much sir...
@moondemudimba7920
@moondemudimba7920 5 лет назад
amazing tutorial
@moondemudimba7920
@moondemudimba7920 5 лет назад
I know Java, C, C++ and PHP I have been coding in those languages for 4 years now.. .. I want to extend my programming skills to solving problems, that's why I chose to learn python... I have been reading about it. It's an awesome and ever growing programming language... So it's worth learning...
@MzUrKeL
@MzUrKeL 8 месяцев назад
This is possibly the best breakdown. I've seen so far!
@killablaze1152
@killablaze1152 3 года назад
Sir good day, My name is Jason and I need your help. I'm a beginner in python doing if, else statements now. Please tell me how can I get in contact with you directly.
@user-hd3zq6we8b
@user-hd3zq6we8b 4 года назад
Best explanation 👍 sir
@prashh47
@prashh47 Год назад
Nice
@toddmaek5436
@toddmaek5436 Год назад
So is it safe to say that when thinking of the operators to think of them as logic gates?
@teluguhacker4160
@teluguhacker4160 2 года назад
Thank you so much sir . Please sir make video easy words in English sir
@user-gj8yk4fx7o
@user-gj8yk4fx7o 3 месяца назад
It works good in Mac too right?
@tankionlinegamer126
@tankionlinegamer126 Год назад
Sir, do you have any Ebook for complete beginners, if you know best e book pls share
@SureshKumar-gm9cz
@SureshKumar-gm9cz 5 лет назад
Pls add more videos
@HusamEmran
@HusamEmran 11 месяцев назад
the last part of bag and apple i did not get it ? the rest was well explained thank you
@BobWila
@BobWila Год назад
Hi Mosh, so say I got this condition where if he opts to select yes to retake the question, how can I rerun that specific variable/question?
@sammygang3181
@sammygang3181 6 месяцев назад
Not sure but I think it's goto
@PKOVBPK
@PKOVBPK 4 месяца назад
Hi Mosh I have one question and I can´t find answer. I read temperature which is float number. I have some zone from -10 to 10. And when I break this zone from outside I want to make action. if temperature > -10: do someting. elif temperature < 10: Do someting. But what is my problem? When I run microcontroler and actual temperature is -5.5. So I need to know how to specify the barier that when I´m already inside zone from -10 to 10 to do nothing. And when I break zone from outside to iside do what I want. I hope it´s clear. Can you help me how to solve it? Thank you so much :)
@milankbudha
@milankbudha 4 года назад
in this video,which python IDE you had used?plzz tell me
@tickogrey5846
@tickogrey5846 4 года назад
Ikr
@roselynearroyocastillo8402
@roselynearroyocastillo8402 3 года назад
im sorry that idk this but what is this used for?
@roqiyajaved6570
@roqiyajaved6570 5 месяцев назад
How do you save to go to the next lin
@ucancallmeultra.3864
@ucancallmeultra.3864 2 года назад
I didnt quite understand how he said bag is greater than apple did he meant what words comes before in the dictionnary?
@hazemalawawdeh9318
@hazemalawawdeh9318 4 года назад
Can you make a math QUIZ in python ?
@himanshuthakur4761
@himanshuthakur4761 7 месяцев назад
How is bag greater than apple(in what context)?
@nobelalan2728
@nobelalan2728 4 года назад
but I have question about the age. I think it should be >=18 and not
@newshapeymani9119
@newshapeymani9119 2 года назад
its because when you try to write it in the shorter version it reads like this 18
@greenishengland
@greenishengland 4 года назад
Can we use If conditional statement without using else statement and print the else statement?
@MparRS
@MparRS Год назад
no
@chungku7474
@chungku7474 3 месяца назад
What is it with bag, apple and cat, please help
@yuvrajwankhede8083
@yuvrajwankhede8083 6 месяцев назад
I did not understand when he said "bag" is greater than "apple" because when we sort it comes before. can someone explain?
@ErkanOkman
@ErkanOkman 5 лет назад
👍👏
@mattnowak2987
@mattnowak2987 7 месяцев назад
Quick question dumb question how is bag greater than apple?
@navrozsalim6944
@navrozsalim6944 Год назад
legend
@kripasaxena457
@kripasaxena457 4 года назад
In last program ..I tried it but it gave me error as 'c' is not defined...reply soon
@ssegiriinyapaul816
@ssegiriinyapaul816 8 месяцев назад
>>> temperature = 11 ... if temperature > 11: ... print("Hot") ... print("drink water") >>> print("Done") SyntaxError: multiple statements found while compiling a single statement am using python 3.11.5, why do i get such a result?
@sheikhrashid3055
@sheikhrashid3055 3 года назад
How bag is greater than apple?
@rickybrenay6249
@rickybrenay6249 2 года назад
💯
@stephendgj
@stephendgj 10 месяцев назад
did you make a mistake at 13.48 it should be > instead of
@sssapss
@sssapss 2 года назад
How bag is smaller than cat?
@prosatisfyingdominoes1537
@prosatisfyingdominoes1537 Год назад
what app do you use for python
@biggiecheese8785
@biggiecheese8785 Год назад
replit
@kirans936
@kirans936 4 года назад
Can I know the name of software used here plz 🙏
@sanjaysawant1975
@sanjaysawant1975 3 года назад
hey friend you asked the name of software the name is "Visual studio code" if you want to know the theme name it is "Horizon italic"
@AlexA-cj5my
@AlexA-cj5my 4 года назад
It writes for me “TypeError: ‘
@cricksterg2324
@cricksterg2324 4 года назад
Same
@ziniazinia4707
@ziniazinia4707 3 года назад
Lol
@al-harithodeh9121
@al-harithodeh9121 7 месяцев назад
4:02 and 5:58 and 15:09
@devdwr9208
@devdwr9208 5 лет назад
This is how works AI xD
@r0d1tub2
@r0d1tub2 9 месяцев назад
why is bag not greater than cat. That I did not understand
@lilskely6278
@lilskely6278 3 года назад
wait so in 15:20 because b comes after a it will turn true and c comes after b so bag will become false in conclusion this will not be grater than cat, srls i never knew that this could happen in python!
@someXone
@someXone 2 года назад
Exactly me too. This is my first time learing python and my mind is blowing up rn
@VaheOhanyan-ig7cj
@VaheOhanyan-ig7cj Год назад
what is this text editor's name?
@georgekomeh
@georgekomeh 7 дней назад
Vs code
@lewisqiu5960
@lewisqiu5960 Год назад
Sorry i didn’t get it why bag great than apple And bag not great than cat. How can i tell
@samabdollahian9841
@samabdollahian9841 4 года назад
The quiz for how b if false dosen't make sense
@MrFamousguy13
@MrFamousguy13 3 года назад
bag comes after apple does not make sense to me I thought it was going to measure the string size and based on the number of character it was going to determine wheater it was longer or shorter
@emeldaoluoch8582
@emeldaoluoch8582 2 года назад
Some clarification Set high income to false Good credit to true And student false Then here is the code: If (high income and good credit) or not student: Print("eligible") Else: Print("not eligible") Am getting eligible I don't understand
@sanketkoirala
@sanketkoirala 2 года назад
Because you’ve set student as false. Which means the person is not a student So they’re eligible.
@yiltushable
@yiltushable Год назад
its because ha has a mistake in the video
@someXone
@someXone 2 года назад
That elif is mistaken of else. Or It is actually elif. Someone please response. That 15:32 part is too confusing for me 😭
@David91777
@David91777 2 года назад
No, from what I understand, it is meant to be elif. You use elif as a substitute condition in case the “if” statement doesn’t work. But if both the “if” and “elif” statements are not true, then it will print the “else” condition. I hope you understand this, but I’m a new programmer who only started this week, so don’t rely on my explanation as I could be wrong. 🙏🏾
@someXone
@someXone 2 года назад
@@David91777 Thanks mate for response Yhh, i asked one of my friends in this elif confusion and he told about the use of elif as it is used as substitute and i understand how it works in python And i’m also newbie to this. I hope you also doing good. #Happylearning
@David91777
@David91777 2 года назад
@@someXone Thanks very much man… Good luck and stay blessed. 🙏🏾
@naitiksingh8957
@naitiksingh8957 8 месяцев назад
Sevy
@alfredo6307
@alfredo6307 4 года назад
Some practice code I wrote. I think it works. response = input("Can you speak English? ") if response != "no": can_speak_english = True else: can_speak_english = False response2 = input("Can you speak Spanish? ") if response2 != "no": can_speak_spanish = True else: can_speak_spanish = False if can_speak_spanish and can_speak_english: print("You are eligible for a larger loan") else: print("You are eligible for a smaller loan")
@alfredo6307
@alfredo6307 4 года назад
Update. It doesn't work 100% of the time properly
@sssapss
@sssapss 2 года назад
it's wrong code
@asshivam8117
@asshivam8117 Год назад
ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-zO9Z4inmLzM.html Topic : Control Flow and User Input in Python Department : CSE By Aditya(IIT DELHI) Notes available in Description Like, Share and Comment on the video Subscribe to the Ninepointers RU-vid Channel
@TaylorGang44
@TaylorGang44 Год назад
i'm pretty sure your code is wrong sir, lol you're giving the same response to both option
@thelmaajomiwe1059
@thelmaajomiwe1059 6 месяцев назад
If can only come ones while elif comes as many as u want then close with else
@MRKAVYA079
@MRKAVYA079 Год назад
Me kya karu
@RadicalEdward_115
@RadicalEdward_115 4 года назад
Just add the spaces lol, your already typing in that area. Dont teach bad habbits
Далее
How to Use Lists in Python
18:49
Просмотров 284 тыс.
▼ОНИ ЩУПАЛИ МЕНЯ 👽🥴
32:00
Просмотров 542 тыс.
100❤️
00:20
Просмотров 1,8 млн
If statements in Python are easy (if, elif, else) 🤔
8:21
Is Coding Still Worth Learning in 2024?
9:33
Просмотров 207 тыс.
5 Mistakes That Are Killing Your Coding Progress
3:42
The if-elif-else Statement in Python
12:45
Просмотров 20 тыс.
Python for Beginners - Learn Python in 1 Hour
1:00:06
Просмотров 17 млн
▼ОНИ ЩУПАЛИ МЕНЯ 👽🥴
32:00
Просмотров 542 тыс.