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
What should a web page designer consider when choosing between fixed positioning and absolute positioning?
nexus9112 [7]

Answer:

Fixed positioning is relative to the browser window, while absolute positioning is located at a specific place on a web page.

7 0
3 years ago
Typically , how do people earn income
natima [27]
People earn income by getting jobs and working. When they work, they get paid. That's an income
3 0
3 years ago
Read 2 more answers
a _____ is a recreation of a thumbnail in a desktop publishing software, also known as a "rough". a. proof b. digital draft c. l
Dmitrij [34]
D. It’s a sketch. That is, if you talking about, an art piece.
6 0
3 years ago
During the reconnaissance step of the attack, what open ports were discovered by Zenmap? What services were running on those por
Setler [38]

Answer:

Following are the solution to the given question:

Explanation:

It sends commands to its Nmap executable platForm, which is used to specified and retrieves the production. The  ZenMap utilizes templates, which are primarily Nmap.

The parameter templates to decide how scans become formed Several ports, like ports, are available: 11, 21, 22, 25, 53, 445, and 3306, all of which run TCP: Linux services, SMTP Postfix, Apache Tomcat/Coyote JSP.

5 0
3 years ago
Which relationship is possible when two tables share the same primary key?
jek_recluse [69]

The answer to this problem is A, one-to-one.

8 0
3 years ago
Read 2 more answers
Other questions:
  • 10. Which of these is not an HTTP verb? PUT AJAX GET DELETE
    12·1 answer
  • ​some forms use a _____ that contains icons or buttons that represent shortcuts for executing common commands.
    14·1 answer
  • During what months do most people file their taxes?
    6·2 answers
  • Which of the following is not a common network architecture type?
    9·1 answer
  • What is a recent technological breakthrough with an impact that can be compared to the invention of paper nearly 2,000 years ago
    8·1 answer
  • Which organization plays a key role in development of global health informatics?
    9·1 answer
  • The model for Diminishing Marginal Utility is ______ in nature.
    12·1 answer
  • What software maintain and increase the efficiency of a computer system?
    12·1 answer
  • What output is generated by this for loop?
    6·1 answer
  • How to print<br> 1<br> 321<br> 54321<br> 7654321<br> triangle pattern in python
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!