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.

assignment 5 2 python for everybody

  • Table of Contents
  • Course Home
  • Assignments
  • Peer Instruction (Instructor)
  • Peer Instruction (Student)
  • Change Course
  • Instructor's Page
  • Progress Page
  • Edit Profile
  • Change Password
  • Scratch ActiveCode
  • Scratch Activecode
  • Instructors Guide
  • About Runestone
  • Report A Problem
  • Function and String Mixed-Up Code Questions
  • Peer Instruction: Functions Multiple Choice Questions
  • Functions and Lists Mixed-Up Code Questions
  • Mixed-up Code Questions
  • Functions with Tuples and Dictionaries Mixed-Up Code Questions
  • Functions and Loops Mixed-Up Code Questions
  • Please join a research study to help us test new approaches to learning programming!
  • Functions Mixed-Up Code Questions
  • Practice Problems
  • An Introduction To Our System
  • Self-efficacy Post-Survey
  • Functions and Conditionals Mixed-Up Code Questions
  • Peer Instruction: Function Multiple Choice Questions
  • 5.1 Function calls
  • 5.2 Built-in functions
  • 5.3 Type conversion functions
  • 5.4 Math functions
  • 5.5 Random numbers
  • 5.6 Adding new functions
  • 5.7 Definitions and uses
  • 5.8 Flow of execution
  • 5.9 Parameters and arguments
  • 5.10 Fruitful functions and void functions
  • 5.11 Why functions?
  • 5.12 Debugging
  • 5.13 Glossary
  • 5.14 Multiple Choice Questions
  • 5.15 Mixed-up Code Questions
  • 5.16 Write Code Questions
  • 5.17 Group Work: Functions
  • 5.18 Functions Multiple Choice Questions
  • 5.19 Functions Mixed-Up Code Questions
  • 5.20 Functions Write Code Questions
  • 5.21 Group Work: Functions and Strings
  • 5.22 Functions and Strings Multiple Choice Questions
  • 5.23 Functions and Strings Mixed-Up Code Questions
  • 5.24 Functions and Strings Write Code Questions
  • 5.25 Group Work: Functions and Conditionals
  • 5.26 Functions and Conditionals Multiple Choice Questions
  • 5.27 Functions and Conditionals Mixed-Up Code Questions
  • 5.28 Functions and Conditionals Write Code Questions
  • 5.29 Group Work: Functions and Lists
  • 5.30 Functions with Lists Multiple Choice Questions
  • 5.31 Functions and Lists Mixed-Up Code Questions
  • 5.32 Functions and Lists Write Code Questions
  • 5.33 Group Work: Functions with Loops
  • 5.34 Functions with Loops Multiple Choice Questions
  • 5.35 Functions and Loops Mixed-Up Code Questions
  • 5.36 Functions and Loops Write Code Questions
  • 5.37 Group Work: Functions with Tuples and Dictionaries
  • 5.38 Functions with Tuples and Dictionaries Multiple Choice Questions
  • 5.39 Functions with Tuples and Dictionaries Mixed-Up Code Questions
  • 5.40 Functions with Tuples and Dictionaries Write Code Questions
  • 5.41 Group Work: Functions, Strings, and Conditionals
  • 5.42 Group Work: Functions with Lists and Loops
  • 5.1. Function calls" data-toggle="tooltip">
  • 5.3. Type conversion functions' data-toggle="tooltip" >

5.2. Built-in functions ¶

Python provides a number of important built-in functions that we can use without needing to provide the function definition. The creators of Python wrote a set of functions to solve common problems and included them in Python for us to use.

The max and min functions give us the largest and smallest values in a list, respectively:

The max function gives us the value 4 because it is the largest value in the list. The min function, inversely, give us the value -2 because it is the smallest value in the list.

Q-2: What will be printed as the output of this code?

  • Incorrect! You cannot use the max function to compare different data types. Try again.
  • There is an error
  • Correct! This code causes a TypeError because the max function cannot be used to compare different data types.

Another very common built-in function is the len function, which tells us how many items are in its argument. If the argument to len is a string, it returns the number of characters in the string.

These functions can operate on any set of values, as we will see in later chapters.

You should treat the names of built-in functions as reserved words (i.e., avoid using “max” as a variable name).

Activity: CodeLens 5.2.4 (functBuiltin_codelens_line2)

Q-5: Consider the code block below. What prints?

  • Incorrect! Spaces and punctuation characters count in the length. Try again.
  • Incorrect! Punctuation characters count in the length. Try again.
  • Incorrect! Spaces count in the length. Try again.
  • Correct! 13 is the length of all characters in the string, including spaces and punctuation.

Q-6: Which of the following would work as a variable name?

  • Incorrect! This is a reserved keyword because it is a built-in function in Python. Try again.
  • Correct! built_in is a valid variable name because it is not a built-in Python function.

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
  174,757 Jul-25-2023, 04:15 PM
:
  46,016 Jan-23-2021, 06:27 AM
:
  12,225 Jul-15-2020, 04:54 PM
:
  5,174 Jun-06-2020, 08:59 AM
:
  6,339 May-02-2020, 01:34 AM
:
  32,012 Apr-08-2020, 06:49 AM
:
  8,669 Dec-23-2019, 08:41 PM
:
  8,670 Oct-22-2019, 08:08 AM
:
  16,109 Jan-17-2019, 07:34 AM
:
  3,343 Feb-08-2018, 05:18 AM
:
  • View a Printable Version

User Panel Messages

Announcements.

assignment 5 2 python for everybody

Login to Python Forum

  • Stack Overflow Public questions & answers
  • Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers
  • Talent Build your employer brand
  • Advertising Reach developers & technologists worldwide
  • Labs The future of collective knowledge sharing
  • About the company

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.

Not sure what is wrong with this code for Python for Everybody 5.2

I'm taking Coursera and doing a python course. I'm struggling with the last assignment.

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

Please help. Thanks

Neil's user avatar

  • What is your question? Right now all you've said is that you wrote some code. What precisely is it that doesn't work about your code which you need help with? –  Max von Hippel Commented Jul 18, 2018 at 4:50
  • 1 If the problem is, that it stops running after entering one number: Your indentation is wrong, everything after while True: and before largest = max(store) needs to be indented, but I guess that could be from pasting it into Stackoverflow as well. –  Bernhard Commented Jul 18, 2018 at 4:53
  • The output of the assignment is supposed to be Invalid input Maximum is 10 Minimum is 2 I get the same output but it still says that it's wrong. It says "Maximum is 10 ← Mismatch" –  Neil Commented Jul 18, 2018 at 4:54
  • make sure to give 4 space indentation it is probably the indentation mistake –  Syed Khizaruddin Commented Jul 18, 2018 at 5:36

Arashsyh's user avatar

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 or ask your own question .

  • Featured on Meta
  • Upcoming sign-up experiments related to tags
  • The return of Staging Ground to Stack Overflow
  • Policy: Generative AI (e.g., ChatGPT) is banned

Hot Network Questions

  • Is there a name for books in which the narrator isn't the protagonist but someone who know them well?
  • Passkeys: MFA or not?
  • Why is "Colourless green ideas sleep furiously" considered meaningless?
  • What was the first modern chess piece?
  • What was Jessica and the Bene Gesserit's game plan if Paul failed the test?
  • Why don't they put more spare gyroscopes in expensive space telescopes?
  • Why does 2N2222 allow battery current flow when separate 5V circuit unpowered, but 2N3904 doesn't?
  • e{ } and e( ) Notation
  • Rule of Thumb meaning in statistics
  • Why does the declension of "duo" (two) look like the first/second declension in nominative, genitive and accusative, but like the third otherwise?
  • Meaning of "virō" in description of Lavinia
  • UTF-8 characters in POSIX shell script *comments* - anything against it?
  • Using only ceramic capacitors on an input of an SMPS - unclear advice from manufacturer
  • What happens if you don't appear for jury duty for legitimate reasons in the state of California?
  • Why do trombones often play differently?
  • What aspects define how present the garlic taste in an aglio e olio pasta becomes?
  • What is this flying boat I just saw fly over?
  • Am I wasting my time self-studying program pre-requisites?
  • Create 3D Cylinder in ArcGIS Pro
  • What will happen if we keep bringing two protons closer and closer to each other, starting from a large distance?
  • Finding the real roots of an octic polynomial (degree eight).
  • Finding a mystery number from a sum and product, with a twist
  • Find 10 float64s that give the least accurate sum
  • Issue with building a version of Blender 4.1.1 (GooEngine)

assignment 5 2 python for everybody

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

assignment 5 2 python for everybody

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.

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.

Save my name, email, and website in this browser for the next time I comment.

Please Enable JavaScript in your Browser to Visit this Site.

IMAGES

  1. exercise 5. 2 python programming 4 everybody

    assignment 5 2 python for everybody

  2. Python for Everybody 5.2 assignment

    assignment 5 2 python for everybody

  3. Coursera

    assignment 5 2 python for everybody

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

    assignment 5 2 python for everybody

  5. Coursera: Python For Everybody Assignment 5.2 program solution

    assignment 5 2 python for everybody

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

    assignment 5 2 python for everybody

VIDEO

  1. PYTHON PROGRAMMING I UNIT- II ONE SHOT I Python Program Flow Control Conditional blocks

  2. "Python for Everybody" Chapter 11

  3. Python For Everybody Assignment 8.5

  4. Python for Informatics

  5. Python Data Structures Assignment 10.2 Solution [Coursera]

  6. Python Week 5 Graded Assignment(IITM)

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

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

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

  6. Week 7- Assignment 5.2

    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-

  7. 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. Topics. html json sqlite python3 beautifulsoup urllib Resources. Readme Activity. Stars. 143 stars Watchers. 11 watching Forks. 80 forks

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

  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. Help with the assignment 5.2 in Python for everybody

    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?

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

  12. Coursera Python Assignment 5.2 : r/learnpython

    Hi there, I'm doing the last assignment for the Programming for Everybody (Getting Started with Python) course on Coursera, and I'm not quite understanding the solution. 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 ...

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

    Last active 2 years ago. [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 ...

  14. 5.2. Built-in functions

    Activity: 5.2.3 The len function tells us how many items are in its argument. (functBuiltin_len) These functions can operate on any set of values, as we will see in later chapters. You should treat the names of built-in functions as reserved words (i.e., avoid using "max" as a variable name). 1. city_name = "Detroit".

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

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

  17. Coursera python for everybody 5.2 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.

  18. Not sure what is wrong with this code for Python for Everybody 5.2

    I'm taking Coursera and doing a python course. I'm struggling with the last assignment. Here 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.

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

    Subreddit for posting questions and asking for general advice about your python code. Members Online • akalama. ADMIN MOD 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. ... This sub is for discussing ...

  20. 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…