kevinho00

none

kevinho00 #Chat Talk

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

Help with python I've been trying to write a python code for a function coinFlipUntilWinMTimes(M, side) that returns the number of coin flip trials required in order to get M trails to result in side (which is either heads or tails). The results of calling my function will look something like this: >>>coinFlipUntilWinMTimes(4, 'Heads') #it took 7 coin flip trials to get 4 'Heads' 7 this is what I tried: [url=http://imgur.com/iUEfmKf][img]http://i.imgur.com/iUEfmKf.png[/img][/url] I ran in from the script and called the function but got no results any help is greatly appreciated

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

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

basic python help Can anyone help me write a code for these questions? 1. program that requests a list of student names from the user and prints those name that start with letters A through M list:['Ellie','Steve','Sam','Owen','Gavin'] for this one I manually did for name in list: >if 'A'in name: >>print(name) from A to M. I'm sure there's a better way to do it though. 2. implement a function abbreviation() that takes a day of the week as input and returns its two-letter abbreviation >>>abbreviation('Tuesday') 'Tu' I have no idea how to do this one