• 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 for everybody - ex 5.2

For the following problem: 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. Input Cases: Enter 7, 2, bob, 10, and 4 and match the output below.

My program is not correctly showing the ans. What is problem here?

Output: Invalid input, Maximum is 10, Minimum is 2.

Output of the program

  • Suggestion: don't test only with the given sequence of inputs. Try a variety of test cases. For example, try entering only "done", try entering only one number, try entering only an invalid input, try entering numbers that only increase or decrease. When a test fails, fix the script for that case and then test some more. –  Dennis Sparrow Commented Jun 10, 2020 at 3:11
  • 1 Your indentation is off, everything in the while loop should be indented from the while True statement –  Sam Commented Jun 10, 2020 at 3:48
  • Looks to me like Maximum is 10, Minimum is 2 is correct, for 7, 2, bob, 10, 4. No? –  Sam Commented Jun 10, 2020 at 3:50
  • given output section is only the expected output. but my given input does not showup like that. –  user3404895 Commented Jun 10, 2020 at 3:55

10 Answers 10

You are missing out few statements while printing the output. The following code worked for me.

Have verified and runs successfully.

Harshit Ruwali's user avatar

  • Your answer is good, but code-only answers are discouraged. Please edit it to include an explanation. –  Sylvester is on codidact.com Commented Jan 1, 2022 at 21:58

Try this code and thank me later

Harrison Ofordu's user avatar

If you include elif statements, they won't be checked if the condition in the if statement is true, so if I had "elif smallest..." it would never be checked giving 'Minimus is none' as a result.

Y.B's user avatar

This is the only thing I could work out. Couldn't figure out how to keep largest and smallest at the value of none

lepsch's user avatar

Fellow coders; most of the above-provided codes are right. The problem is the browser. I used chrome and got a mismatch. I then run the same code using Microsoft edge and finally received "Grade updated on server." So use a different browser. thank me later.

wizzy's user avatar

  • Your answer could be improved with additional supporting information. Please edit to add further details about your code. –  CreepyRaccoon Commented May 4, 2023 at 11:44

Niqua's user avatar

  • I’m having trouble understanding your question, what exactly are you trying to ask? –  surftijmen Commented Dec 27, 2021 at 8:54

Your Answer

Reminder: Answers generated by artificial intelligence tools are not allowed on Stack Overflow. Learn more

Sign up or log in

Post as a guest.

Required, but never shown

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy .

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

  • Featured on Meta
  • Upcoming initiatives on Stack Overflow and across the Stack Exchange network...
  • Announcing a change to the data-dump process

Hot Network Questions

  • Is every Boolean algebra a subalgebra of a free one?
  • Securing Transactional Email: User Input Escaping for a email subject
  • What programming language was used in Dijkstra's response to Frank Rubin's article about "Go To Statement Considered Harmful"
  • Find 𝛼 in the triangle below.
  • When solving eigenvalues, what does the factor in front of the Root[] mean?
  • What's the frequency level of 時々?
  • The vertiginous question: Why am I me and not someone else?
  • Make both colors connected
  • Why "praemiīs mē dōnant" and not "praemia mihi donant"?
  • Relationship between Pythagorean Triples and double/half angles
  • Has any US president ever endorsed Trump for US presidency?
  • Is the text of speeches by foreign leaders (given to the US Congress) entered into the Congressional Record?
  • Swale puddles/floods before driveway - looking for solution
  • Can modern civilization maintain itself under an Earth constantly bombarded with lightning?
  • Was there an Easter egg in the Electrologica X1 QUINIO (GO-MOKU) game?
  • How to estimate temperature based on known points in a map?
  • Binomial coefficient with stix2
  • How can I prevent my fountain's water from turning green?
  • Number of leaves in complete binary tree
  • English equivalent for the idiom "mother-in-law has forgotten to wear her saree (dress)"
  • With SHA-1 broken, can the old Linux /dev/(u)random algorithm be trusted?
  • bootstrapping a confidence interval with unbalanced data
  • Camera & Negatives identification
  • What are the safe assumptions I can make when installing a wall oven without model/serial?

assignment 2 3 python for everybody

Python for Everybody

  • Coursera: Python for Everybody Specialization
  • edX: Python for Everybody
  • FutureLearn: Programming for Everybody (Getting Started with Python)
  • FreeCodeCamp
  • Free certificates for University of Michigan students and staff

If you log in to this site you have joined a free, global open and online course. You have a grade book, autograded assignments, discussion forums, and can earn badges for your efforts.

We take your privacy seriously on this site, you can review our Privacy Policy for more details.

If you want to use these materials in your own classes you can download or link to the artifacts on this site, export the course material as an IMS Common Cartridge®, or apply for an IMS Learning Tools Interoperability® (LTI®) key and secret to launch the autograders from your LMS.

The code for this site including the autograders, slides, and course content is all available on GitHub . That means you could make your own copy of the course site, publish it and remix it any way you like. Even more exciting, you could translate the entire site (course) into your own language and publish it. I have provided some instructions on how to translate this course in my GitHub repository.

And yes, Dr. Chuck actually has a race car - it is called the SakaiCar . He races in a series called 24 Hours of Lemons .

Instantly share code, notes, and snippets.

@jennyonjourney

jennyonjourney / 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 ( 11 ) 11 You must be signed in to star a gist
  • Fork ( 5 ) 5 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 jennyonjourney/c032a1f4e25d4d03e4601b3536f77f92 to your computer and use it in GitHub Desktop.
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

SmaranikaBiswas commented Sep 25, 2021

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.

Sorry, something went wrong.

@KhaledE21

KhaledE21 commented Nov 14, 2021

image

mdshamimchowdhury commented Jan 19, 2022

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

initiatorvaibhav commented Feb 21, 2022

# 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

rovesoul commented Feb 21, 2022 via email

@Abi-London

Abi-London commented Mar 21, 2022

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 commented Mar 21, 2022 via email

@chenchen218

chenchen218 commented May 10, 2022

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 commented May 10, 2022 via email

@WitherspoonD

WitherspoonD commented Oct 16, 2022

The code checker is case sensitive.

rovesoul commented Oct 16, 2022 via email

@techfresher

techfresher commented Nov 23, 2022

Capture online assignment

please help out

rovesoul commented Nov 23, 2022 via email

Rovesoul commented jan 9, 2023 via email.

@mohamednazeih

mohamednazeih commented Jan 16, 2023

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

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

@amw514

amw514 commented Apr 3, 2023

Rovesoul commented apr 3, 2023 via email.

@iqtidarali

iqtidarali commented Apr 17, 2023

image

work for me hope for you guys as well

rovesoul commented Apr 17, 2023 via email

@anitasoaares

anitasoaares commented May 29, 2023 • edited Loading

image

rovesoul commented May 29, 2023 via email

@Irajam

Irajam commented Aug 27, 2023

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 commented Aug 27, 2023 via email

 alt=

mike-official commented Sep 14, 2023

Rovesoul commented sep 14, 2023 via email.

@tadeletekeba13

tadeletekeba13 commented Oct 14, 2023

"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

rovesoul commented Oct 14, 2023 via email

Rovesoul commented oct 30, 2023 via email.

@HyugasV

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")

assignment 2 3 python for everybody

Assignment 2.2 | Week-4 | Programming for Everybody (Getting Started with Python) By Coursera

Assignment 2.2 | Week-4 | Programming for Everybody (Getting Started with Python) By Coursera

Coursera Programming for Everybody (Getting Started with Python) Week 4  Assignment 2.2 

 Question:  2.2  Write a program that uses  input  to prompt a user for their name and then welcomes them. Note that  input  will pop up a dialog box. Enter  Sarah  in the pop-up box when you are prompted so your output will match the desired output.

assignment 2 3 python for everybody

Do Not Only Use These Quizzes For Getting Certificates.You Can Take Help From These Quizzes Answer. All Quizzes & Contents Are Free Of Charge. ✅ If You Want Any Quiz Answers Then Please  Contact Us

Related Questions & Answers:

Leave a comment cancel reply, please enable javascript in your browser to visit this site..

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

Python for Everybody 3.3 assignment

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

Programmer named Tim

Jan-08-2019, 12:14 AM (This post was last modified: Jan-08-2019, 12:14 AM by .)






Involuntary Spiderweb Collector
Jan-08-2019, 12:18 AM statement. Right now, everything is on the next line. In Python, a plain string is a legal line, and print by itself just prints a newline, so your code is legal although it doesn't do what I suspect you want it to. likes this post
Silly Frenchman

Jan-08-2019, 07:48 AM
Programmer named Tim

Jan-08-2019, 09:14 PM ramadan2099 Wrote: Is there a code error?
What do you need to get output?








Did you mean that?
Involuntary Spiderweb Collector
Jan-08-2019, 11:40 PM If you're using Python 3, then you'll need parenthesis as well as the quotes. The code block I've provided will work for Python 2 but will be a syntax error in Python 3, though you should be able to correct it easily.
Programmer named Tim

Jan-09-2019, 09:10 PM micseydel Wrote: I didn't mention parenthesis. I said they should be on the same line, more like this:
If you're using Python 3, then you'll need parenthesis as well as the quotes. The code block I've provided will work for Python 2 but will be a syntax error in Python 3, though you should be able to correct it easily.
thanks well done
Unladen Swallow
Apr-08-2020, 06:19 AM
So-and-so of the Yard

Apr-08-2020, 06:49 AM
All humans together. We don't need politicians!
  175,440 Jul-25-2023, 04:15 PM
:
  46,398 Jan-23-2021, 06:27 AM
:
  13,433 Oct-22-2020, 11:57 AM
:
  12,316 Jul-15-2020, 04:54 PM
:
  5,318 Jun-06-2020, 08:59 AM
:
  6,427 May-02-2020, 01:34 AM
:
  8,761 Dec-23-2019, 08:41 PM
:
  8,746 Oct-22-2019, 08:08 AM
:
  16,197 Jan-17-2019, 07:34 AM
:
  • View a Printable Version

User Panel Messages

Announcements.

assignment 2 3 python for everybody

Login to Python Forum

IMAGES

  1. Coursera Assignment 2.3 Solved Python for Everybody

    assignment 2 3 python for everybody

  2. Assignment 2.3

    assignment 2 3 python for everybody

  3. Python for Everybody Answers

    assignment 2 3 python for everybody

  4. Assignment 2.3

    assignment 2 3 python for everybody

  5. "Python for Everybody" Chapter 3

    assignment 2 3 python for everybody

  6. Programming for Everybody (Getting Started with Python)

    assignment 2 3 python for everybody

VIDEO

  1. Coursera: 8.4 Assignment// python data structures assignment 8.4 solution

  2. "Python for Everybody" Chapter 11

  3. NPTEL The Joy of Computing using Python Week2 Quiz Assignment Solutions

  4. 2.5. Operators in Python

  5. Py4e Assignment 5.2

  6. Coursera Assignment 2.3 Solved Python for Everybody

COMMENTS

  1. python-for-everybody/wk2

    Automate any workflow. Packages. Host and manage packages. Security. Find and fix vulnerabilities. Codespaces. Instant dev environments. GitHub Copilot. Write better code with AI.

  2. Assignment 2.3

    CourseraProgramming for Everybody (Getting Started with Python)Week 4 Assignment 2.3 Question: 2.3 Write a program to prompt the user for hours and rate per hour using input to compute gross pay. Use 35 hours and a rate of 2.75 per hour to test the program (the pay should be 96.25). You should…

  3. Coursera Python for Everybody EP-6

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

  4. Coursera: Assignment 2.3 Python For Everybody

    Coursera: Programming For Everybody Assignment 2.3 program solution Answer | Python for Everybody Assignment 2.3 program solution.Hello friends, In this vide...

  5. GitHub

    If the file ends with _p2, this means that the file runs on Python 2. If the file ends with _p3, this means that the file runs on Python 3. I tried to create two versions. However, you can easily modify the syntax accordingly. Mostly it's due to the print syntax.

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

  7. Coursera

    Try a variety of test cases. For example, try entering only "done", try entering only one number, try entering only an invalid input, try entering numbers that only increase or decrease. When a test fails, fix the script for that case and then test some more. Looks to me like Maximum is 10, Minimum is 2 is correct, for 7, 2, bob, 10, 4.

  8. Answer of Assignment 2.3

    Answer of assignment 2.3 for everybody like a piece of cake.if you have every question about this program and this assignment of python for everybody course,...

  9. Python for Everyone

    Exercise 28. At Quizlet, we're giving you the tools you need to take on any subject without having to carry around solutions manuals or printing out PDFs! Now, with expert-verified solutions from Python for Everyone 2nd Edition, you'll learn how to solve your toughest homework problems. Our resource for Python for Everyone includes answers ...

  10. PY4E

    Python for Everybody. This web site is building a set of free materials, lectures, book and assignments to help students learn how to program in Python. You can take this course and receive a certificate at: Coursera: Python for Everybody Specialization; edX: Python for Everybody; FreeCodeCamp

  11. Assignment solutions for python for everybody

    Python 100.0%. Assignment solutions for python for everybody. Contribute to sweehors/python-for-everybody development by creating an account on GitHub.

  12. Assignment 2.2 Python for Everybody

    January 25, 2021 at 2:03 AM. Assignment 2.2 Python for Everybody. 2.2 Write a program that uses input to prompt a user for their name and then welcomes them. Note that input will pop up a dialog box. Enter Sarah in the pop-up box when you are prompted so your output will match the desired output. Desired output: Hello Sarah. Original sample code:

  13. [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 ...

  14. Python For Everybody Assignment 3.2 program solution

    Coursera: Python For Everybody Assignment 3.2 program solution | Assignment 3.2 Python For EverybodyCode link: https://drive.google.com/file/d/1zBODlCGxzdWBr...

  15. 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 4 - Assignment 2.2 at master · Ritik2703/Coursera---Programming-for-Everybody-Getting-Started-with-Python-

  16. Assignment 3.3

    The above questions are from " Programming for Everybody (Getting Started with Python) " You can discover all the refreshed questions and answers related to this on the " Programming for Everybody (Getting Started with Python) By Coursera " page. If you find the updated questions or answers, do comment on this page and let us know. We will update the answers as soon as possible.

  17. Assignment 2.2

    CourseraProgramming for Everybody (Getting Started with Python)Week 4 Assignment 2.2 Question: 2.2 Write a program that uses input to prompt a user for their name and then welcomes them. Note that input will pop up a dialog box. Enter Sarah in the pop-up box when you are prompted so your output will match the desired output. Input: # The code below…

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

  19. Python for Everybody 3.3 assignment

    The official dedicated python forum. You need to put what you're printing on the same line as the print statement. Right now, everything is on the next line. In Python, a plain string is a legal line, and print by itself just prints a newline, so your code is legal although it doesn't do what I suspect you want it to.

  20. python-for-everybody/wk7

    7.2 Write a program that prompts for a file name, then opens that file and reads through the file, looking for lines of the form: X-DSPAM-Confidence: 0.8475 Count these lines and extract the floating point values from each of the lines and compute the average

  21. python-for-everybody/wk3

    wk3 - assignment 3.1.py. 3.1 Write a program to prompt the user for hours and rate per hour using raw_input to compute gross pay. Pay the hourly rate for the hours up to 40 and 1.5 times the hourly rate for all hours worked above 40 hours. Use 45 hours and a rate of 10.50 per hour to test the program (the pay should be 498.75).