Answered step by step
Verified Expert Solution
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started