Python Programming Tutorial - 16: Nested IF-ELSE Statement

preview_player
Показать описание
In this tutorial we'll check out an interesting application of the nested if-else statement using a programming example.
Рекомендации по теме
Комментарии
Автор

I just don't get the purpose of the elif statement in this code. Why not just have it as an if as well, it seems to work the same?

mamc
Автор

I can't get this to work. But there is no way to contact "The Bad Tutorials, " I've noticed, if we have questions. Is there any way to contact The Bad Tutorials?

nelsonkane
Автор

Agreed awesome video and very useful!

kyshark
Автор

i am running this code in linux terminal. first i have made nested.py file and then running it on linux terminal. and when i enter somthing it shows me error:

Traceback (most recent call last):
  File "nested_if.py", line 4, in <module>
    if ord(char)>=65 and ord(char)<=90:           #A=65 Z=90 z=122
TypeError: ord() expected string of length 1, but int found

solankisagar
Автор

I liked the ELIF tutorial but instead of initializing a variable you can go with getting the input from the user i think that would be much useful for the programmers .

AshishSk-askAshish
Автор

awesome sir, i studied python, sql and c from your tutorials.please make videos on data structure also ....:)

arjit
Автор

I'm getting error in line 5, 7, 11 and 13 depends upon value, can anyone guide me?

pinkeishz
Автор

I running this code but it give error

Traceback (most recent call last):
  File "C:/Python27/word.py", line 1, in <module>
    char=input()
  File "<string>", line 1, in <module>
NameError: name 'R' is not defined
 how to fix it?

divayanshudeo
Автор

why you have used elif in between when you can just continue using else and if statements

gouthamkumar
Автор

I did get one issue like this

please enter numbera
Traceback (most recent call last):
File "C:/Users/Uday and else.py", line 2, in <module>
if ord (alphabett)>=65 and (alphabett)<=90 :
TypeError: '<=' not supported between instances of 'str' and 'int'
>>>
anybody can tell me about that issue.

UdayKumar-hedq
Автор

Thank you very, very much Madhur.
Your presentation is excellent.
Minor typo (hardly worth mentioning), "entered" not "enetered"

eb
Автор

Nice videos.

Uppercase letter*

English language has a single alphabet with 26 letters.

shihabkhan
Автор

I just didn't get one thing which i have seen in other programming languages why do we have to restart the shell every time to check the condition

shubhankgupta
Автор


check out the following codes where you are free to work with any numbers, instead of initialization :


print(" This Coding has been done by Ashish Sreekumar :\n")
print(" Check whether you earned a profit or loss or maybe niether of it  :\n")
print(" Enter the cost price of the item :")
cp = float(input () )
print (" Enter the selling price of the item  :")
sp = float(input ())

if (sp>cp):
     print ("Congratulations ! ")
     print ("You earned a profit of :", sp-cp, "Euros")
elif (cp>sp):
     print(" oops !")
     print("You made a loss of : ", cp-sp, "Euros")
else:
     print("You sold the commodity at it's actual cost price of :", sp, "Euros")
     print("So you niether earn a profit nor a loss :")
print("Thanks for using Python Ashish Sreekumar  :")

AshishSk-askAshish
Автор

var1="Gopal"
var2="Gokul"
var3="Chinju"
var4="Mary"

char=input()
if char is var1:
print("He is the father")
elif char is var2:
print("This is me!!")
elif char is var3:
print("This is my sister!!")
elif char is var4:
print("This is mom!!")
else:
print("They are outsiders")


What is the error in this code? No matter what i give as input, i get only "They are outsiders" as output

gokulneov