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
Leona [35]
3 years ago
14

Write a program that will print out statistics for eight coin tosses. The user will input either an "h" for heads or a "t" for t

ails for the eight tosses. The program will then print out the total number and percentages of heads and tails. Use the increment operator to increment the number of tosses as each toss is input. For example, a possible sample dialog might be: For each coin toss enter either ‘h’ for heads or ‘t’ for tails. First toss: h Second toss: t Third toss: t Fourth toss: h Fifth toss: t Sixth toss: h Seventh toss: t Eighth toss: t Number of heads: 3 Number of tails: 5 Percent heads: 37.5 Percent tails: 62.5
Computers and Technology
1 answer:
shusha [124]3 years ago
3 0

Answer:

Written in Python

head = 0

tail = 0

for i in range(1,9):

     print("Toss "+str(i)+": ")

     toss = input()

     if(toss == 'h'):

           head = head + 1

     else:

           tail = tail + 1

print("Number of head: "+str(head))

print("Number of tail: "+str(tail))

print("Percent head: "+str(head * 100/8))

print("Percent tail: "+str(tail * 100/8))

Explanation:

The next two lines initialize head and tail to 0, respectively

head = 0

tail = 0

The following is an iteration for 1 to 8

<em>for i in range(1,9): </em>

<em>      print("Toss "+str(i)+": ") </em>

<em>      toss = input()  </em><em>This line gets user input</em>

<em>      if(toss == 'h'):  </em><em>This line checks if input is h</em>

<em>            head = head + 1 </em>

<em>      else:  </em><em>This line checks otherwise</em>

<em>            tail = tail + 1 </em>

The next two lines print the number of heads and tails respectively

print("Number of head: "+str(head))

print("Number of tail: "+str(tail))

The next two lines print the percentage of heads and tails respectively

print("Percent head: "+str(head * 100/8))

print("Percent tail: "+str(tail * 100/8))

You might be interested in
Organizational structures with one or more layers of authority between top-level management and employees are known as vertical
r-ruslan [8.4K]

The organizational structure described here, which is known as vertical organizational structure, is also commonly identified as tall organizations.

They usually have hierarchical structures, with the CEO being at the very top of the layer. Tall organization have multiple levels, compared to its counterpart, the flat organization or horizontal, which would only have one level.  

8 0
3 years ago
Read 2 more answers
Which is the shortest and simplest tax form? <br> 1040 long form <br> 1040EZ<br> 1040A<br> 140E
Kay [80]
The answer is 1040EZ. That is the shortest and simplest tax form. 
7 0
3 years ago
Read 2 more answers
Although a tablet can connect to a cellular network, it cannot be used as a
Misha Larkins [42]

Answer:

A tablet can have mobile data such as MetroPCS. But the tablet can not make phone calls or texts.

7 0
3 years ago
Read 2 more answers
Which math ratio represents efficiency?
andrew-mc [135]

Answer:

I think its the second one

6 0
3 years ago
Which statement accurately describes a bitmap graphic?
igomit [66]

Answer:

It uses small dots (usually thousands) to create images and specify colors is the correct answer.

Explanation:

A bitmap graphic is also known as raster, and it is created by putting together rows of pixels. Later, these pixels will form a complete image, that could only be black and white (using only these colors) or similar to a photography (which will lead to use as many colors as necessary). Different programs are used to create bitmap graphics.

4 0
3 years ago
Other questions:
  • Only the _________ can add users with passwords and limit user access to selected areas.
    5·1 answer
  • Which consumer document is most likely to help you if you have trouble figuring out how to operate a device
    6·1 answer
  • 1.
    5·2 answers
  • You have a Bluetooth headset that integrates with your computer so that you can talk to partners through Microsoft Lync. This is
    6·2 answers
  • Many languages do not use the characters of U.S. English. Suppose you wanted to be able to
    15·1 answer
  • Among the second generation home console companies,which managed to come out on top
    10·1 answer
  • Karen works in a department store. Her coworker gave diverse cultural backgrounds. Which statement shows that Karen understand t
    14·1 answer
  • PLEASE HURRY!!!!<br> Look at the image below
    8·1 answer
  • Is it true that if the user log out the computer will turn off automatically​
    9·2 answers
  • How do you get your winkey wet??
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!