Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is an assignment for my Python Programming class. Struggling with the indefinite loop concept. Please help! In this Programming Assignment you will read data

image text in transcribedThis is an assignment for my Python Programming class. Struggling with the indefinite loop concept. Please help!

In this Programming Assignment you will read data via input (not from a file) using an indefinite loop (section 8.2 in your text). Continue reading input until you have read 1U integers. You must use exception handling (section 7.4) to take the action of displaying an error message when the object that has been input is not an integer and then continue requesting more input until 10 valid integers have been entered. Place the integers into a list as you receive them. When you have successfully entered 10 integers (you may actually want to use a number smaller than 10 while you are in the debugging phase) use decision structures to determine: 1. The number of positive integers 2. The number of negative integers (consider zero to be neither positive nor negative) 3. The number of even integers Also determine: 4. The largest integer 5. The smallest integer 6. The sum of all the integers 7. The average of just the positive integers (guaranteed to be at least 1 of these) Write functions to do 1,2, 3, and 7 above. Python includes functions to do 4, 5, and 6. The functions you write should accept the list as the only parameter and return the answer (an integer for 1,2, and 3 and a float for 7). Here is a sample run of the program. User inputs are shown in bold. Input prompts were created with string formatting. Enter 10 integers Enter integer 1: 18 Enter integer 2: -5 Enter integer 3: abc abc is not a valid integer. Try again. Enter integer 3: .. is not a valid integer. Try again. Enter integer 3: 6 Enter integer 4: -9 Enter integer 5: 0 Enter integer 6: 0.0 0.0 is not a valid integer. Try again. Enter integer 6: 1 Enter integer 7:5 Enter integer 8: 100 Enter integer 9:-95 Enter integer 10: 6 You got: [18, -5, 6, -9, 0, 1. 5, 100, -95, 6] 6 integers are positive. 3 integers are negative 5 integers are even. 100 is the largest integer 95 is the smallest integer 27 is the sum of the integers. 22.666666666666668 is the average of the positive integers

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: 3

blur-text-image

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

Database Principles Programming And Performance

Authors: Patrick O'Neil, Elizabeth O'Neil

2nd Edition

1558605800, 978-1558605800

More Books

Students also viewed these Databases questions