Question

*IN PYTHON* (Count single digits) Write a program that generates 1,000 random integers between 0 and...

*IN PYTHON*

(Count single digits) Write a program that generates 1,000 random integers between 0 and 9 and displays the count for
each number. (Hint: Use a list of ten integers, say counts, to store the counts for the number of 0s, 1s, ..., 9s.)

Rubric

5 pts: Proper use of list to count occurrences of numbers

5 pts: Proper calculations of counts

5 pts: Proper output

Note: No software dev plan or UML required
0 0
Add a comment Improve this question Transcribed image text
Answer #1
Thanks for the question.

Below is the code you will be needing  Let me know if you have any doubts or if you need anything to change.

Thank You !
​​​​​​​
===========================================================================

import random

counts = [0] * 10

for _ in range(1000):
    rand_num = random.randint(0,9)
    counts[rand_num]+=1

print('{0:<7}{1:>8}'.format('Number','Counts'))
for i in range(len(counts)):
    print('{0:<7}{1:>7}'.format(i,counts[i]))

==============================================================

Add a comment
Know the answer?
Add Answer to:
*IN PYTHON* (Count single digits) Write a program that generates 1,000 random integers between 0 and...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a C program that generates one hundred random integers between 0 and 9 and displays...

    Write a C program that generates one hundred random integers between 0 and 9 and displays the count for each number. (Hint: Use rand()%10 to generate a random integer between 0 and 9. Use an array of ten integers, say counts, to store the counts for the number of 0’s, 1’s,…..,9’s.)

  • 4. Write a program that generates one hundred random integers between 0 and 9 and displays...

    4. Write a program that generates one hundred random integers between 0 and 9 and displays the count for each number. (Hint: Use rand()%10 to generate a random integer between 0 and 9. Use an array of ten integers, say counts, to store the counts for the number of 0’s, 1’s,…..,9’s.) this program kinda works but i cant figure out why its making more than 100 random numbers ls) [*] test2.cpp test3.cpp #include<stdio.h> #include<stdlib.h> int main() 4 { int a[14],is...

  • C# prograaming language 1. write a program that generates 10,000 random integers in the range of ...

    c# prograaming language 1. write a program that generates 10,000 random integers in the range of 0-9 and them in binary search tree. 2. use any sort algorithm (insertion, bubble, quick...) to display a list of each of the integers and how many times they appear. 3. at last, add ruction to the BinarySearchTree class that count the number of edges in a tree. Write a program that generates 10,000 random integers in the range of 0-9 and store them...

  • Write a program that generates an array of one hundred random integers between 0 and 9...

    Write a program that generates an array of one hundred random integers between 0 and 9 and displays the count of each number. C programming

  • Write a C++ program that generates twenty five random integers between 0 and 24 and display the sum of even integers.

    (C++)Write a program that generates twenty five random integers between 0 and 24 and display the sum of even integers. (Hint: Use rand()%25 to generate a random integer between 0 and 24. Use an array of 25 integers, say num , to store the random integers generated between 0 and 24.)

  • Using Python, Lists: Write a program that randomly generates 1000 numbers between 0 and 9 and...

    Using Python, Lists: Write a program that randomly generates 1000 numbers between 0 and 9 and counts the count of each number. The output should have this form: 3 occurs 5 times 5 occurs 1 time Notice that if there is more than 1. The word times is used and if there is only 1, the word times is used.

  • (Count occurrence of numbers) Write a program that reads some integers between 1 and 100 and...

    (Count occurrence of numbers) Write a program that reads some integers between 1 and 100 and counts the occurrences of each. Here is a sample run of the program: Enter integers between 1 and 100: 2 occurs 2 times 3 occurs 1 time 4 occurs 1 time 5 occurs 2 times 6 occurs 1 time 23 occurs 1 time 43 occurs 1 time 2 5 6 5 4 3 23 43 2 Note that if a number occurs more than...

  • Write a program in python that generates X random integers Num. Num is a random number...

    Write a program in python that generates X random integers Num. Num is a random number between 20 to 50. X is a random number between 10 to 15. Calculate and show the Smallest, Largest, Sum, and Average of those numbers. You are not allowed to use Python functions sample(), min(), max(), average(), sort(), sorted()!! HINTs: to find Smallest.... 1) X is a random number between 10 to 15... for example 11...this determines how many times the loop will happen...

  • Problem: Write a program that generates random numbers between 1 and 10 and fill an array...

    Problem: Write a program that generates random numbers between 1 and 10 and fill an array of size 20 with them. Have your program sort the array then output in order the number of occurrences of each random number generated. Use the STL sort function to sort your array. How to use the STL sort: #include <algorithm> ... int a[20] ... sort(a,a+20); Example Output: This program generates random numbers and tabulates the results Original List Sorted: a[ 0] 1 a[...

  • In JAVA, write a program that generates 10 random numbers between 0 and 9. Use count...

    In JAVA, write a program that generates 10 random numbers between 0 and 9. Use count arrays for each number. A sample output would be: The 10 random numbers are: 5 7 1 9 0 0 1 2 3 4 0 occurs 2 times 1 occurs 2 times 2 occurs 1 time 3 occurs 1 time 4 occurs 1 time 5 occurs 1 time 6 occurs 0 times 7 occurs 1 time 8 occurs 0 times 9 occurs 1 time

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