Write a program that read a sequence of positive integer


Q: 1. Write a program that read a sequence of positive integer inputs and print the sum and average of the inputs. Assume that the user always enters a positive number (integer) as an input value or an empty space as a sentinel value. Please use the below to test your code:

Enter an int value or empty string to end: 98

Enter an int value or empty string to end: 78

Enter an int value or empty string to end: 77

Enter an int value or empty string to end: 1

Enter an int value or empty string to end: 10

Enter an int value or empty string to end:

Sum: 264 Average: 52.8

2. Write a program that read a sequence of positive integers and print the number of odd inputs entered by the user. The sentinel value is an empty string. Use the following test case :

Enter integer or empty string to end: 3

Enter integer or empty string to end: 2

Enter integer or empty string to end: 10

Enter integer or empty string to end: 5

Enter integer or empty string to end: 6

Enter integer or empty string to end: 7

Enter integer or empty string to end:

number of odd integers entered: 3

3. Write a program that read a sequence of positive integers and print the average value of all the odd integers entered by the user (hint: you need to compute the sum of all the odd integers first to calculate the average). Use the following test case:

Enter an int value or empty string to end: 10

Enter an int value or empty string to end: 20

Enter an int value or empty string to end: 5

Enter an int value or empty string to end: 10

Enter an int value or empty string to end: 15

Enter an int value or empty string to end:

average : 10.0

Use python code for all questions and give the outpu in word document and make in python cell file

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: Write a program that read a sequence of positive integer
Reference No:- TGS02908447

Expected delivery within 24 Hours

2015 ┬ęTutorsGlobe All rights reserved. TutorsGlobe Rated 4.8/5 based on 34139 reviews.