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
And I love your course and thinks very highly of it and I could never repay you fro such free education.
Thank you so much!! I watch all of your stuff. Your personality and teaching skills are top notch
You are really my savior. I love the way you explain things. Thank you so much!
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!")
Thank you, Chuck!!
Thank you very much.
realmente se nota su pasión por la docencia! Excelente.
Thanks for your work, it helps.
Best of all time . ❤ thank you sir
Wish I could hv studied in ur University. Great teacher
Chuck’s a good guy
Thanks chuck
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
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
4 жыл бұрын
@@mahorinav Exactly, otherwise negatives would also fail
Thank you so much
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
2 жыл бұрын
Thanks for this! 💛💙
@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
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.
Thank you
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
3 жыл бұрын
:) try & except is the part where I am actually am :))
@jaydenchesslife
2 жыл бұрын
@@Sinan97082 Same man!
@9:01th minute in try block istr= int( aste) blows up?
@tis_i_sana
2 жыл бұрын
Yes because you can't convert a words to an integer!
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!!!
cannot read the colours.
You are very sweet guy, I love you~
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
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
4 жыл бұрын
@@succumbtothebutter1972 , i haven't. Now i copy pasted the code and it worked fine. Who knows. But thank you for the help!