Coursera Python for Everybody EP-13 | Assignment 5.2 Solution (Week 7) | Shoeb Solves

preview_player
Показать описание
Hi guys, in this video I solved the assignment 5.2 of Coursera Python for Everybody. Hope you find it useful.

"Coursera Python for Everybody" Playlist:

#shoebsolves #Coursera_Python_for_Everybody #Assignment5_2_Solution
Рекомендации по теме
Комментарии
Автор

largest = None
smallest = None
while True:
num = input("Enter a number: ")
if num == "done" :
break
try:
n=int (num)
if largest is None:
largest=n
elif largest<n:
largest =n

if smallest is None:
smallest=n
elif smallest>n:
smallest=n

except:
print("Invalid input")
continue

print("Maximum is", largest)
print ("Minimum is", smallest)

gauravsingh
Автор

Thanks a lot. Most helpful video ever seen. Your explanation was very clear and understandable.

서와어
Автор

wow, I way over complicated my solution. this was very succinct. nice

SomeStuff
Автор

Thank you for the solution. Can you explain further how these lines produce the smallest value and vice versa? I don't really understand.

if smallest = None:
smallest = n
elif smallest > n:
smallest = n

suhailayunus
Автор

I am getting a syntax error bad input in line 5, help 🆘

AfricanRenaissancetv.
Автор

I'm confused how the equalities here work like why did we use largest < n and smallest > n ?

sakina
Автор

This is really amazing, how he is simplifying every bit

murtadhaaltai
Автор

I'm having a hard time understanding the flow of the iterations. How is n assigned to the input values given in the problem (7, 2, bob, 10, 4)? I.e., how does the flow of the iteration work with these values in order to calculate the min and max? Thank you.

cesarnunez
Автор

Hey, it's printing out the maximum and minimum as soon as I enter it never waiting for done. what's up with that?

markespinoza
Автор

Can you say what's the actual purpose of try and except functions..?

mohammednasrudheenk
Автор

Sir, it is showing an error in line 19 can anyone help me out?

anishhushuare
Автор

Why cant you just use zero instead of None. I used zero and it worked fine. When i used None, i got an error saying floats cant be compared to None values.

markkennedy
Автор

Hello can you help me with the 5.2
Mine is not going through 😢

ahmedabracadabra
Автор

"Break is outside loop " This is the error iam getting

rohanrajpasupunoori
Автор

Invalid Input ← Mismatch Invalid Input Maximum is 10 Minimum is 2
Why???

kimjeong
Автор

Invalid input Invalid input ← Mismatch Invalid input Invalid input Invalid input Maximum is None Minimum is None

youthbanglamahima
Автор

it's showing Continue outside loop ... Please help

zakiah
Автор

Hello code is not working plzz helppp meee

pratikmandilwar
Автор

largest = None
smallest = None
while True:
num = input(*Enter a number : *)
if num == *done* :
break
try :
n=int (num)
if largest is None :
largest =n
elif largest <n :
largest =n
if smallest is None :
smallest =n
elif smallest >n :
smallest =n
except :
print (*Invalid input*)
continue

mine saying error in line 4, what can be the error, can you guide

somiaashraf
Автор

largest = None
smallest = None
while True:
num = input("Enter a number: ")
if num == "done" :
break
try :
n = int(num)

if largest is None :
largest = n
elif largest < n :
largest = n

if smallest is None :
smallest = n
elif smallest > n :
smallest = n
except :
print("Invalid input")
continue

print("Maximum is ", largest)
print("Minimum is ", smallest)

that program have been executed well but i have a problem in output :
Invalid input
Maximum is 10 ← Mismatch
#why ?
Minimum is 2

eminberkeaydn