PY4E - Conditionals (Chapter 3 Part 2)

www.py4e.com - Python for Everybody: Exploring Data
Please visit the web site to access a free textbook, free supporting materials, as well as interactive exercises. You can see my entire online curriculum at online.dr-chuck.com

Пікірлер: 32

  • @mostafa5512
    @mostafa55125 жыл бұрын

    And I love your course and thinks very highly of it and I could never repay you fro such free education.

  • @verdell2x246
    @verdell2x2462 жыл бұрын

    Thank you so much!! I watch all of your stuff. Your personality and teaching skills are top notch

  • @gkai0
    @gkai02 жыл бұрын

    You are really my savior. I love the way you explain things. Thank you so much!

  • @mridulagrawal2370
    @mridulagrawal23702 жыл бұрын

    Just to ensure the person enters an integer. x=1 while x==1 : try: car=int(input("Enter an integer: ")) x+=1 except: print("That was not an integer, please try again") continue print("That was an integer, thanks!")

  • @raquelb7955
    @raquelb79556 жыл бұрын

    Thank you, Chuck!!

  • @Chamchijjige
    @Chamchijjige Жыл бұрын

    Thank you very much.

  • @trino01
    @trino01 Жыл бұрын

    realmente se nota su pasión por la docencia! Excelente.

  • @user-rr7hs6ex2r
    @user-rr7hs6ex2r6 жыл бұрын

    Thanks for your work, it helps.

  • @Taratouille.
    @Taratouille. Жыл бұрын

    Best of all time . ❤ thank you sir

  • @soniasmelodiousland
    @soniasmelodiousland2 жыл бұрын

    Wish I could hv studied in ur University. Great teacher

  • @ravisandhu1111
    @ravisandhu11113 жыл бұрын

    Chuck’s a good guy

  • @mridulagrawal2370
    @mridulagrawal23702 жыл бұрын

    Thanks chuck

  • @mostafa5512
    @mostafa55125 жыл бұрын

    Minor note: I think it should be if ival >= 0 not if ival >0 otherwise if you run this code and enter 0, it will give you "Not a number"

  • @mahorinav

    @mahorinav

    4 жыл бұрын

    x = input('Enter a number: ') try: x=int(x) if x >= 0: print('Nice work') elif x print('Nice work') except: print('Not a number') print('Thank you.')

  • @FacundoTupac

    @FacundoTupac

    4 жыл бұрын

    @@mahorinav Exactly, otherwise negatives would also fail

  • @soniasmelodiousland
    @soniasmelodiousland2 жыл бұрын

    Thank you so much

  • @jackharisson5598
    @jackharisson55982 жыл бұрын

    11:34 is bad example ... couse , for example -45 is also a number, but in Charles example it will be - "not a number" 😀 So I present my right example to you guys😊 By the way I am from Ukraine💛💙! PUTIN HUILO! rafs = input('type something: ') try: num = int(rafs) except ValueError: num = str(rafs) if type(num) == int: print('you enter a number ') elif type(num) == str: print('you enter a letters ')

  • @tis_i_sana

    @tis_i_sana

    2 жыл бұрын

    Thanks for this! 💛💙

  • @eliashobeika2657

    @eliashobeika2657

    9 ай бұрын

    Late reply here, you're right, but 2 things for newcomers like me: 1- num is already a string after input(), so u can just write pass in line 5 instead of str() 2- What does ValueError do here in line 4? Just write except.

  • @androranogajec5029

    @androranogajec5029

    4 ай бұрын

    bro, your attitude is so childish like, it's obvious that his examples aren't a mathematical indentity, so just go and grow on yourself and stop acting stupid, very please.

  • @ravisandhu1111
    @ravisandhu11113 жыл бұрын

    Thank you

  • @jawadhussain9349
    @jawadhussain93495 жыл бұрын

    val= input("Please enter a number ") try: num = int(val) if (num > 0 ): print("Nice Work, Value is grater than 0 ") elif (num print("Nice Work, Value is less than 0") elif (num == 0 ): print("Number is equal to zero") except: num="It was not a number" print(num) print("All done")

  • @Sinan97082

    @Sinan97082

    3 жыл бұрын

    :) try & except is the part where I am actually am :))

  • @jaydenchesslife

    @jaydenchesslife

    2 жыл бұрын

    @@Sinan97082 Same man!

  • @purushothamreddy.j5613
    @purushothamreddy.j56133 жыл бұрын

    @9:01th minute in try block istr= int( aste) blows up?

  • @tis_i_sana

    @tis_i_sana

    2 жыл бұрын

    Yes because you can't convert a words to an integer!

  • @FkSeditiousChristofascists
    @FkSeditiousChristofascists4 ай бұрын

    at 12:40 the example isn't quite right. Unless you don't consider zero a number-- which I suppose IS up for debate... THANKS FOR ALL THIS!!!

  • @trenholmelodge1820
    @trenholmelodge1820 Жыл бұрын

    cannot read the colours.

  • @totoro013
    @totoro0134 жыл бұрын

    You are very sweet guy, I love you~

  • @thomaspivaf
    @thomaspivaf4 жыл бұрын

    Hello professor Chuck. I ran the try/except sample and it blew up rawstr = input('Enter a number:') try: ival = int(rawstr) except: ival = -1 if ival > 1: print('Nice work') else: print('Not a number') The Error: Enter a number:w Traceback (most recent call last): File "tryexcept.py", line 1, in rawstr = input('Enter a number:') File "", line 1, in NameError: name 'w' is not defined Can you help me to understand where I failed? Thank you, so far I loving the classes!

  • @succumbtothebutter1972

    @succumbtothebutter1972

    4 жыл бұрын

    Did you figure out what the issue was? I copy-pasted your code to test it and it worked fine, even when I inputted non-numbers.

  • @thomaspivaf

    @thomaspivaf

    4 жыл бұрын

    @@succumbtothebutter1972 , i haven't. Now i copy pasted the code and it worked fine. Who knows. But thank you for the help!