• Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers
  • Advertising & Talent Reach devs & technologists worldwide about your product, service or employer brand
  • OverflowAI GenAI features for Teams
  • OverflowAPI Train & fine-tune LLMs
  • Labs The future of collective knowledge sharing
  • About the company Visit the blog

Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Get early access and see previews of new features.

Coursera Python: Programming for everybody assignment 5.2

I have been taking Coursera's course, Programming for Everybody with Python. But one of the assignment 5.2 on week 7 got my attention.

The objective is to make the user enter some numbers and enter done, when he entered all the numbers he wanted. After that, the output should be the biggest number and smallest number he entered.

Here is the problem. If I enter a negative number it is not displayed. Let's say I enter: 32, 55,10, -2 76. The output should be 76 and -2. But what really happens is that 76 and 10 are printed out.

Do you guys have any idea why this happens?

Here is the code.

  • variable-assignment

J.Felipe's user avatar

  • 2 What do you think range(-2) does? –  José Sánchez Commented Dec 28, 2016 at 12:33
  • 1 Why are you even looping over a range? –  TigerhawkT3 Commented Dec 28, 2016 at 12:38

3 Answers 3

Well,the issue is that why are you iterating over an int if it isnt a list? You can rather do it with out a loop:

Taufiq Rahman's user avatar

  • The continue isn't necessary, as the only other code in that loop is the elif block which already won't run if the if executes. –  TigerhawkT3 Commented Dec 28, 2016 at 12:55
  • True,didnt see that. –  Taufiq Rahman Commented Dec 28, 2016 at 12:57

Well, this was my answer. Try this. Let me know what you don't understand.

Ihfaz666's user avatar

  • 2 Welcome to SO. While this code snippet may be the solution, including an explanation really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code suggestion. Please check how-to-answer for more details. –  alan.elkin Commented Jun 13, 2020 at 20:58

This code will work for your assignment

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

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

MohaMmed MQ's user avatar

Not the answer you're looking for? Browse other questions tagged python numbers variable-assignment or ask your own question .

  • The Overflow Blog
  • Scaling systems to manage all the metadata ABOUT the data
  • Navigating cities of code with Norris Numbers
  • Featured on Meta
  • We've made changes to our Terms of Service & Privacy Policy - July 2024
  • Bringing clarity to status tag usage on meta sites
  • Tag hover experiment wrap-up and next steps

Hot Network Questions

  • Union of lists with original order
  • A study on the speed of gravity
  • Why is Excel not counting time with COUNTIF?
  • How do Christians determine which messianic prophecies are to be fulfilled by the 'Second Coming'?
  • Writing a Puzzle Book: Enigmatic Puzzles
  • Why didn't Walter White choose to work at Gray Matter instead of becoming a drug lord in Breaking Bad?
  • Does the US Congress have to authorize non-combat deployments (e.g. of advisers and trainers) from the US armed forces to a foreign country?
  • Would several years of appointment as a lecturer hurt you when you decide to go for a tenure-track position later on?
  • Can a Statute of Limitations claim be rejected by the court?
  • What's the polarity of this electrolytic capacitor symbol?
  • can a CPU once removed retain information that poses a security concern?
  • Is Apex Trigger considers two updates on different records from two users into a single transaction?
  • What is the soteriological significance of Hebrews 10:1 in the context of God's Redemption Plan?
  • Why are these simple equations so slow to `Solve`?
  • What are those bars in subway train or bus called?
  • Word to classify what powers a god is associated with?
  • Can two different points can be connected by multiple adiabatic curves?
  • When is internal use internal (considering licenses and their obligations)?
  • A burning devil shape rises into the sky like a sun
  • Whats the source of saying Al Cheit at night?
  • What is a word/phrase that best describes a "blatant disregard or neglect" for something, but with the connotation of that they should have known?
  • Shift right by half a trit
  • Can someone help me identify this plant?
  • Would it be possible for humans to be alive to witness the beginning of a runaway greenhouse effect on Earth?

python for everybody coursera assignment 5.2

Instantly share code, notes, and snippets.

@initiatorvaibhav

initiatorvaibhav / 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,

  • Download ZIP
  • Star ( 0 ) 0 You must be signed in to star a gist
  • Fork ( 0 ) 0 You must be signed in to fork a gist
  • Embed Embed this gist in your website.
  • Share Copy sharable link for this gist.
  • Clone via HTTPS Clone using the web URL.
  • Learn more about clone URLs
  • Save initiatorvaibhav/3758f116f237ef60e9c5ca4e8b18f788 to your computer and use it in GitHub Desktop.
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))

@initiatorvaibhav

initiatorvaibhav commented Feb 21, 2022

newer update

Sorry, something went wrong.

Python Forum

  • View Active Threads
  • View Today's Posts
  • View New Posts
  • My Discussions
  • Unanswered Posts
  • Unread Posts
  • Active Threads
  • Mark all forums read
  • Member List
  • Interpreter

Coursera python for everybody 5.2 assignment

  • Python Forum
  • Python Coding
  • 0 Vote(s) - 0 Average

Unladen Swallow
Aug-30-2020, 05:10 AM (This post was last modified: Aug-30-2020, 05:11 AM by .)

Aug-30-2020, 05:38 AM
Unladen Swallow
Aug-30-2020, 05:51 AM

Aug-30-2020, 06:09 AM (This post was last modified: Aug-30-2020, 06:10 AM by .) File "paillasse/tmp/badinput.py", line 7 largest = i ^ IndentationError: expected an indented blockIt tells me that line 7 has a bad indentation. You need to add more space at the beginning of the line. It must not be aligned with the 'if' of the previous line.
Unladen Swallow
Sep-02-2020, 08:06 AM

Sep-02-2020, 11:35 AM

Sep-02-2020, 12:59 PM (This post was last modified: Sep-02-2020, 01:00 PM by .) SteppentigerV2 Wrote: I was using that py4e.com playgoundDos in not print the whole ?
I guess is dos,if it do not then is useless. SteppentigerV2 Wrote: Does visual studio do it?All editor should give show that Traceback output,and very few in the Python world use Visual Studio.
A lot use which is not the same as Visual Studio.
Is VS Code if a Linter if turned on give a Warning before running the code.
Here a example how this look,the linter i use here is .

Unladen Swallow
Oct-21-2020, 06:33 PM
Da Bishop

Oct-21-2020, 08:07 PM
Unladen Swallow
Oct-22-2020, 04:54 AM
  175,827 Jul-25-2023, 04:15 PM
:
  46,565 Jan-23-2021, 06:27 AM
:
  12,398 Jul-15-2020, 04:54 PM
:
  5,383 Jun-06-2020, 08:59 AM
:
  6,487 May-02-2020, 01:34 AM
:
  32,255 Apr-08-2020, 06:49 AM
:
  8,834 Dec-23-2019, 08:41 PM
:
  8,834 Oct-22-2019, 08:08 AM
:
  16,265 Jan-17-2019, 07:34 AM
:
  3,452 Feb-08-2018, 05:18 AM
:
  • View a Printable Version

User Panel Messages

Announcements.

python for everybody coursera assignment 5.2

Login to Python Forum

Get the Reddit app

Subreddit for posting questions and asking for general advice about your python code.

An issue with Assignment 5.2 [Coursera Programming for Everybody]

Even if my code matches desired output, it shows the code is incorrect. I spent all day trying to fix the issue but failed. Could anyone please help me fix the issue?

Screenshot: https://prnt.sc/1fs2vr8

By continuing, you agree to our User Agreement and acknowledge that you understand the Privacy Policy .

Enter the 6-digit code from your authenticator app

You’ve set up two-factor authentication for this account.

Enter a 6-digit backup code

Create your username and password.

Reddit is anonymous, so your username is what you’ll go by here. Choose wisely—because once you get a name, you can’t change it.

Reset your password

Enter your email address or username and we’ll send you a link to reset your password

Check your inbox

An email with a link to reset your password was sent to the email address associated with your account

Choose a Reddit account to continue

IMAGES

  1. Coursera

    python for everybody coursera assignment 5.2

  2. Coursera: Python For Everybody Assignment 5.2 program solution

    python for everybody coursera assignment 5.2

  3. Coursera: Programming For Everybody Assignment 5.2 program solution

    python for everybody coursera assignment 5.2

  4. [Coursera] Python for everybody 5.2 Assignment · GitHub

    python for everybody coursera assignment 5.2

  5. [Coursera] Python for everybody 5.2 Assignment · GitHub

    python for everybody coursera assignment 5.2

  6. Coursera Python for Everybody EP-13

    python for everybody coursera assignment 5.2

VIDEO

  1. Coursera: Python For Everybody Complete Course Assignments Solution |Python For Everybody Assignment

  2. Coursera: Programming for Everybody (Getting Started with Python) Complete Course solved Live

  3. Coursera: Python For Everybody Assignment 5.2 program solution

  4. Python for Everybody

  5. Python for every body|

  6. Python for Everybody

COMMENTS

  1. [Coursera] Python for everybody 5.2 Assignment · GitHub

    Fork 5 5. [Coursera] Python for everybody 5.2 Assignment. Raw. 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 ...

  2. Coursera Python: Programming for everybody assignment 5.2

    I have been taking Coursera's course, Programming for Everybody with Python. But one of the assignment 5.2 on week 7 got my attention. The objective is to make the user enter some numbers and enter done, when he entered all the numbers he wanted. After that, the output should be the biggest number and smallest number he entered. Here is the ...

  3. Coursera Python for Everybody EP-13

    Hi guys, in this video I solved the assignment 5.2 of Coursera Python for Everybody. Hope you find it useful.If you're new, Subscribe! https://www.youtube....

  4. Coursera---Programming-for-Everybody-Getting-Started-with-Python-/Week

    this contains all the answers to the quizes and asssignments for "Programming for Everybody (Getting Started with Python)" on Coursera by the University of Michigan. - Coursera---Programming-for-Everybody-Getting-Started-with-Python-/Week 7- Assignment 5.2 at master · Ritik2703/Coursera---Programming-for-Everybody-Getting-Started-with-Python-

  5. GitHub

    This contains all the practices for the lectures, custom answers to the assignments and additional inline notes for "Python for Everybody Specialization" on Coursera by the University of Michigan. 42 stars 55 forks Branches Tags Activity

  6. python-for-everybody/wk5

    wk5 - assignment 5.2.py. Cannot retrieve latest commit at this time. 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 ...

  7. [Coursera] Python for everybody 5.2 Assignment · GitHub

    [Coursera] Python for everybody 5.2 Assignment. GitHub Gist: instantly share code, notes, and snippets.

  8. Ritik2703/Coursera---Programming-for-Everybody-Getting-Started-with-Python-

    this contains all the answers to the quizes and asssignments for "Programming for Everybody (Getting Started with Python)" on Coursera by the University of Michigan. - Ritik2703/Coursera---Programming-for-Everybody-Getting-Started-with-Python-

  9. Python for Everybody Answers

    The video is about the solution of the mentioned assignment of the python course named 'PYTHON FOR EVERYBODY' on coursera by Dr. Chuck

  10. Coursera: Python For Everybody Assignment 5.2 program solution

    Coursera: Programming For Everybody Assignment 5.2 program solution Answer | Python for Everybody Assignment 5.2 program solution.IF YOUR PROGRAM IS WORKING...

  11. Help with the assignment 5.2 in Python for everybody

    Community Support (Archived) — Edward Lundqvist asked a question. March 8, 2021 at 6:45 AM. Help with the assignment 5.2 in Python for everybody. I need help with the assignment 5.2 in Python for everybody. Somebody that could help me?

  12. Assignment 5.2

    CourseraProgramming for Everybody (Getting Started with Python)Week 5 Assignment 5.2 Question: 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…

  13. sersavn/coursera-python-for-everybody-specialization

    Current repository contains all assignments, notes, quizzes and course materials from the "Python for Everybody Specialization" provided by Coursera and University of Michigan. - sersavn/coursera-python-for-everybody-specialization

  14. Coursera Python Assignment 5.2 : r/learnpython

    The assignment is. 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.

  15. Coursera Programming for Everybody (Getting Started with Python) Week 7

    Coursera Programming for Everybody (Getting Started with Python) Week 7 Assignment 5.2 . Ques: 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 ...

  16. Python for Everybody 5.2 assignment

    Joined: Oct 2017. Reputation: 1. #1. Oct-07-2017, 03:58 PM. 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.

  17. [Coursera] Python for everybody 5.2 Assignment · GitHub

    Raw. 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.

  18. Coursera python for everybody 5.2 assignment

    This is the requirement 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.

  19. Programming for Everybody (Getting Started with Python)

    There are 7 modules in this course. This course aims to teach everyone the basics of programming computers using Python. We cover the basics of how one constructs a program from a series of simple instructions in Python. The course has no pre-requisites and avoids all but the simplest mathematics. Anyone with moderate computer experience should ...

  20. EngineerInd/Coursera-Python-for-everybody-solutions

    Hello friends, In this video we discussed about Coursera programming for everybody Assignment 5.2 answer other way it's known as Python for everybody Exercise 5.2 Complete program In this course Assignment (Exercise) are available in week 7 part.

  21. An issue with Assignment 5.2 [Coursera Programming for Everybody]

    An issue with Assignment 5.2 [Coursera Programming for Everybody] Even if my code matches desired output, it shows the code is incorrect. I spent all day trying to fix the issue but failed. Could anyone please help me fix the issue? Screenshot: https://prnt.sc/1fs2vr8. Also, as an aside, run your program with one number then "done." Even if my ...