Skip to content

Instantly share code, notes, and snippets.

  • Save jennyonjourney/c032a1f4e25d4d03e4601b3536f77f92 to your computer and use it in GitHub Desktop.
Save jennyonjourney/c032a1f4e25d4d03e4601b3536f77f92 to your computer and use it in GitHub Desktop.
[Coursera] Python for everybody 5.2 Assignment
largest = None
smallest = None
while True:
inp = raw_input("Enter a number: ")
if inp == "done" : break
try:
num = float(inp)
except:
print ("Invalid input")
continue
if smallest is None:
smallest = num
if num > largest :
largest = num
elif num < smallest :
smallest = num
def done(largest,smallest):
print ("Maximum is", int(largest))
print ("Minimum is", int(smallest))
done(largest,smallest)
@SmaranikaBiswas
Copy link

largest = None
smallest = None
num = 0
while True:
    num = input("Enter a number: ")
    if num == "done" : 
        break
    try:
        numb = int(num)
    except:
        print ("Invalid input")
        continue
    if smallest is None:
        smallest = numb 
    elif numb < smallest :
        smallest = numb
    if largest is None:
        largest = numb
    elif numb > largest:
        largest = numb
print ("Maximum is", largest)  
print ("Minimum is", smallest)

This is a correct code. It's absolutely run and match the output.

@KhaledE21
Copy link

image

@mdshamimchowdhury
Copy link

Now you Must Try This one

num = 0
largest = -1
smallest = None
while True:
num = input("Enter a number: ")
if num == "done" :
break
try :
numb = int(num)
except :
print('Invalid input')
if smallest is None :
smallest = numb
elif numb < smallest :
smallest = numb
elif numb > largest :
largest = numb
print("Maximum is", largest)
print("Minimum is", smallest)

Now you should try to enter output: 7 then 2 then bob then 10 then 4 then done

@initiatorvaibhav
Copy link

#newer update

largest = None
smallest = None
while True:
inp = input("Enter a number: ")
if inp == "done": break
try:
num = float(inp)
except:
print("Invalid input")
continue
if smallest is None:
smallest = num
largest = num
if num < smallest:
smallest = num
elif num > largest:
largest = num
print("Maximum is", int(largest))
print("Minimum is", int(smallest))

@rovesoul
Copy link

rovesoul commented Feb 21, 2022 via email

@Abi-London
Copy link

largest = None
smallest = None
while True:
num = input("Enter a number: ")
if num == "done":
break
try:
numb=int(num)
except:
print('Invalid input')
continue
if largest is None:
largest=numb
elif largest<numb:
largest=numb
if smallest is None:
smallest=numb
elif numb<smallest:
smallest=numb
print("Maximum", largest)
print("Minimum", smallest)

@rovesoul
Copy link

rovesoul commented Mar 21, 2022 via email

@chenchen218
Copy link

my code for this practice:

large = None
small = None

while True:
num = input('please enter a vallue<<')
try:
if num == 'done':
print('program finished')
break
number = int(num)
except:
print('please enter a numeric value')
if small is None or small > number:
small = number
if large is None or large < number:
large = number

print('MAX NUM: ',large, 'MIN NUM:',small)

@rovesoul
Copy link

rovesoul commented May 10, 2022 via email

@WitherspoonD
Copy link

The code checker is case sensitive.

@rovesoul
Copy link

rovesoul commented Oct 16, 2022 via email

@techfresher
Copy link

Capture online assignment

please help out

@rovesoul
Copy link

rovesoul commented Nov 23, 2022 via email

@rovesoul
Copy link

rovesoul commented Jan 9, 2023 via email

@mohamednazeih
Copy link

largest = None
smallest = None
while True:
num = input("Enter a number: ")

if num == "done":
    break

try:
  num = int(num)
  if largest is None or largest < num:
      largest = num
  if smallest is None or smallest > num:
      smallest = num

except:
  print('Invalid input')
  continue

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

@amw514
Copy link

amw514 commented Apr 3, 2023

largest = None
smallest = None
while True:
    num = input("Enter a number: ")
    if num == "done":
        break
    try:
        fnum = float(num)
        if smallest == None or fnum < smallest:
            smallest = num
        if largest is None or fnum > largest:
            largest = num
    except:
        print("Invalid input")
        continue
    
            
print("Maximum is", largest)
print("Minimum is", smallest)

@rovesoul
Copy link

rovesoul commented Apr 3, 2023 via email

@iqtidarali
Copy link

image

work for me hope for you guys as well

@rovesoul
Copy link

rovesoul commented Apr 17, 2023 via email

@anitasoaares
Copy link

anitasoaares commented May 29, 2023

image
can pls someone help me, i have been trying a lot of different things and this mismatch is always appearing. I dont know what i am doing wrong. I have tried without the quit() but is the same thing.

@rovesoul
Copy link

rovesoul commented May 29, 2023 via email

@Irajam
Copy link

Irajam commented Aug 27, 2023

image can pls someone help me, i have been trying a lot of different things and this mismatch is always appearing. I dont know what i am doing wrong. I have tried without the quit() but is the same thing.

did you find any solution for this? i have same issue, i tried several codes but not working

@rovesoul
Copy link

rovesoul commented Aug 27, 2023 via email

@Irajam
Copy link

Irajam commented Aug 27, 2023

image

work for me hope for you guys as well

i did the exactly same but i have an error
Uploading Screenshot 2023-08-27 at 15.05.51.png…

@mike-official
Copy link

largest = None
smallest = None
num = 0
while True:
    num = input("Enter a number: ")
    if num == "done" : 
        break
    try:
        numb = int(num)
    except:
        print ("Invalid input")
        continue
    if smallest is None:
        smallest = numb 
    elif numb < smallest :
        smallest = numb
    if largest is None:
        largest = numb
    elif numb > largest:
        largest = numb
print ("Maximum is", largest)  
print ("Minimum is", smallest)

This is a correct code. It's absolutely run and match the output.

@rovesoul
Copy link

rovesoul commented Sep 14, 2023 via email

@tadeletekeba13
Copy link

"Hello, everyone. Could you kindly assist me with this exercise?

I am encountering difficulties, and nothing seems to be effective.

largest = None
smallest = None

while True :
num = input ('Enter a number :')
if num=='done':
break
#elif num =='Done':
#break
try :
fnum = float (num )
except:
print ('Invaild input')
continue
if largest in None:
largest = fnum
elif fnum > largest:
largest = fnum
#print (fnum)
if smallest is None :
smallest =fnum
#print (fnum)
Print ('Maximum is', int(largest))
Print ('Minimum is' , int(smallest)) IS NOT WORKIG

Exercise 5 2 is no
Exercise 5 2 not working
Exercise 5 2

@rovesoul
Copy link

rovesoul commented Oct 14, 2023 via email

@rovesoul
Copy link

rovesoul commented Oct 30, 2023 via email

@HyugasV
Copy link

HyugasV commented Oct 30, 2023

Guys my code is like that and it's working is it true ?

numlist = []
while True:
num = input("Enter a number: ")
if num == "done":
break
try:
num = int(num)
(numlist.append(num))
largest = max(numlist)
smallest = min(numlist)
except:
print("Invalid input")

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment