Do you want to learn python from me with a lot of interactive quizzes, and exercises? Here is my project-based python learning course: codebasics.io/courses/python-for-beginner-and-intermediate-learners
Hi, Thanks for the tutorial, I am executing the same code as you, but when I am entering any dish from the indian , chinese or italian , program is only executing the else block and not the remaining block. I have added breakpoint also at if , elif blocks but it is not going inside the blocks. Any help would be appreciated. indian=["Samosa","Dal","Roti","Paneer"] chinese=["Noodles","egg role","Fried Rice"] italian=["Pizza","pasta","french fries"] dish=input("Enter the dish to check for its type:") if dish in indian: print("It is the indian dish") elif dish in chinese: print("It is the chinese dish") elif dish in italian: print("It is the italian dish") else: print("It is not in the indain,chinese,italian cuisines types")
NIce playlist. I'm learning Python from basics and i'm accustomed to Anaconda Jupiter notebook. I found Pycharm little bit difficult IDE. Can i continue with Jupiter or should I try to accustom with Pycharm as well ? Thanks
@codebasics: in If statement exercise . We need your help to make changes to the code. 2: Write a python program that can tell you if your sugar is normal or not. Normal fasting level sugar range is 80 to 100. We need to use AND Operator for low sugar range 80 to 100: patientsugar = float(input("Enter sugar level no: ")) # 3.1 - Ask user to enter his fasting sugar level if patientsugar > 80 and patientsugar < 100: print("Normal Sugar") # 3.2 - If it is above 100 then print that it is high otherwise print that it is normal elif patientsugar > 100: print("High Sugar") # 3.3 - If it is below 80 to 100 range then print that sugar is low elif patientsugar < 80: print("low sugar")
I found the leap year for the month with if statement its very good. # find out enterd year is leap year or not year=input("enter the year: ") year=int(year) if year/4==0: print("entered year is Leap year") else: print("enterd year is not leap year")
your code is not working for input whereas when i use raw_input it worked, why is it so? and i got to know through stack overflow this fix but didnt understand what they are trying too say.
Can anyone tell me why the input entered by the user is considered a string & not an integer or a float? Would it not be considered an integer or float since the user is inputting a number & not text?
asian = ["biryani","siripaye","haleem","sajji"] Italian = ["pizza","pasta","burger"] Chinese = ["boiled rice","egg role","potato role"] dish = input("enter a dish: ") if dish in asian: print("asian") elif dish in Italian: print("italian") elif dish in Chinese: print("chinese") else: print("according to my knowledge that i have this particular dish" ,dish, "is not belonged to the related lists")
can you tell me how to do this thing ----- if connection_str == "bad": print("cant run program (this is a beta program)") else: print("running program") pass i have made a variable called connection and made it a input but I want to do if the person connection is bad it will not run the program.
Hello, I just started learning Coding. I have one doubt. I have written the following code with only "if" and only code line at the end with "else". But, it's working exactly same like yours. Please see as follows : indian=["samosa","daal"] chinese=["noodles","fried rice"] american=["burger","finger chips"] dish=input("Enter a dish name : ") if dish in indian: print("Indian") if dish in chinese: print("Chinese") if dish in american: print("American") else: print("Sorry not found") Can you please explain when to use else and else if? I am little bit confused.
in python, there is no "else if" condition, it is "elif". when you have more than 2 conditions, you use elif. in your code, you have to use elif in line numbers 7 and 9.
Sir aap hindi me bhi aplod karne wale the pr kahi koi link dikha ni sir.... Aap ne kaha tha ki hindi me bi aplod karne wale the..... Sir kya aap link send kar skte hai ......
Hi Sir, Trying to run the same code in Jupyter as num = input("Enter a number: ") num = int(num) if num%2 == 0: print("The number is even ") else: print("The number is odd ") However I am getting the error as TypeError: 'str' object is not callable. Please could you tell me how to resolve this.
Malaysian style: indian = ['thosai','idli','chapati'] chinese = ['kuew tiau', 'wan tan mee','chicken rice'] malay = ['nasi lemak','roti canai','rendang','ayam masak merah'] dish = input('What you would like to have:') if dish in indian: print ('This indian dish is available') elif dish in chinese: print('This chinese dish ia available') elif dish in malay: print('This malay food is available') else: print('This food is not available. Sorry about that')
pakistani=["samosa", "daal", "Rooti"] Indian= ["masala dhosa", "Chapati", "Khakhra"] italian= ["patisa", "pizza", "masala"] dish=input("Enter the dish name: ") if dish in pakistani: print("Pakistan Zindabad") elif dish in Indian: print("Pak Indo Friendship") elif dish in italian: print("Italy+Indian+Pakistan") else: print("Sorry based on little info, I don't know the cuisine.")
Doesnt work for me this is my code: indian=["samosa","daal","naan"] chinese=["egg roll","pot sticker","fried rice"] italian["pizza","pasta","risoto"] dish=input('enter dish name') if dish in indian: print("indian") elif dish in chinese: print("chinese") elif dish in italian: print('italian') else: print('no dish found')
I also noticed that if you make a new python project that you have to make sure you are running the new one. You have to select run from the header menu or it will continue running the previous program. Hope this helps.
try this indian = str( indian ) chinese = str ( chinese ) italian = str ( intalian ) dish = str ( dish ) put this in your code before if, this will convert content in the list to string and same with the dish Hope this helps.
indian=["samosa","daal","naan"] chinese=["egg roll","pot sticker","fried rice"] italian=["pizza","pasta","risoto"] dish=input('enter dish name') if dish in indian: print("indian") elif dish in chinese: print("chinese") elif dish in italian: print('italian') else: print('no dish found') 1) so the fault was with the spaces, you had spaces before else and elif functions 2)You missed "=" after italian in the 3rd line and everything was fine
Here is the link of exercise along with the solution, please work on it as it will make your learning solid: github.com/codebasics/py/blob/master/Basics/Exercise/8_if/8_exercise_description.md
Do you want to learn python from me with a lot of interactive quizzes, and exercises? Here is my project-based python learning course: codebasics.io/courses/python-for-beginner-and-intermediate-learners
Yeh! done successfully. thanks for knowledge sharing
number=input("Insert number:")
number=int(number)
if number=10 and number=20 and number
doing excesise is one of best way to gain confidence:
thank you so much sir love from nepal:
your teaching skill(style) is very fun and interesting
Thank you for this nice tutorial series! Its straight to the point, simple explanation .
Thank you so much for u r wonderful explaination......really u r a great teacher....
Hi,
Thanks for the tutorial,
I am executing the same code as you, but when I am entering any dish from the indian , chinese or italian , program is only executing the else block and not the remaining block. I have added breakpoint also at if , elif blocks but it is not going inside the blocks. Any help would be appreciated.
indian=["Samosa","Dal","Roti","Paneer"]
chinese=["Noodles","egg role","Fried Rice"]
italian=["Pizza","pasta","french fries"]
dish=input("Enter the dish to check for its type:")
if dish in indian:
print("It is the indian dish")
elif dish in chinese:
print("It is the chinese dish")
elif dish in italian:
print("It is the italian dish")
else:
print("It is not in the indain,chinese,italian cuisines types")
All your sessions are awesome. And I’ve a query.. In corporate, do Python developers use PyCharm or any other IDE ?
It can depend although it depends on developers comfort. They can use VS code or pycharm
@@programmingwithraahim oh okay. Thank you so much.
@@srikrithibharadwaj6779 Welcome bro
NIce playlist. I'm learning Python from basics and i'm accustomed to Anaconda Jupiter notebook. I found Pycharm little bit difficult IDE. Can i continue with Jupiter or should I try to accustom with Pycharm as well ? Thanks
pandagoi
# Graterthen and less then program
x=input("enter the value")
x=int(x)
y=input("enter the Value")
y=int(y)
if y
I have never eaten samosa,
but the happiness you describe it ... i need to try :)
You will love it. It is not very healthy choice of food but it will definitely generate a rush of happy hormones in your brain 😀
Thank you very much. May Buddha grant you and your family all that is good for your souls.
Thank you for these sessions...very helpful 👍👍
🙂👍
Beautifully Explained😍👌
JavaScript users
that "in" thing in the array he is talking about is
array.includes() in js
Thank me later
ありがとうございました
@@ohgeez9124 Np
best thank to the instructor , very nice learn
I am glad you liked it
@codebasics: in If statement exercise . We need your help to make changes to the code.
2: Write a python program that can tell you if your sugar is normal or not. Normal fasting level sugar range is 80 to 100.
We need to use AND Operator for low sugar range 80 to 100:
patientsugar = float(input("Enter sugar level no: "))
# 3.1 - Ask user to enter his fasting sugar level
if patientsugar > 80 and patientsugar < 100:
print("Normal Sugar")
# 3.2 - If it is above 100 then print that it is high otherwise print that it is normal
elif patientsugar > 100:
print("High Sugar")
# 3.3 - If it is below 80 to 100 range then print that sugar is low
elif patientsugar < 80:
print("low sugar")
TYSM you are a life saver
Thank you very much sir
exercise solution of Q no. 3 explain
your works are soo useful....!!
👍🙏
👌👌👌👌 catching easily it's great
I found the leap year for the month with if statement its very good.
# find out enterd year is leap year or not
year=input("enter the year: ")
year=int(year)
if year/4==0:
print("entered year is Leap year")
else:
print("enterd year is not leap year")
your code is not working for input whereas when i use raw_input it worked, why is it so? and i got to know through stack overflow this fix but didnt understand what they are trying too say.
Check your python version.input works in Python 3.x version
it is only working when i give the dish name in quotes as input .. if not it is giving error. why is that ? I have the same code as yours
Yes, why is that so?
Can anyone tell me why the input entered by the user is considered a string & not an integer or a float? Would it not be considered an integer or float since the user is inputting a number & not text?
the number itself is integer ,why we are type casting it to Integer?
what we do if i do not want to specify letters in upper case and lower case.
is it okay if i code this in jupyter , it seems easy to use
hi sir , when i learn python ,it shows a comment "Process finished with exit code 0", i cannot understand it.
I' am not able to debug , showing connection to python debugger is failed, why ??
asian = ["biryani","siripaye","haleem","sajji"]
Italian = ["pizza","pasta","burger"]
Chinese = ["boiled rice","egg role","potato role"]
dish = input("enter a dish: ")
if dish in asian:
print("asian")
elif dish in Italian:
print("italian")
elif dish in Chinese:
print("chinese")
else:
print("according to my knowledge that i have this particular dish" ,dish, "is not belonged to the related lists")
In debugger there are no variables or frames
So, what should I do
That window is hidden you need to to menu and make it visible. just google on how to show variables window in pycharm
@@codebasics Thank you
It has happened
@@varshasata8616 can you please tell me how you have done ??
I am having same problem
link to exercises is not working
Please provide workable link
It is working for me. Do not do copy paste, just directly click on the link
sir are you from bpit
Achal kaushik sir
I am from a college called DDIT I'm Gujarat, India. In a town called nadiad
@@codebasics thanks sir
your face really match too much from our colledge DSA sir
can you tell me how to do this thing ----- if connection_str == "bad":
print("cant run program (this is a beta program)")
else:
print("running program")
pass
i have made a variable called connection and made it a input but I want to do if the person connection is bad it will not run the program.
BRAVO⭐⭐⭐⭐⭐👏⚠️
Hi,
it seems they are case sensitive. What to do if the user enter the info in all caps?
add .lower() and that will convert the words to lower case
Hello,
I just started learning Coding.
I have one doubt. I have written the following code with only "if" and only code line at the end with "else". But, it's working exactly same like yours. Please see as follows :
indian=["samosa","daal"]
chinese=["noodles","fried rice"]
american=["burger","finger chips"]
dish=input("Enter a dish name : ")
if dish in indian:
print("Indian")
if dish in chinese:
print("Chinese")
if dish in american:
print("American")
else:
print("Sorry not found")
Can you please explain when to use else and else if? I am little bit confused.
in python, there is no "else if" condition, it is "elif". when you have more than 2 conditions, you use elif. in your code, you have to use elif in line numbers 7 and 9.
if there is another condition then you have to use elif, otherwise there is no condition you have to use else
Sir aap hindi me bhi aplod karne wale the pr kahi koi link dikha ni sir.... Aap ne kaha tha ki hindi me bi aplod karne wale the..... Sir kya aap link send kar skte hai ......
Hi Sir, Trying to run the same code in Jupyter as
num = input("Enter a number: ")
num = int(num)
if num%2 == 0:
print("The number is even ")
else:
print("The number is odd ")
However I am getting the error as TypeError: 'str' object is not callable.
Please could you tell me how to resolve this.
The error occurs due to a potential variable naming conflict; ensure that you haven't used "input" as a variable name before in your Jupyter Notebook.
Malaysian style:
indian = ['thosai','idli','chapati']
chinese = ['kuew tiau', 'wan tan mee','chicken rice']
malay = ['nasi lemak','roti canai','rendang','ayam masak merah']
dish = input('What you would like to have:')
if dish in indian:
print ('This indian dish is available')
elif dish in chinese:
print('This chinese dish ia available')
elif dish in malay:
print('This malay food is available')
else:
print('This food is not available. Sorry about that')
😋 I need to visit malaysia to try these recipes
@@codebasics once tasted,you will never leave Malaysia🤭
Wow python is much easier than C and java lolz 😆
pakistani=["samosa", "daal", "Rooti"]
Indian= ["masala dhosa", "Chapati", "Khakhra"]
italian= ["patisa", "pizza", "masala"]
dish=input("Enter the dish name: ")
if dish in pakistani:
print("Pakistan Zindabad")
elif dish in Indian:
print("Pak Indo Friendship")
elif dish in italian:
print("Italy+Indian+Pakistan")
else:
print("Sorry based on little info, I don't know the cuisine.")
Doesnt work for me
this is my code:
indian=["samosa","daal","naan"]
chinese=["egg roll","pot sticker","fried rice"]
italian["pizza","pasta","risoto"]
dish=input('enter dish name')
if dish in indian:
print("indian")
elif dish in chinese:
print("chinese")
elif dish in italian:
print('italian')
else:
print('no dish found')
How many times did you try it? You could have a spelling error when you input. Also the code looks good to me but check to see what the error is
I also noticed that if you make a new python project that you have to make sure you are running the new one. You have to select run from the header menu or it will continue running the previous program. Hope this helps.
try this
indian = str( indian )
chinese = str ( chinese )
italian = str ( intalian )
dish = str ( dish )
put this in your code before if, this will convert content in the list to string and same with the dish
Hope this helps.
it is not working for me as well, did you got the solution @ Vishak Bhaskar
indian=["samosa","daal","naan"]
chinese=["egg roll","pot sticker","fried rice"]
italian=["pizza","pasta","risoto"]
dish=input('enter dish name')
if dish in indian:
print("indian")
elif dish in chinese:
print("chinese")
elif dish in italian:
print('italian')
else:
print('no dish found')
1) so the fault was with the spaces, you had spaces before else and elif functions
2)You missed "=" after italian in the 3rd line
and everything was fine
Learn data science with python and pandas: ua-cam.com/video/CmorAWRsCAw/v-deo.html
No one but Hermione Granger: It's "Egg roll", not "Egg role".😁
Ahh. thanks for correcting :) and sorry my english is not the best but I am trying to improve :)
@@codebasics I think all the knowledge you share on your channel warrants your intellect
Here is the link of exercise along with the solution, please work on it as it will make your learning solid: github.com/codebasics/py/blob/master/Basics/Exercise/8_if/8_exercise_description.md
Why you are not using jupyter notebook ??
If user enter same dish name in capital letter then this code will give wrong o/p..for that how we write the code
this page not found
page is not available
Page is not available :(
hmmm....Samosas....
py! charm🙃