1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
RUDIKE [14]
2 years ago
6

Write a program that prompts the user to enter a series of numbers between 0 and 10 asintegers. The user will enter all numbers

on a single line, and scores will be separatedby spaces. You cannot assume the user will supply valid integers, nor can you assumethat they will enter positive numbers, so make sure that you validate your data. You donot need to re-prompt the user once they have entered a single line of data. Once youhave collected this data you should compute the following: • The largest value • Thesmallest value • The range of values • The mode (the value that occurs the most often) •A histogram that visualizes the frequency of each number Here’s a sample running of theprogram.
Computers and Technology
1 answer:
Anna71 [15]2 years ago
7 0

Answer:

The program in Python is as follows:

import collections

from collections import Counter

from itertools import groupby

import statistics

str_input = input("Enter a series of numbers separated by space: ")

num_input = str_input.split(" ")

numList = []

for num in num_input:

         if(num.lstrip('-').isdigit()):

                   if num[0] == "-" or int(num)>10:

                             print(num," is out of bound - rejecting")

                   else:

                             print(num," is valid - accepting")

                             numList.append(int(num))

         else:

                   print(num," is not a number")

print("Largest number: ",max(numList))

print("Smallest number: ",min(numList))

print("Range: ",(max(numList) - min(numList)))

print("Mode: ",end = " ")

freqs = groupby(Counter(numList).most_common(), lambda x:x[1])

print([val for val,count in next(freqs)[1]])

count_freq = {}

count_freq = collections.Counter(numList)

for item in count_freq:

         print(item, end = " ")

         lent= int(count_freq[item])

         for i in range(lent):

                   print("#",end=" ")

print()

Explanation:

See attachment for program source file where comments are used as explanation. (Lines that begin with # are comments)

The frequency polygon is printed using #'s to represent the frequency of each list element

You might be interested in
What are 5 good movies like The Breakfast Club or 8 Mile?
Gnoma [55]

Answer:

The Notebook, Beauty and the Beast, Step Brother, The Breakfast Club and The Little Mermaid

Explanation:

8 0
3 years ago
Read 2 more answers
What does cpu stand for
lozanna [386]
Central processing unit.
7 0
3 years ago
Read 2 more answers
Write a lottery program that will ask the user if they would like to pick 5 numbers (1-30) or if they would like to choose EZ Pi
Llana [10]

Answer:

Explanation:

The following code is written in Python and creates arrays for the user's numbers and the next chance numbers, it also creates a cost variable and a did_you_win variable. The function takes in the winning numbers as an array parameter. It asks all the necessary questions to generate data for all the variables and then compares the user's numbers to the winning numbers in order to detect if the user has won. Finally, it prints all the necessary information.

import random

def lottery(winning_numbers):

   user_numbers = []

   next_chance_drawing = []

   cost = 0

   did_you_win = "No"

   #print("Would you like to choose your own 5 numbers? Y or N")

   answer = input("Would you like to choose your own 5 numbers? Y or N: ")

   if answer.capitalize() == "Y":

       for x in range(5):

           user_numbers.append(input("Enter number " + str(x+1) + ": "))

   else:

       for x in range(5):

           user_numbers.append(random.randint(0,31))

           cost += 1

   next_chance = input("Would you like to enter a Next Chance drawing for $1.00? Y or N: ")

   if next_chance.capitalize() == "Y":

       for x in range(4):

           next_chance_drawing.append(random.randint(0, 31))

           cost += 1

           

   if user_numbers == winning_numbers or next_chance_drawing == winning_numbers:

       did_you_win = "Yes"

   print("User Numbers: " + str(user_numbers))

   print("Next Chance Numbers: " + str(next_chance_drawing))

   print("Cost: $" + str(cost))

   print("Did you win: " + did_you_win)

6 0
2 years ago
This has nothing to do with anything school related, but I'm new to car audio and I was wondering, what happens or what would ha
DerKrebs [107]
It most likely can but It may damage your system. So you should seek out professional help from a car dealership and do more research.

Hope this helps.<span />
7 0
2 years ago
Microsoft has developed a method for measuring a system's total costs and benefits, called ____, which is a framework to help IT
Korvikt [17]

Answer:

It is called B. REJ

Explanation:

REJ means Rapid Economic Justification. This is a methodology or framework to help IT professionals analyze IT investments. The main aim of this framework for business optimization

7 0
3 years ago
Other questions:
  • andy accidentally saved a file in the wrong folder. what is the quickest way to move the file? create a new file and save it in
    8·2 answers
  • When should students practice netiquette in an online course?
    9·1 answer
  • Write a program that prints the day number of the year, given the date in the form month-day-year. For example, if the input is
    9·1 answer
  • _____ provide a description of the data characteristics and the set of relationships that link the data found within the databas
    8·1 answer
  • When you are working in Performance Monitor, in the "Add Counters" dialog box, and need more information about a particular coun
    8·1 answer
  • What is technology? *
    10·1 answer
  • Write a program that calculates the average of N integers. The program should prompt the
    12·1 answer
  • Chức năng của hàm MOD(number, divisor)?
    7·1 answer
  • you want to be able to restrict values allowed in a cell and need to create a drop-down list of values from which users can choo
    14·1 answer
  • Sharon's company has written a new computer program, and she has been asked to find a way to prevent people from copying the sof
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!