Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

here is my code in python, but i am getting an error. from random import random def CoinTossCount(numTosses): headsCount=0; tailsCount=0; for i in range(1,numTosses+1): flip=int(random()*2)

here is my code in python, but i am getting an error. from random import random def CoinTossCount(numTosses): headsCount=0; tailsCount=0; for i in range(1,numTosses+1): flip=int(random()*2) +1; if flip==1: headsCount +=1; else: tailsCount +=1; print('Number of heads: ' + str(headsCount)) print('Number of tails: ' + str(tailsCount)) CoinTossCount(40); here is the error i am getting, print('Number of heads: ' + str(headsCount)) NameError: name 'headsCount' is not defined

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

What is the meaning of fiduciary obligation?

Answered: 1 week ago

Question

=+Where does the focus of labor relations lie? Is it collective

Answered: 1 week ago

Question

=+With whom does the firm have to negotiate?

Answered: 1 week ago