Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTHON CODE PLEASE in python Purpose The purpose of this assignment is to give you practice with writing loops and introduce you to lists. Problem

image text in transcribedPYTHON CODE PLEASE
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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_step_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts Of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

4th Edition

ISBN: 0619064625, 978-0619064624

More Books

Students also viewed these Databases questions

Question

What is meant by organisational theory ?

Answered: 1 week ago

Question

What is meant by decentralisation of authority ?

Answered: 1 week ago

Question

Briefly explain the qualities of an able supervisor

Answered: 1 week ago

Question

Define policy making?

Answered: 1 week ago

Question

Define co-ordination?

Answered: 1 week ago