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 4.6 python for everybody

def computepay(h,r):<br/> if h > 40:<br/> pa = 40 * r + (h-40)*1.5*r<br/> else:<br/> pa = h * r<br/> return pa<br/><br/>hrs = input("Enter Hours:")<br/>h = float(hrs)<br/>rate = input("Enter Rate")<br/>r = float(rate)<br/>p = computepay(h,r)<br/><br/>print("Pay",p)

Welcome Back!

  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings

Create a Free Account

Mark the violation.

IMAGES

  1. Coursera : python for everybody assignment 4.6 solution

    python for everybody coursera assignment 4 6

  2. Coursera: Python For Everybody Assignment 4.6 program solution

    python for everybody coursera assignment 4 6

  3. Python For Everybody Assignment 4.6 program solution

    python for everybody coursera assignment 4 6

  4. Coursera Python for everybody Assignments 4.6 and 5.2

    python for everybody coursera assignment 4 6

  5. GitHub

    python for everybody coursera assignment 4 6

  6. Programming for everybody (getting started with python) week 6 chapter

    python for everybody coursera assignment 4 6

VIDEO

  1. Python For Everybody Honors Recognition Assignment 2

  2. Print the Score

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

  4. "Python for Everybody" Chapter 3

  5. Programming for Everybody Getting Started with Python Coursera complete Assignment Solution #DCG

  6. Coursera Programming for Everybody Getting Started with Python chapter 1 week3 graded external tool

COMMENTS

  1. python-for-everybody/wk4

    wk4 - assignment 4.6.py. Cannot retrieve latest commit at this time. History. Code. Blame. 17 lines (13 loc) · 897 Bytes. 4.6 Write a program to prompt the user for hours and rate per hour using raw_input to compute gross pay. Award time-and-a-half for the hourly rate for all hours worked above 40 hours. Put the logic to do the computation of ...

  2. Week 6- Assignment 4.6

    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 6- Assignment 4.6 at master · Ritik2703/Coursera---Programming-for-Everybody-Getting-Started-with-Python-

  3. Assignment 4.6

    CourseraProgramming for Everybody (Getting Started with Python)Week 6 Assignment 4.6 Question: 4.6 Write a program to prompt the user for hours and rate per hour using input to compute gross pay. Pay should be the normal rate for hours up to 40 and time-and-a-half for the hourly rate for all hours worked above…

  4. Coursera Python for Everybody EP-11

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

  5. Python for everybody

    The second pay should be beneath se of the else: and lastly return pay should be in alignment with else: so it should be if hours, else: and return pay aligned correctly and the same for pay by using the space bar in your pc. There two spaces after lines:6 and 10. Python for everybody - Assignment 4.6. GitHub Gist: instantly share code, notes ...

  6. Python_For_Everybody_Coursera/Exercise_4.6.py at main

    I did the Course by myself on coursera. I faced many challenges and went through all of them. So just a help from my side of providing exercise solutions for the ones starting with this course! - d...

  7. Python For Everybody Assignment 4.6 program solution

    Coursera: Python For Everybody Assignment 4.6 program solution | Assignment 4.6 Python For EverybodyQ.) 4.6 Write a program to prompt the user for hours and ...

  8. Coursera : python for everybody assignment 4.6 solution

    Program :hrs = input("Enter hours")rat = input("Enter rates")h = float(hrs)r = float(rat)additionalhours = h - 40a = float(additionalhours)def computepay(h, ...

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

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

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

  12. Coursera: Python For Everybody Assignment 4.6 program solution

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

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

    The answers are entirely created by me. They are not the same as the suggested ones. However, they produce the same results and are roughly similar. Moreover, there are inline notes to help you to understand each step. I created python files on the go when I watched the lectures to document every ...

  15. Programming for Everybody (Getting Started with Python ...

    This course will cover Chapters 1-5 of the textbook "Python for Everybody". Once a student completes this course, they will be ready to take more advanced programming courses. ... Assignment 4.6 ... it's so much more than that. Coursera allows me to learn without limits." Learner reviews. Showing 3 of 228203. 4.8. 228,203 reviews. 5 stars ...

  16. Python-for-Everybody-Coursera/Programming for Everybody/Chapter 4

    Coursera courses for the Python for Everybody Specialization. - atse0612/Python-for-Everybody-Coursera

  17. Programming for Everybody (Getting Started with Python ...

    This course will cover Chapters 1-5 of the textbook "Python for Everybody". Once a student completes this course, they will be ready to take more advanced programming courses. ... Assignment 4.6 ... Join over 3,400 global companies that choose Coursera for Business. Upskill your employees to excel in the digital economy. Learn more. Enroll ...

  18. assignment 4.6 python for everybody

    assignment 4.6 python for everybody coursera python for everybody assignment 4.6 python for everybody chapter 4 assignment python for everybody coursera assignment 4.6 python for everybody coursera assignment 4.6 python 3. Code examples. 178055. Follow us on our social networks. IQCode. About us Press Blog.

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

  20. Python for Everybody Specialization [5 courses] (UMich)

    Specialization - 5 course series. This Specialization builds on the success of the Python for Everybody course and will introduce fundamental programming concepts including data structures, networked application program interfaces, and databases, using the Python programming language. In the Capstone Project, you'll use the technologies ...

  21. python-for-everybody/wk6

    Cannot retrieve latest commit at this time. #6.5 Write code using find () and string slicing (see section 6.10) to extract the number at the end of the line below. #Convert the extracted value to a floating point number and print it out. text = "X-DSPAM-Confidence: 0.8475" start = text.find ('0') result =float (text [start : ]) print (result ...