8. If Statement [Python 3 Programming Tutorials]

Поділитися
Вставка
  • Опубліковано 17 лис 2024

КОМЕНТАРІ • 84

  • @codebasics
    @codebasics  2 роки тому +1

    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

  • @sibirnayek2465
    @sibirnayek2465 3 роки тому +3

    Yeh! done successfully. thanks for knowledge sharing
    number=input("Insert number:")
    number=int(number)
    if number=10 and number=20 and number

  • @bishalshrismagar8907
    @bishalshrismagar8907 2 роки тому +1

    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

  • @AtulVijayP
    @AtulVijayP 4 роки тому +5

    Thank you for this nice tutorial series! Its straight to the point, simple explanation .

  • @rajualwarappan2584
    @rajualwarappan2584 3 роки тому +1

    Thank you so much for u r wonderful explaination......really u r a great teacher....

  • @ravindersingh8863
    @ravindersingh8863 3 роки тому +6

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

  • @srikrithibharadwaj6779
    @srikrithibharadwaj6779 3 роки тому +3

    All your sessions are awesome. And I’ve a query.. In corporate, do Python developers use PyCharm or any other IDE ?

  • @LiyaUlagam
    @LiyaUlagam 2 роки тому +4

    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

  • @THARUNKUMAR-m3d
    @THARUNKUMAR-m3d Рік тому

    pandagoi
    # Graterthen and less then program
    x=input("enter the value")
    x=int(x)
    y=input("enter the Value")
    y=int(y)
    if y

  • @SkillsForTeams
    @SkillsForTeams Рік тому

    I have never eaten samosa,
    but the happiness you describe it ... i need to try :)

    • @codebasics
      @codebasics  Рік тому +1

      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 😀

  • @Home-kj7wm
    @Home-kj7wm 2 роки тому

    Thank you very much. May Buddha grant you and your family all that is good for your souls.

  • @rajalakshmiramya6295
    @rajalakshmiramya6295 3 роки тому +1

    Thank you for these sessions...very helpful 👍👍

  • @thethinker6837
    @thethinker6837 3 роки тому

    Beautifully Explained😍👌

  • @kiyochi7705
    @kiyochi7705 3 роки тому +2

    JavaScript users
    that "in" thing in the array he is talking about is
    array.includes() in js
    Thank me later

    • @ohgeez9124
      @ohgeez9124 3 роки тому +1

      ありがとうございました

    • @kiyochi7705
      @kiyochi7705 3 роки тому

      @@ohgeez9124 Np

  • @mohdnasser9012
    @mohdnasser9012 4 роки тому +1

    best thank to the instructor , very nice learn

  • @newbie2learning199
    @newbie2learning199 2 роки тому

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

  • @Miipanda
    @Miipanda 3 роки тому

    TYSM you are a life saver

  • @cloudmahenderdaily4573
    @cloudmahenderdaily4573 3 роки тому

    Thank you very much sir

  • @Mecha666
    @Mecha666 2 роки тому

    exercise solution of Q no. 3 explain

  • @sindhupraj
    @sindhupraj 4 роки тому

    your works are soo useful....!!

  • @anshujoshi4131
    @anshujoshi4131 4 роки тому

    👌👌👌👌 catching easily it's great

  • @THARUNKUMAR-m3d
    @THARUNKUMAR-m3d Рік тому

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

  • @Saimelodies2512
    @Saimelodies2512 3 роки тому +2

    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.

    • @RaviShankarvirat
      @RaviShankarvirat 3 роки тому +1

      Check your python version.input works in Python 3.x version

  • @sandhyathippesh
    @sandhyathippesh 4 роки тому +2

    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

  • @KAEMO
    @KAEMO Рік тому

    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?

  • @True_living_2112
    @True_living_2112 2 роки тому

    the number itself is integer ,why we are type casting it to Integer?

  • @asraalyssa5839
    @asraalyssa5839 2 роки тому

    what we do if i do not want to specify letters in upper case and lower case.

  • @riddhidigital7604
    @riddhidigital7604 3 роки тому

    is it okay if i code this in jupyter , it seems easy to use

  • @not_lina7482
    @not_lina7482 3 роки тому

    hi sir , when i learn python ,it shows a comment "Process finished with exit code 0", i cannot understand it.

  • @creator_rajaa0068
    @creator_rajaa0068 3 роки тому

    I' am not able to debug , showing connection to python debugger is failed, why ??

  • @salaarraizami6527
    @salaarraizami6527 2 роки тому

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

  • @varshasata8616
    @varshasata8616 3 роки тому +1

    In debugger there are no variables or frames
    So, what should I do

    • @codebasics
      @codebasics  3 роки тому +1

      That window is hidden you need to to menu and make it visible. just google on how to show variables window in pycharm

    • @varshasata8616
      @varshasata8616 3 роки тому +1

      @@codebasics Thank you
      It has happened

    • @aniketpatel2147
      @aniketpatel2147 3 роки тому

      @@varshasata8616 can you please tell me how you have done ??
      I am having same problem

  • @khurramalimubasher6929
    @khurramalimubasher6929 3 роки тому +1

    link to exercises is not working
    Please provide workable link

    • @codebasics
      @codebasics  3 роки тому

      It is working for me. Do not do copy paste, just directly click on the link

  • @helloworld2740
    @helloworld2740 3 роки тому +1

    sir are you from bpit
    Achal kaushik sir

    • @codebasics
      @codebasics  3 роки тому +1

      I am from a college called DDIT I'm Gujarat, India. In a town called nadiad

    • @helloworld2740
      @helloworld2740 3 роки тому +1

      @@codebasics thanks sir
      your face really match too much from our colledge DSA sir

  • @bob-zb3ed
    @bob-zb3ed 3 роки тому

    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.

  • @tsaltslinger3268
    @tsaltslinger3268 3 роки тому +2

    BRAVO⭐⭐⭐⭐⭐👏⚠️

  • @janakiyeluripati6368
    @janakiyeluripati6368 3 роки тому

    Hi,
    it seems they are case sensitive. What to do if the user enter the info in all caps?

    • @pasindubimsara2241
      @pasindubimsara2241 Рік тому

      add .lower() and that will convert the words to lower case

  • @renukale6246
    @renukale6246 4 роки тому

    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.

    • @tabassumhossain811
      @tabassumhossain811 3 роки тому

      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.

    • @aishwarykulkarni1619
      @aishwarykulkarni1619 3 роки тому

      if there is another condition then you have to use elif, otherwise there is no condition you have to use else

  • @kiransoni1658
    @kiransoni1658 2 роки тому

    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 ......

  • @SagarikaP-pu2dd
    @SagarikaP-pu2dd Рік тому

    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.

    • @TechBalu
      @TechBalu 8 місяців тому

      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.

  • @7660jk
    @7660jk 3 роки тому

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

    • @codebasics
      @codebasics  3 роки тому +2

      😋 I need to visit malaysia to try these recipes

    • @7660jk
      @7660jk 3 роки тому

      @@codebasics once tasted,you will never leave Malaysia🤭

  • @chilledgamer5585
    @chilledgamer5585 2 роки тому +1

    Wow python is much easier than C and java lolz 😆

  • @mannantareen
    @mannantareen 17 днів тому

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

  • @vishakbhaskar5034
    @vishakbhaskar5034 3 роки тому +1

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

    • @CE-vd2px
      @CE-vd2px 3 роки тому

      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

    • @CE-vd2px
      @CE-vd2px 3 роки тому

      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.

    • @aishwarykulkarni1619
      @aishwarykulkarni1619 3 роки тому

      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.

    • @ravindersingh8863
      @ravindersingh8863 3 роки тому

      it is not working for me as well, did you got the solution @ Vishak Bhaskar

    • @riteshkotian922
      @riteshkotian922 3 роки тому

      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

  • @codebasics
    @codebasics  5 років тому +1

    Learn data science with python and pandas: ua-cam.com/video/CmorAWRsCAw/v-deo.html

  • @anunevethaponravi5555
    @anunevethaponravi5555 4 роки тому

    No one but Hermione Granger: It's "Egg roll", not "Egg role".😁

    • @codebasics
      @codebasics  4 роки тому +2

      Ahh. thanks for correcting :) and sorry my english is not the best but I am trying to improve :)

    • @olakunle5139
      @olakunle5139 3 роки тому

      @@codebasics I think all the knowledge you share on your channel warrants your intellect

  • @codebasics
    @codebasics  4 роки тому +2

    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

    • @shiprapandey7448
      @shiprapandey7448 3 роки тому

      Why you are not using jupyter notebook ??

    • @rashmithakur9
      @rashmithakur9 3 роки тому

      If user enter same dish name in capital letter then this code will give wrong o/p..for that how we write the code

    • @bharishifa6342
      @bharishifa6342 3 роки тому

      this page not found

    • @bhavanasirohi9592
      @bhavanasirohi9592 3 роки тому

      page is not available

    • @nasir7687
      @nasir7687 3 роки тому

      Page is not available :(

  • @puddinfacekiki
    @puddinfacekiki 4 роки тому

    hmmm....Samosas....

  • @Ligress
    @Ligress Рік тому

    py! charm🙃