SlideShare a Scribd company logo
1 of 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.

More Related Content

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

Excel Data Management
Excel Data ManagementExcel Data Management
Excel Data Management
Rachel Espino
 
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
 
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 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
 
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
 
template ltclass Tgt struct nodeType T data n.pdf
template ltclass Tgt struct nodeType      T data     n.pdftemplate ltclass Tgt struct nodeType      T data     n.pdf
template ltclass Tgt struct nodeType T data n.pdf
aceautomate
 
Data management( on computer)
Data management( on computer)Data management( on computer)
Data management( on computer)
elvieantony
 
Given is the IntNode class that represents an element in a linked list (3).docx
Given is the IntNode class that represents an element in a linked list (3).docxGiven is the IntNode class that represents an element in a linked list (3).docx
Given is the IntNode class that represents an element in a linked list (3).docx
francescaj1
 
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
 
Prompt Your task is to create a connected list implementation and .pdf
Prompt Your task is to create a connected list implementation and .pdfPrompt Your task is to create a connected list implementation and .pdf
Prompt Your task is to create a connected list implementation and .pdf
alsofshionchennai
 

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

Excel Data Management
Excel Data ManagementExcel Data Management
Excel Data Management
 
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
 
Values and Data types in python
Values and Data types in pythonValues and Data types in python
Values and Data types in python
 
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
 
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
 
How to use a spreadsheet
How to use a spreadsheetHow to use a spreadsheet
How to use a spreadsheet
 
22 Excel Basics
22 Excel Basics22 Excel Basics
22 Excel Basics
 
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
 
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
 
RANDOMISATION-NUMERICAL METHODS FOR ENGINEERING.pptx
RANDOMISATION-NUMERICAL METHODS  FOR ENGINEERING.pptxRANDOMISATION-NUMERICAL METHODS  FOR ENGINEERING.pptx
RANDOMISATION-NUMERICAL METHODS FOR ENGINEERING.pptx
 
template ltclass Tgt struct nodeType T data n.pdf
template ltclass Tgt struct nodeType      T data     n.pdftemplate ltclass Tgt struct nodeType      T data     n.pdf
template ltclass Tgt struct nodeType T data n.pdf
 
Data management( on computer)
Data management( on computer)Data management( on computer)
Data management( on computer)
 
types
typestypes
types
 
22-excel-basics-15511.ppt
22-excel-basics-15511.ppt22-excel-basics-15511.ppt
22-excel-basics-15511.ppt
 
Lab6: I/O and Arrays
Lab6: I/O and ArraysLab6: I/O and Arrays
Lab6: I/O and Arrays
 
Data types in python
Data types in pythonData types in python
Data types in python
 
Given is the IntNode class that represents an element in a linked list (3).docx
Given is the IntNode class that represents an element in a linked list (3).docxGiven is the IntNode class that represents an element in a linked list (3).docx
Given is the IntNode class that represents an element in a linked list (3).docx
 
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
 
Prompt Your task is to create a connected list implementation and .pdf
Prompt Your task is to create a connected list implementation and .pdfPrompt Your task is to create a connected list implementation and .pdf
Prompt Your task is to create a connected list implementation and .pdf
 

More from MichaelQEBMartinc

More from MichaelQEBMartinc (20)

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

Recently uploaded

1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Recently uploaded (20)

PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 

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.