kevinho00

none

General Chat

python help so I'm trying to find this function Write a function that estimates the probability of getting M or more heads out of N fair coin flips (by fair we mean the coin has equal chance of turning up heads or tails), repeating this sequence of flips a total of nTrials times. To perform this experiment, you should define a helper function coinFlipTrial(M, N) that performs one sequence of N coin flips and returns True if the number of heads is greater than or equal to M, and False otherwise. A test you can use for your functions is to estimate the probability of getting 8 or more heads out of 10 coin flips, which should be around 5 percent (0.05). What i got: import random lst = ['Heads', 'Tails'] def coinFlipTrial(M, N): count = 0 for i

General Chat

python turtle question I made a function for a random turtle race when turtle1(Tom) is in front of turtle2(Amy) it becomes green and vise versa My code is this: import turtle import random tom = turtle.Turtle('turtle') amy = turtle.Turtle('turtle') myScreen = turtle.Screen() def setup(tom, amy, myScreen): myScreen.setworldcoordinates(0,0,50,50) tom.up() amy.up() tom.setposition(1,25) amy.setposition(1,25) tom.color('red') amy.color('red') tom.down() amy.down() myScreen.exitonclick() def newHeading(turtle, angleOfTipsiness): angleOfTipsiness = 70 tom.setheading(random.randint(-angleOfTipsiness, angleOfTipsiness)) amy.setheading(random.randint(-angleOfTipsiness, angleOfTipsiness)) def newColor(tom, amy): if tom.xcor() >= amy.xcor: tom.colo

General Chat

python help Can anyone help me on this python question? I am lost on how to solve this statement(LTransactions) - returns(totalWithdrawals,totalDeposits) Write a function that takes as input a list of floating point numbers (or ints), LTransactions, representing deposits (positive numbers) and withdrawals (negative numbers). A two item list should be returned with entries totalWithdrawals, the sum of all withdrawals, and totalDeposits, the sum of all deposits. The following result when run should return a statement like this >>>statement([30.95, -15.67, 45.56, -55.00, 43.78]) [-70.67, 120.29] the totalWithdrawals is the sum of all the negative transactions while the totalDeposits are the sum of all the positive ones

Show me more!