Question

In Python 3 - Write a program that reads a sequence of integer inputs from the...

In Python 3 -

Write a program that reads a sequence of integer inputs from the user.

When the user is finished entering the integers, they will enter a 'q'. There is no need to check if the entry is a valid integer. All integers in the test data (input) will be between -255 and 255.

The program should then print:

The smallest and largest of the inputs.

The number of even and odd inputs (0 should be considered even)

Cumulative totals. For example, if the input is 1 7 2 9, the program should print 1 8 10 19.

1 0
Add a comment Improve this question Transcribed image text
✔ Recommended Answer
Answer #1

sums = []

# initialize sum and counter

sum = 0

evenCnt=0

oddCnt=0

min=9999

max=-9999

more = ""

# To take input from the user,

more = input("Enter n: ")

while more!= "q":

  n = int(more)

if min>n:

  min=n

if max<n:

  max=n

sum = sum + n

if n%2==0:

  evenCnt=evenCnt+1

if n%2!=0:

  oddCnt=oddCnt+1

sums.append(sum)

more = input("Enter n: ")



print("Minimum:",min)

print("Maximum:",max)

print("No of Odds:",oddCnt)

print("No of Evens:",evenCnt)

print("Cumulative Sums: ", sums)


Add a comment
Know the answer?
Add Answer to:
In Python 3 - Write a program that reads a sequence of integer inputs from the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • # Write PYTHON programs that read a sequence of integer inputs and print # a.  The...

    # Write PYTHON programs that read a sequence of integer inputs and print # a.  The smallest and largest of the inputs. # b.  The number of even and odd inputs. # c.  Cumulative totals. For example, if the input is 1 7 2 9, the program should print # 1 8 10 19. # d.  All adjacent duplicates. For example, if the input is 1 3 3 4 5 5 6 6 6 2, the # program should print...

  • For Java Write a program that reads a sequence of integer inputs all on one line...

    For Java Write a program that reads a sequence of integer inputs all on one line and prints: 1.)The smallest and largest of the inputs 2.)The number of odd and even inputs 3.)Cumulative totals. If the input is 1 7 2 9, the program prints 1 8 10 19. 4.)All adjacent duplicates. If the input is 1 3 3 4 5 5 6 6 6 2, the output is 3 5 6.

  • Write a single program in java using only do/while loops for counters(do not use array pls)...

    Write a single program in java using only do/while loops for counters(do not use array pls) for the majority of the program and that asks a user to enter a integer and also asks if you have any more input (yes or no) after each input if yes cycle again, if not the program must do all the following 4 things at the end of the program once the user is finished inputting all inputs... a.The smallest and largest of...

  • In Python 3, Write a program that reads a set of floating-point values. Ask the user...

    In Python 3, Write a program that reads a set of floating-point values. Ask the user to enter the values, then print: The number of values entered. The smallest of the values The largest of the values. The average of the values. The range, that is the difference between the smallest and largest values. If no values were entered, the program should display “No values were entered” The program execution should look like (note: the bold values are sample user...

  • Exercise 9.2 Write a Python program that collects from the user a single integer. Have the...

    Exercise 9.2 Write a Python program that collects from the user a single integer. Have the program print “EVEN” if the integer is divisible by 2, and “ODD” if the integer is not divisible by two. [Use the % operator to compute the two’s modulus (remainder of division by two)] Exercise 9.3 Write a Python program that collects from the user two integers. Have the program print “Yes” if the two integers are BOTH greater than 10. Do nothing if...

  • Write a MIPS program that reads (with an appropriate prompt) a sequence of 20 integers and...

    Write a MIPS program that reads (with an appropriate prompt) a sequence of 20 integers and stores them in an array, and then calls the following two functions and prints the results in a readable format. The two functions are: smallestLargest: computes the smallest and the largest values in the array. oddEven: computes the number of even integers and the number of odd integers.

  • python la ab X, X Lab 7 Design and implement a Python program that uses a...

    python la ab X, X Lab 7 Design and implement a Python program that uses a while loop and selection statements to print the sum of the even numbers and the sum of the odd numbers (all integers) read from the keyboard. The sequence of numbers ends with a negative number: So, all numbers considered for printing the two sums are greater than or equal to 0. The sequence may be empty. Here is a possible interaction. Enter an integer:...

  • C++ assignment Write a program that reads a sequence of integers and prints the following: 1....

    C++ assignment Write a program that reads a sequence of integers and prints the following: 1. The number of odd and even numbers of inputs Use a sentinel value to signal the end of inputs. If the sentinel value is the first you enter, give a message “NO input is entered!”. Input Validation: Do not accept a negative number.

  • Python 3 Write a program that reads a sequence of words and prints every word whose...

    Python 3 Write a program that reads a sequence of words and prints every word whose frequency is equal to its length. You can assume that there will always be a word that meets this condition. If more than one word have this condition, you must print first the most frequent one. If two or more words with equal frequencies meet this condition, print them from the smallest to the largest in alphabetical order. Sample Input lee john lee peter...

  • Write a program that reads from the keypad an integer and calculates the following: If the...

    Write a program that reads from the keypad an integer and calculates the following: If the number given by the user is even, then divide it by 2. If it is an odd number, multiply it by 3 and add 1.The program should repeat this procedure for the calculated new result (which will be printed on the screen) until it reaches number 1. The program will also need to print out how many steps it took overall.

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT