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
sergey [27]
2 years ago
12

Write a program that generates 1,000 random integers between 0 and 9 and displays the count for each number. (Hint: Use a list o

f ten integers, say counts, to store the counts for the number of 0s, 1s, ..., 9s.)
Computers and Technology
1 answer:
masya89 [10]2 years ago
5 0

Answer:

import random

count0, count1, count2, count3,

count4, count5, count6, count7,

count8, count9, i = [0 for _ in range(11)]

while i < 1000:

   number = random.randint(0,9)

   if number == 0:

       count0 = count0 + 1

   if number == 1:

       count1 = count1 + 1

   if number == 2:

       count2 = count2 + 1

   if number == 3:

       count3 = count3 + 1

   if number == 4:

       count4 = count4 + 1

   if number == 0:

       count5 = count5 + 1

   if number == 6:

       count6 = count6 + 1

   if number == 7:

       count7 = count7 + 1

   if number == 0:

       count8 = count8 + 1

   if number == 9:

       count9 = count9 + 1

   

   i = i+1

print("0's: "+ str(count0) + "\n"+ "1's: "+ str(count1) + "\n"+

"2's: "+ str(count2) + "\n"+ "3's: "+ str(count3) + "\n"+

"4's: "+ str(count4) + "\n"+ "5's: "+ str(count5) + "\n"+

"6's: "+ str(count6) + "\n"+ "7's: "+ str(count7) + "\n"+

"8's: "+ str(count8) + "\n"+ "9's: "+ str(count9) + "\n")

Explanation:

- Initialize variables to hold the count for each number

- Initialize <em>i</em> to control the while loop

- Inside the while loop, check for the numbers and increment the count values when matched.

- Print the result

You might be interested in
Who can help me with 50 varables on codeskulptor​
MrMuchimi

Answer:variables - placeholders for important values

# used to avoid recomputing values and to

# give values names that help reader understand code

# valid variable names - consists of letters, numbers, underscore (_)

# starts with letter or underscore

# case sensitive (capitalization matters)

# legal names - ninja, Ninja, n_i_n_j_a

# illegal names - 1337, 1337 ninja

# Python convention - multiple words joined by _

# legal names - elite_ninja, leet_ninja, ninja_1337

# illegal name 1337_ninja

# assign to variable name using single equal sign =

# (remember that double equals == is used to test equality)

# examples  

my_name = "Joe Warren"

print my_name

my_age = 51

print my_age

# birthday - add one

#my_age += 1

print my_age

# the story of the magic pill

magic_pill = 30

print my_age - magic_pill

my_grand_dad = 74

print my_grand_dad - 2 * magic_pill

Explanation:placeholders for important values. 2. # used to avoid recomputing values and to. 3. # give values names that help reader understand code. 4. ​. 5. ​.

6 0
3 years ago
4. Write technical term for the following statements
IRISSAK [1]

A=Application software

C=Microcomputer

D=hybrid computers

E=digital computer

F=Handheld computer

G=Dextop computer

Sorry,i couldn't help you in B.

5 0
3 years ago
Read 2 more answers
Which operating system became obsolete with the arrival of a more advanced graphical user interfaces
12345 [234]
The answer is Ms Dos
6 0
3 years ago
Why do we need to send emails
DiKsa [7]

Answer:

email is the easier way of communicating and fast

5 0
3 years ago
Identify any eight new programming languages and classify them based on their functionality.
shepuryov [24]

Answer:

Some of the new programming languages are R, Python, Haskell, Swift, C++, Java, Javascript and PHP.

However, you should know that in general sense there are three types of programming languages.

R is a pure object-oriented programming language being used for scientific purposes, and now it is being used extensively for machine learning as well.

Python is also a pure object-oriented programming language, and it is being used for mainly machine learning. However, you need to keep in mind that it supports the functional programming paradigm as well.

Haskell is a functional programming language and is the best in the functional paradigm as well. You can compare it with LISP, FORTRAN and PASCAL or COBOL, and you will find that Haskell is the best.

Swift is a pure object-oriented programming language, And by pure it means it never cheats anybody like if it says a variable is an int, it will be an int and not like C# here a string data type can be an integer data type. And this is not the correct thing. However, if you study in deep, you will find it is a necessary evil.

C++ and Java are imperative programming languages.

The Javascript and PHP are the scripting languages that support the object-oriented programming concepts but not fully, and they too fall under the imperative programming language list.

Explanation:

The answer is self explanatory.

4 0
3 years ago
Read 2 more answers
Other questions:
  • ______ means locating a file among a set of file​
    14·1 answer
  • During World War II, the Battle of the Coral Sea was significant because it evened the naval strength of the Japanese and US fle
    6·1 answer
  • In step 2 of the mail merge process you must be prepared to
    6·2 answers
  • Today encoding scheme has taken over ascII by what
    5·1 answer
  • An Internet user has a need to send private data to another user. Which of the following provides the most security when transmi
    15·2 answers
  • How can you tell that a website is valid and reliable
    7·2 answers
  • Car batteries have two terminals which are (blank).
    8·2 answers
  • Describe the functions of ALU, resisters, CU, BIU, Cache and FPU.
    7·1 answer
  • When you copy a formula that contains an absolute reference to a new location, the reference ____. a. has a dotted outline in it
    6·1 answer
  • It is not important to keep financial records since they can all be found online.
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!