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
I'm gonna get grounded for getting a 52 on my test :(
Alla [95]

Answer:

well thats not good

Explanation:

5 0
3 years ago
Simple Java programming
Softa [21]

I found the same answer on

g.o.o.g.l.e

3 0
3 years ago
Read 2 more answers
The set of folders and subfolders that MATLAB searches through to locate a command or M-file is called the ___________.(fill in
Oduvanchick [21]

Answer:

<u>path</u>

Explanation:

The sub-folders and folders set that MATLAB searches through in order to locate M-file or a command is known as the path.

These files are stored in the user path which is stored in the user path directory in it.

We usually run the function , i.e., user path function in order to know the location of the folder stored or command or the M-file.

7 0
3 years ago
What are the different between Facebook and LinkedIn
DIA [1.3K]
Face you can talk to friends post picture's and see pictures of friends i am not really sure what is linkedln
7 0
3 years ago
Read 2 more answers
How does Python recognize a tuple?
Maru [420]

Answer:

You use parentheses around the data values.

Explanation:

j took the test on edge

4 0
3 years ago
Other questions:
  • If your DTP document contains watermarks on every page, where can you place them?
    13·2 answers
  • What is PHP language
    12·1 answer
  • In this digital age of rapid communications, how can you justify the time it takes to stop and revise a message
    10·1 answer
  • A file extension of .xlsx means that the file contains what? *
    12·2 answers
  • Line spacing refers to the amount of space between each line in a paragraph. A. True B. False
    14·2 answers
  • Create a Python program that: Allows the user to enter a person's first name and last name. The user should be able to enter as
    12·1 answer
  • Which one you choosing? PS5 OR THE XBOX SERIES X???
    14·2 answers
  • The ______ engine compares your entry against its database and returns a list of hits or sites that contain the keywords. (hint:
    8·1 answer
  • What is the accurate description
    12·1 answer
  • Array bounds checking should be directly coded into a system rather than assumed.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!