SlideShare a Scribd company logo
in python Purpose The purpose of this assignment is to give you practice with writing loops and
introduce you to lists. Problem Write a program that receives a series of numbers from the user
and allows the user to press the Enter key to indicate that inputs are done. As each number is
input, it is stored into a list. After the user presses the Enter key (i.e., they enter nothing as input),
the program should do the following: - If the list has no elements, just prints "Empty List". - If
the list has at least one element, you must print: The total number of items in the list The list
itself sorted in ascending order. The sum of all the elements in the lis. The average of the
elements in the list. The largest value in the list. The smallest value in the list. The first half of
the list. (If the list has an odd number of elements, you can exclude the middle element. For
example, if there are 5 elements, just print the first 2 .) Each individual list element. You must
use a loop to iterate through the list to print each element, and each element must be separated by
a tab character (t). Inputs Any input other than a number or the Enter key should be caught using
an exception with an appropriate error message and the program should continue seeking input.
Comments Make sure your code is sufficiently commented! In this casse, you'll want to include
your name and denote where input is collected, where errors are handled, and where the various
list calculations occur. Hint for stopping input An easy way to capture whether the Enter key was
pressed or not is to initially accept the input as a string. and then convert it to integer, all within a
Try block: try: input string = input("Enter a Number.") number = int(input string) If it causes an
exception, in your except clause you can check for cither the value of the input_string variable to
be an empty string (which is two double quotes without anything in it) or the length of the string
being zero (the function len can be used). If it's not an empty string but invalid input (like
nonnumeric input) you must continue to seck input after a proper error message.

More Related Content

DOCX
The purpose of this assignment is to give you practice with writing lo.docx
PDF
numanalysis.py (30 points)A) Write a program that asks user to.pdf
PDF
2. numanalysis.py ( 30 points) A) Write a program that asks user to e.pdf
PDF
This application is used to keep track of inventory information. A c.pdf
PDF
In the rest of this lab, you will help build such a list class. The .pdf
PDF
Please find this solution in C++ An OrderedList is a vector that keeps.pdf
PDF
You are required to open an input file (shown below) then read one c.pdf
PDF
Python workshop
The purpose of this assignment is to give you practice with writing lo.docx
numanalysis.py (30 points)A) Write a program that asks user to.pdf
2. numanalysis.py ( 30 points) A) Write a program that asks user to e.pdf
This application is used to keep track of inventory information. A c.pdf
In the rest of this lab, you will help build such a list class. The .pdf
Please find this solution in C++ An OrderedList is a vector that keeps.pdf
You are required to open an input file (shown below) then read one c.pdf
Python workshop

Similar to in python Purpose The purpose of this assignment is to give you practi.docx (20)

PPTX
Excel Data Management
PDF
Answer should be in MIPS please Please ensure you are follo.pdf
PPTX
Values and Data types in python
PPTX
ADST university of Sussex foundation class
DOCX
Write a complete C programme to implement the following sorting algor.docx
PDF
Instructions Write a program whose main function is merely a.pdf
PPTX
How to use a spreadsheet
PPT
22 Excel Basics
PDF
I am stuck on parts E and FExercise 1      NumberListTester.java.pdf
PDF
Please help. C++ The program is an interactive program th.pdf
PPTX
RANDOMISATION-NUMERICAL METHODS FOR ENGINEERING.pptx
PDF
template ltclass Tgt struct nodeType T data n.pdf
PPTX
Data management( on computer)
PPT
types
PPTX
Learn more about the concepts of Data Types in Python
PPTX
Tuples class 11 notes- important notes for tuple lesson
PPT
basic excels in information communication technology
PPT
22-excel-basics-15511.ppt
PDF
Lab6: I/O and Arrays
PPTX
Data types in python
Excel Data Management
Answer should be in MIPS please Please ensure you are follo.pdf
Values and Data types in python
ADST university of Sussex foundation class
Write a complete C programme to implement the following sorting algor.docx
Instructions Write a program whose main function is merely a.pdf
How to use a spreadsheet
22 Excel Basics
I am stuck on parts E and FExercise 1      NumberListTester.java.pdf
Please help. C++ The program is an interactive program th.pdf
RANDOMISATION-NUMERICAL METHODS FOR ENGINEERING.pptx
template ltclass Tgt struct nodeType T data n.pdf
Data management( on computer)
types
Learn more about the concepts of Data Types in Python
Tuples class 11 notes- important notes for tuple lesson
basic excels in information communication technology
22-excel-basics-15511.ppt
Lab6: I/O and Arrays
Data types in python

More from MichaelQEBMartinc (20)

DOCX
int FUNCTION(unsigned int process_id) -{ task_t processes-MAX_PROCESSE.docx
DOCX
Instructions- Indicate whether each of the following statements is tru (1).docx
DOCX
Instructions- Please answer all questions in FULL sentences- Use APA.docx
DOCX
Instructions Part 1- Compare and contrast the similarities and differe.docx
DOCX
Instructions Assign ICD-10-CM codes after interpreting coding conventi.docx
DOCX
Instructions Amount Hershey needs- $1 billion to build four new manufa.docx
DOCX
Insertion Sort- 7- Copy paste the card images to the empty cells below.docx
DOCX
Input of preparatory reaction (1-2) Output of preparatory reaction (2-.docx
DOCX
Innovative Consulting Co- has the foliowhg accounts in its jodper Cash.docx
DOCX
Information Technology Project Management Which of these types of p.docx
DOCX
Indicate whether the following items can be classified on a statement.docx
DOCX
Indigo Inc- uses a calendar year for financial reporting- The company (1).docx
DOCX
Income statement information for Martincz Tire Repair Corporation for.docx
DOCX
In your initial post- present an area or a country that currently has.docx
DOCX
include calculations Problem 4- Consider the system x1-x13x2x2-x1x2 Is.docx
DOCX
In what areas will oxygen move into the blood- In the lungs None of th.docx
DOCX
In the Stevens Case- the Supreme Court determined that the defendant-.docx
DOCX
In the last few years- many healthcare organizations have had challeng.docx
DOCX
In the plot below- the y-axis represented fractional saturation (Y) an.docx
DOCX
In the histology image shown below- letter A represents the - Select-.docx
int FUNCTION(unsigned int process_id) -{ task_t processes-MAX_PROCESSE.docx
Instructions- Indicate whether each of the following statements is tru (1).docx
Instructions- Please answer all questions in FULL sentences- Use APA.docx
Instructions Part 1- Compare and contrast the similarities and differe.docx
Instructions Assign ICD-10-CM codes after interpreting coding conventi.docx
Instructions Amount Hershey needs- $1 billion to build four new manufa.docx
Insertion Sort- 7- Copy paste the card images to the empty cells below.docx
Input of preparatory reaction (1-2) Output of preparatory reaction (2-.docx
Innovative Consulting Co- has the foliowhg accounts in its jodper Cash.docx
Information Technology Project Management Which of these types of p.docx
Indicate whether the following items can be classified on a statement.docx
Indigo Inc- uses a calendar year for financial reporting- The company (1).docx
Income statement information for Martincz Tire Repair Corporation for.docx
In your initial post- present an area or a country that currently has.docx
include calculations Problem 4- Consider the system x1-x13x2x2-x1x2 Is.docx
In what areas will oxygen move into the blood- In the lungs None of th.docx
In the Stevens Case- the Supreme Court determined that the defendant-.docx
In the last few years- many healthcare organizations have had challeng.docx
In the plot below- the y-axis represented fractional saturation (Y) an.docx
In the histology image shown below- letter A represents the - Select-.docx

Recently uploaded (20)

PDF
Complications of Minimal Access Surgery at WLH
PDF
LNK 2025 (2).pdf MWEHEHEHEHEHEHEHEHEHEHE
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PDF
What if we spent less time fighting change, and more time building what’s rig...
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PPTX
UNIT III MENTAL HEALTH NURSING ASSESSMENT
PDF
1_English_Language_Set_2.pdf probationary
PPTX
A powerpoint presentation on the Revised K-10 Science Shaping Paper
PPTX
UV-Visible spectroscopy..pptx UV-Visible Spectroscopy – Electronic Transition...
PDF
advance database management system book.pdf
PPTX
Lesson notes of climatology university.
PDF
Hazard Identification & Risk Assessment .pdf
DOC
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
PDF
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PDF
Trump Administration's workforce development strategy
PPTX
History, Philosophy and sociology of education (1).pptx
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
Complications of Minimal Access Surgery at WLH
LNK 2025 (2).pdf MWEHEHEHEHEHEHEHEHEHEHE
Supply Chain Operations Speaking Notes -ICLT Program
Final Presentation General Medicine 03-08-2024.pptx
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
What if we spent less time fighting change, and more time building what’s rig...
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
UNIT III MENTAL HEALTH NURSING ASSESSMENT
1_English_Language_Set_2.pdf probationary
A powerpoint presentation on the Revised K-10 Science Shaping Paper
UV-Visible spectroscopy..pptx UV-Visible Spectroscopy – Electronic Transition...
advance database management system book.pdf
Lesson notes of climatology university.
Hazard Identification & Risk Assessment .pdf
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
Chinmaya Tiranga quiz Grand Finale.pdf
Trump Administration's workforce development strategy
History, Philosophy and sociology of education (1).pptx
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS

in python Purpose The purpose of this assignment is to give you practi.docx

  • 1. in python Purpose The purpose of this assignment is to give you practice with writing loops and introduce you to lists. Problem Write a program that receives a series of numbers from the user and allows the user to press the Enter key to indicate that inputs are done. As each number is input, it is stored into a list. After the user presses the Enter key (i.e., they enter nothing as input), the program should do the following: - If the list has no elements, just prints "Empty List". - If the list has at least one element, you must print: The total number of items in the list The list itself sorted in ascending order. The sum of all the elements in the lis. The average of the elements in the list. The largest value in the list. The smallest value in the list. The first half of the list. (If the list has an odd number of elements, you can exclude the middle element. For example, if there are 5 elements, just print the first 2 .) Each individual list element. You must use a loop to iterate through the list to print each element, and each element must be separated by a tab character (t). Inputs Any input other than a number or the Enter key should be caught using an exception with an appropriate error message and the program should continue seeking input. Comments Make sure your code is sufficiently commented! In this casse, you'll want to include your name and denote where input is collected, where errors are handled, and where the various list calculations occur. Hint for stopping input An easy way to capture whether the Enter key was pressed or not is to initially accept the input as a string. and then convert it to integer, all within a Try block: try: input string = input("Enter a Number.") number = int(input string) If it causes an exception, in your except clause you can check for cither the value of the input_string variable to be an empty string (which is two double quotes without anything in it) or the length of the string being zero (the function len can be used). If it's not an empty string but invalid input (like nonnumeric input) you must continue to seck input after a proper error message.