Python Forum
Python for Everybody 5.2 assignment
Thread Rating:
  • 2 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python for Everybody 5.2 assignment
#11
if smallest is None:
smallest = num
elif num < smallest:
smallest = num

if largest is None:
largest=num
elif num > largest:
largest = num

then it works.
Reply
#12
(Oct-07-2017, 04:56 PM)Lux Wrote: Well, the line print(num) seems to be why it's printing all the numbers- not sure if it's supposed to do that.
Reply
#13
(Apr-16-2020, 12:05 PM)caseyfloyd6 Wrote: Removed spam content
Is this supposed to help with the question? Huh It is interesting, but how about you post it as a thread in the News and Discussions bar? Smile
pyzyx3qwerty
"The greatest glory in living lies not in never falling, but in rising every time we fall." - Nelson Mandela
Need help on the forum? Visit help @ python forum
For learning more and more about python, visit Python docs
Reply
#14
(Apr-07-2020, 05:37 AM)vis1999 Wrote: please, solve my problem, when i put the term in output block(7,2,bob,10,2)again it ask enter a num and not show the result
Bro plss help me for 3.3 assignment
Reply
#15
(Oct-07-2017, 03:58 PM)baba04201 Wrote: Hey guys- I'm on my last assignment for Python and I need some expert assistance please.

This is the assignment:
5.2 Write a program that repeatedly prompts a user for integer numbers until the user enters 'done'. Once 'done' is entered, print out the largest and smallest of the numbers. If the user enters anything other than a valid number catch it with a try/except and put out an appropriate message and ignore the number. Enter 7, 2, bob, 10, and 4 and match the output below.

This is my code:

largest = None
smallest = None
while True:
    try:
        num = raw_input("Enter a number: ")
        if num == "done":
            break
        print (num)
        num = int(num)
        if largest is None or largest < num:
            largest = num
        elif smallest is None or smallest > num:
             smallest = num
    except ValueError:
        print("Please, enter only numbers.")

print ("Maximum", largest)
print ("Minimum", smallest)
This is the Desired output:
Invalid input
Maximum is 10
Minimum is 2


This is my output:
7 ← Mismatch
2
bob
Please, enter only numbers.
10
4
Maximum 10
Minimum 2


I need help please. Wall

# check out this code

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

continue

print ("Maximum is", largest)
print ("Minimum is", smallest)
Reply
#16
Quote:check out this code

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

continue

print ("Maximum is", largest)
print ("Minimum is", smallest)
First of all, this is the HOMEWORK SECTION, you aren't SUPPOSED TO WRITE CODE FOR OTHERS.
And, second, even if you write code, please use proper code tags
pyzyx3qwerty
"The greatest glory in living lies not in never falling, but in rising every time we fall." - Nelson Mandela
Need help on the forum? Visit help @ python forum
For learning more and more about python, visit Python docs
Reply
#17
(Oct-07-2017, 03:58 PM)baba04201 Wrote: Hey guys- I'm on my last assignment for Python and I need some expert assistance please.

This is the assignment:
5.2 Write a program that repeatedly prompts a user for integer numbers until the user enters 'done'. Once 'done' is entered, print out the largest and smallest of the numbers. If the user enters anything other than a valid number catch it with a try/except and put out an appropriate message and ignore the number. Enter 7, 2, bob, 10, and 4 and match the output below.

This is my code:

largest = None
smallest = None
while True:
    try:
        num = raw_input("Enter a number: ")
        if num == "done":
            break
        print (num)
        num = int(num)
        if largest is None or largest < num:
            largest = num
        elif smallest is None or smallest > num:
             smallest = num
    except ValueError:
        print("Please, enter only numbers.")

print ("Maximum", largest)
print ("Minimum", smallest)
This is the Desired output:
Invalid input
Maximum is 10
Minimum is 2


This is my output:
7 ← Mismatch
2
bob
Please, enter only numbers.
10
4
Maximum 10
Minimum 2


I need help please. Wall





TRY THIS CODE:
largest = None
smallest = None
while True:
try:
num = input("Enter a number: ")
if num == "done":
break
num = int(num)
if largest is None or largest < num:
largest = num
elif smallest is None or smallest > num:
smallest = num
except ValueError:
print("Invalid input")
continue

print ("Maximum is", largest)
print ("Minimum is", smallest)
Reply
#18
(Apr-07-2020, 05:37 AM)vis1999 Wrote: please, solve my problem, when i put the term in output block(7,2,bob,10,2)again it ask enter a num and not show the result
To ask another question, start a new thread , DON'T POST IN ANOTHER THREAD WRITTEN BY ANOTHER USER
(Apr-07-2020, 07:10 AM)gracePython3 Wrote: if smallest is None:
smallest = num
elif num < smallest:
smallest = num

if largest is None:
largest=num
elif num > largest:
largest = num

then it works.
Please don't post you solution, this is the homework section. And also, if you post codes in future, please use proper code tags
(Apr-18-2020, 04:40 AM)Saikumar Wrote:
(Apr-07-2020, 05:37 AM)vis1999 Wrote: please, solve my problem, when i put the term in output block(7,2,bob,10,2)again it ask enter a num and not show the result
Bro plss help me for 3.3 assignment
You need help in an assignment, post another thread, specifying all needs and requirements

(Apr-25-2020, 04:04 PM)Helious10 Wrote:
(Oct-07-2017, 03:58 PM)baba04201 Wrote: Hey guys- I'm on my last assignment for Python and I need some expert assistance please.

This is the assignment:
5.2 Write a program that repeatedly prompts a user for integer numbers until the user enters 'done'. Once 'done' is entered, print out the largest and smallest of the numbers. If the user enters anything other than a valid number catch it with a try/except and put out an appropriate message and ignore the number. Enter 7, 2, bob, 10, and 4 and match the output below.

This is my code:

largest = None
smallest = None
while True:
    try:
        num = raw_input("Enter a number: ")
        if num == "done":
            break
        print (num)
        num = int(num)
        if largest is None or largest < num:
            largest = num
        elif smallest is None or smallest > num:
             smallest = num
    except ValueError:
        print("Please, enter only numbers.")

print ("Maximum", largest)
print ("Minimum", smallest)
This is the Desired output:
Invalid input
Maximum is 10
Minimum is 2


This is my output:
7 ← Mismatch
2
bob
Please, enter only numbers.
10
4
Maximum 10
Minimum 2


I need help please. Wall





TRY THIS CODE:
largest = None
smallest = None
while True:
try:
num = input("Enter a number: ")
if num == "done":
break
num = int(num)
if largest is None or largest < num:
largest = num
elif smallest is None or smallest > num:
smallest = num
except ValueError:
print("Invalid input")
continue

print ("Maximum is", largest)
print ("Minimum is", smallest)
Please don't post you solution, this is the homework section. And also, if you post codes in future, please use proper code tags
(May-30-2020, 09:29 PM)sanjaykumar11 Wrote: I have upload python assignment 5.2 full solution in the video

https://www.youtube.com/watch?v=8bfPhZAJyto
https://www.youtube.com/watch?v=8bfPhZAJyto
Please, start another thread for this. It would also be preferred if you didn't show this, as students need to solve assignments on their own
pyzyx3qwerty
"The greatest glory in living lies not in never falling, but in rising every time we fall." - Nelson Mandela
Need help on the forum? Visit help @ python forum
For learning more and more about python, visit Python docs
Reply
#19
Photo 
hello cheakout man

Tongue
numList = []
while True:
        try:
            num = input("Enter a number: ")
            if num == 'done':
              break
            n = int(num)
            if n != 'done':
                Value = n
                numList.append(Value)
                smallest = min(numList)
                largest = max(numList)
        except:
            print("Invalid input")
            continue

print("Maximum is", largest)
print("Minimum is", smallest)
[Image: 85965237-947d3080-b9ab-11ea-875e-cf6ad8b3b227.png]
Reply
#20
(Jun-29-2020, 02:02 AM)rafaelmoreno1 Wrote: hello cheakout man

Tongue
numList = []
while True:
        try:
            num = input("Enter a number: ")
            if num == 'done':
              break
            n = int(num)
            if n != 'done':
                Value = n
                numList.append(Value)
                smallest = min(numList)
                largest = max(numList)
        except:
            print("Invalid input")
            continue

print("Maximum is", largest)
print("Minimum is", smallest)
[Image: 85965237-947d3080-b9ab-11ea-875e-cf6ad8b3b227.png]

That's very good, but please don't post unnecessary stuff on a thread when a person is asking a question. If you want to show this, post it probably in the board/bar section.
pyzyx3qwerty
"The greatest glory in living lies not in never falling, but in rising every time we fall." - Nelson Mandela
Need help on the forum? Visit help @ python forum
For learning more and more about python, visit Python docs
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python for Everybody 3.1 assignment ramadan2099 18 45,372 Jan-23-2021, 06:27 AM
Last Post: KonohaHokage
  Coursera python for everybody 5.2 assignment SteppentigerV2 11 12,810 Oct-22-2020, 11:57 AM
Last Post: Larz60+
  [split] Python for Everybody 5.2 assignment ramadan2099 3 12,036 Jul-15-2020, 04:54 PM
Last Post: Bipasha
  Python Assignment 3 - Applied Data Science - 2.3 eyavuz21 8 4,941 Jun-06-2020, 08:59 AM
Last Post: eyavuz21
  Python Password Saver Assignment sshellzr21 2 6,145 May-02-2020, 01:34 AM
Last Post: sshellzr21
  Python for Everybody 3.3 assignment ramadan2099 7 31,727 Apr-08-2020, 06:49 AM
Last Post: DeaD_EyE
  Python for everyone course assignment 5.2 ofekx 3 8,525 Dec-23-2019, 08:41 PM
Last Post: nilamo
  [split] Python for Everybody 5.2 assignment jonchanzw 4 8,453 Oct-22-2019, 08:08 AM
Last Post: perfringo
  Python Assignment 5.2 amos76823 3 15,961 Jan-17-2019, 07:34 AM
Last Post: perfringo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020