Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 [split] Python for Everybody 5.2 assignment
largest = None
smallest = None
while True:
    num = input("Enter a number: ")
    if num == "done":
        fnum = float(num)
        print("Invalid input")
    if largest is None :
    	largest = float(num)
    elif num > largest :
        largest = float(num)
    if smallest is None :
        smallest = float(num)
    elif num < smallest :
    	smallest = float(num)
print("Maximum is",int(largest))
print("Minimum is",int(smallest))
Can someone help point to where I have gone wrong with the logic please? Thanks!
micseydel wrote Jun-14-2019, 09:01 PM:
Please post all code, output and errors (in it's entirety) between their respective tags. I did it for you this time, Here are instructions on how to do it yourself next time.

Also, I split your post from someone else's thread. Please don't hijack others' threads, create your own (you don't need to create a new thread for this question).
Can you be more specific? What inputs are you using? How exactly is the behavior different from what you want?
(Jun-14-2019, 04:38 PM)jonchanzw Wrote: elif num > largest :

num is a string. largest is a float. You have an fnum variable available, why not use that for comparisons?

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  assignment help sammmy 4 192 Jun-11-2019, 06:17 PM
Last Post: micseydel
  Write pseudo code for a class assignment Scrimshot 3 243 May-07-2019, 05:38 PM
Last Post: Scrimshot
  Need help with my assignment please - game of Solitaire Muzz 2 289 Apr-09-2019, 03:48 PM
Last Post: Muzz
  [split] University Assignment Help needed Nomathemba 2 167 Apr-07-2019, 11:49 PM
Last Post: micseydel
  Powerball assignment, how to get correct output of a dictionary ? msp1981 5 236 Mar-19-2019, 11:02 PM
Last Post: Yoriz
  Help with homework assignment grayarea3 1 312 Feb-20-2019, 10:10 PM
Last Post: ichabod801
  Help with assignment dxfrelince 7 453 Feb-18-2019, 09:16 PM
Last Post: dxfrelince
  Need help with a tough school assignment datson79 5 337 Feb-18-2019, 06:01 PM
Last Post: ichabod801
  Need some help with a bit of code for an assignment. JackMercer50 1 219 Feb-09-2019, 04:13 PM
Last Post: stullis
  Help with arrays assignment hyg71886 15 656 Jan-30-2019, 09:36 AM
Last Post: perfringo

Forum Jump:

Users browsing this thread: 1 Guest(s)