SlideShare a Scribd company logo
1 of 1
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 list. 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 (V).
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 case, 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 either 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 seek input after a proper error message.

More Related Content

Similar to The purpose of this assignment is to give you practice with writing lo.docx

Please help. C++ The program is an interactive program th.pdf
Please help. C++ The program is an interactive program th.pdfPlease help. C++ The program is an interactive program th.pdf
Please help. C++ The program is an interactive program th.pdf
fsenterprises
 
Data management( on computer)
Data management( on computer)Data management( on computer)
Data management( on computer)
elvieantony
 
Please find this solution in C++ An OrderedList is a vector that keeps.pdf
Please find this solution in C++ An OrderedList is a vector that keeps.pdfPlease find this solution in C++ An OrderedList is a vector that keeps.pdf
Please find this solution in C++ An OrderedList is a vector that keeps.pdf
aachalsaleswani
 
You are required to open an input file (shown below) then read one c.pdf
You are required to open an input file (shown below) then read one c.pdfYou are required to open an input file (shown below) then read one c.pdf
You are required to open an input file (shown below) then read one c.pdf
arpaqindia
 
Open Office Calc : Level1
 Open Office Calc : Level1 Open Office Calc : Level1
Open Office Calc : Level1
thinkict
 
Instructions Write a program whose main function is merely a.pdf
Instructions Write a program whose main function is merely a.pdfInstructions Write a program whose main function is merely a.pdf
Instructions Write a program whose main function is merely a.pdf
adinathknit
 
Open Office Calc : Level 1
Open Office Calc : Level 1Open Office Calc : Level 1
Open Office Calc : Level 1
thinkict
 
I am stuck on parts E and FExercise 1      NumberListTester.java.pdf
I am stuck on parts E and FExercise 1      NumberListTester.java.pdfI am stuck on parts E and FExercise 1      NumberListTester.java.pdf
I am stuck on parts E and FExercise 1      NumberListTester.java.pdf
RAJATCHUGH12
 
Please Please Please Read the instructions and do everything li.docx
Please Please Please Read the instructions and do everything li.docxPlease Please Please Read the instructions and do everything li.docx
Please Please Please Read the instructions and do everything li.docx
tienmixon
 
RANDOMISATION-NUMERICAL METHODS FOR ENGINEERING.pptx
RANDOMISATION-NUMERICAL METHODS  FOR ENGINEERING.pptxRANDOMISATION-NUMERICAL METHODS  FOR ENGINEERING.pptx
RANDOMISATION-NUMERICAL METHODS FOR ENGINEERING.pptx
Out Cast
 

Similar to The purpose of this assignment is to give you practice with writing lo.docx (20)

Please help. C++ The program is an interactive program th.pdf
Please help. C++ The program is an interactive program th.pdfPlease help. C++ The program is an interactive program th.pdf
Please help. C++ The program is an interactive program th.pdf
 
Answer should be in MIPS please Please ensure you are follo.pdf
Answer should be in MIPS please Please ensure you are follo.pdfAnswer should be in MIPS please Please ensure you are follo.pdf
Answer should be in MIPS please Please ensure you are follo.pdf
 
22-excel-basics-15511.ppt
22-excel-basics-15511.ppt22-excel-basics-15511.ppt
22-excel-basics-15511.ppt
 
Data management( on computer)
Data management( on computer)Data management( on computer)
Data management( on computer)
 
Please find this solution in C++ An OrderedList is a vector that keeps.pdf
Please find this solution in C++ An OrderedList is a vector that keeps.pdfPlease find this solution in C++ An OrderedList is a vector that keeps.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
You are required to open an input file (shown below) then read one c.pdfYou are required to open an input file (shown below) then read one c.pdf
You are required to open an input file (shown below) then read one c.pdf
 
Write a complete C programme to implement the following sorting algor.docx
 Write a complete C programme to implement the following sorting algor.docx Write a complete C programme to implement the following sorting algor.docx
Write a complete C programme to implement the following sorting algor.docx
 
Open Office Calc : Level1
 Open Office Calc : Level1 Open Office Calc : Level1
Open Office Calc : Level1
 
Instructions Write a program whose main function is merely a.pdf
Instructions Write a program whose main function is merely a.pdfInstructions Write a program whose main function is merely a.pdf
Instructions Write a program whose main function is merely a.pdf
 
Open Office Calc : Level 1
Open Office Calc : Level 1Open Office Calc : Level 1
Open Office Calc : Level 1
 
Gui testing
Gui testingGui testing
Gui testing
 
Python workshop
Python workshopPython workshop
Python workshop
 
I am stuck on parts E and FExercise 1      NumberListTester.java.pdf
I am stuck on parts E and FExercise 1      NumberListTester.java.pdfI am stuck on parts E and FExercise 1      NumberListTester.java.pdf
I am stuck on parts E and FExercise 1      NumberListTester.java.pdf
 
stats
statsstats
stats
 
Calc lessons
Calc lessonsCalc lessons
Calc lessons
 
types
typestypes
types
 
Please Please Please Read the instructions and do everything li.docx
Please Please Please Read the instructions and do everything li.docxPlease Please Please Read the instructions and do everything li.docx
Please Please Please Read the instructions and do everything li.docx
 
Lab6: I/O and Arrays
Lab6: I/O and ArraysLab6: I/O and Arrays
Lab6: I/O and Arrays
 
RANDOMISATION-NUMERICAL METHODS FOR ENGINEERING.pptx
RANDOMISATION-NUMERICAL METHODS  FOR ENGINEERING.pptxRANDOMISATION-NUMERICAL METHODS  FOR ENGINEERING.pptx
RANDOMISATION-NUMERICAL METHODS FOR ENGINEERING.pptx
 
Manual for typing tutor for punjabi raavi font
Manual for typing tutor for punjabi raavi fontManual for typing tutor for punjabi raavi font
Manual for typing tutor for punjabi raavi font
 

More from StephenzcxParsonsq

There is- a dirty little secret about Alexander Fleming and his discov.docx
There is- a dirty little secret about Alexander Fleming and his discov.docxThere is- a dirty little secret about Alexander Fleming and his discov.docx
There is- a dirty little secret about Alexander Fleming and his discov.docx
StephenzcxParsonsq
 

More from StephenzcxParsonsq (20)

This question is related to Immunohematology- Rh blood group- There ca.docx
This question is related to Immunohematology- Rh blood group- There ca.docxThis question is related to Immunohematology- Rh blood group- There ca.docx
This question is related to Immunohematology- Rh blood group- There ca.docx
 
These are the results you observe- And once you view the results thi.docx
These are the results you observe-   And once you view the results thi.docxThese are the results you observe-   And once you view the results thi.docx
These are the results you observe- And once you view the results thi.docx
 
There is- a dirty little secret about Alexander Fleming and his discov.docx
There is- a dirty little secret about Alexander Fleming and his discov.docxThere is- a dirty little secret about Alexander Fleming and his discov.docx
There is- a dirty little secret about Alexander Fleming and his discov.docx
 
There is risk involved in consumer decision making as discussed in lec.docx
There is risk involved in consumer decision making as discussed in lec.docxThere is risk involved in consumer decision making as discussed in lec.docx
There is risk involved in consumer decision making as discussed in lec.docx
 
There is a view that life is one big externality- (Just about everythi.docx
There is a view that life is one big externality- (Just about everythi.docxThere is a view that life is one big externality- (Just about everythi.docx
There is a view that life is one big externality- (Just about everythi.docx
 
There is a new test for a new disease- For a specific version of the t.docx
There is a new test for a new disease- For a specific version of the t.docxThere is a new test for a new disease- For a specific version of the t.docx
There is a new test for a new disease- For a specific version of the t.docx
 
There are 100 students in a class- Ninety-six did well in the course w.docx
There are 100 students in a class- Ninety-six did well in the course w.docxThere are 100 students in a class- Ninety-six did well in the course w.docx
There are 100 students in a class- Ninety-six did well in the course w.docx
 
There are a certain number of pigs in a race at the Ohio State Fair th.docx
There are a certain number of pigs in a race at the Ohio State Fair th.docxThere are a certain number of pigs in a race at the Ohio State Fair th.docx
There are a certain number of pigs in a race at the Ohio State Fair th.docx
 
The Wall had protected Westeros from the dangers of the wildlings for.docx
The Wall had protected Westeros from the dangers of the wildlings for.docxThe Wall had protected Westeros from the dangers of the wildlings for.docx
The Wall had protected Westeros from the dangers of the wildlings for.docx
 
The two types of people in an accounting information system are inform.docx
The two types of people in an accounting information system are inform.docxThe two types of people in an accounting information system are inform.docx
The two types of people in an accounting information system are inform.docx
 
The Twist Trust has qenerated $60-000 in depreciation deductions for t.docx
The Twist Trust has qenerated $60-000 in depreciation deductions for t.docxThe Twist Trust has qenerated $60-000 in depreciation deductions for t.docx
The Twist Trust has qenerated $60-000 in depreciation deductions for t.docx
 
The TATO and FATO ratios calculate how quickly our assets are replaced.docx
The TATO and FATO ratios calculate how quickly our assets are replaced.docxThe TATO and FATO ratios calculate how quickly our assets are replaced.docx
The TATO and FATO ratios calculate how quickly our assets are replaced.docx
 
The third biggest level in Linnaeus' biological classification is- QUE.docx
The third biggest level in Linnaeus' biological classification is- QUE.docxThe third biggest level in Linnaeus' biological classification is- QUE.docx
The third biggest level in Linnaeus' biological classification is- QUE.docx
 
The term haploid refers to a cell in which the chromosomes do not have (1).docx
The term haploid refers to a cell in which the chromosomes do not have (1).docxThe term haploid refers to a cell in which the chromosomes do not have (1).docx
The term haploid refers to a cell in which the chromosomes do not have (1).docx
 
The table below ehes protabilities for various combernations of events.docx
The table below ehes protabilities for various combernations of events.docxThe table below ehes protabilities for various combernations of events.docx
The table below ehes protabilities for various combernations of events.docx
 
The table below shows the values for several different components of G.docx
The table below shows the values for several different components of G.docxThe table below shows the values for several different components of G.docx
The table below shows the values for several different components of G.docx
 
The table below shows the correlations between the death rate from COV.docx
The table below shows the correlations between the death rate from COV.docxThe table below shows the correlations between the death rate from COV.docx
The table below shows the correlations between the death rate from COV.docx
 
The table below describes the distribution of a random sample S of 100.docx
The table below describes the distribution of a random sample S of 100.docxThe table below describes the distribution of a random sample S of 100.docx
The table below describes the distribution of a random sample S of 100.docx
 
The Subtropical Highs are characterized by_________- descending ai.docx
The Subtropical Highs are characterized by_________-     descending ai.docxThe Subtropical Highs are characterized by_________-     descending ai.docx
The Subtropical Highs are characterized by_________- descending ai.docx
 
The star Alpha Lupi (the brightest star in the constellation Lupus) ha.docx
The star Alpha Lupi (the brightest star in the constellation Lupus) ha.docxThe star Alpha Lupi (the brightest star in the constellation Lupus) ha.docx
The star Alpha Lupi (the brightest star in the constellation Lupus) ha.docx
 

Recently uploaded

會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
中 央社
 
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
EADTU
 

Recently uploaded (20)

Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptx
 
The Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFThe Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDF
 
Book Review of Run For Your Life Powerpoint
Book Review of Run For Your Life PowerpointBook Review of Run For Your Life Powerpoint
Book Review of Run For Your Life Powerpoint
 
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community PartnershipsSpring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
 
An Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppAn Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge App
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
 
Trauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesTrauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical Principles
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
 
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhĐề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
 
Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"
 
PSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptxPSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptx
 
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMDEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
 
Supporting Newcomer Multilingual Learners
Supporting Newcomer  Multilingual LearnersSupporting Newcomer  Multilingual Learners
Supporting Newcomer Multilingual Learners
 
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxAnalyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
 
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopal
 
How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17
 

The purpose of this assignment is to give you practice with writing lo.docx

  • 1. 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 list. 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 (V). 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 case, 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 either 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 seek input after a proper error message.