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))
Step-by-step 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
for i in range(1,9):
print("Toss "+str(i)+": ")
toss = input() This line gets user input
if(toss == 'h'): This line checks if input is h
head = head + 1
else: This line checks otherwise
tail = tail + 1
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))