I am working on an assignment that involves simulating a volley ball game and I have NO idea. Can anyone help.
Here is the question
OK, so i have worked on it a bit and have developed some code but am having problems with defining when the game should stop because the winning player needs to wins by 2 points and the highest score needs to be atleast 15. here is my code so far
def main (): print Intro () probA, probB, n = getInputs () winsA, winsB = simNGames (n, probA, probB) printSummary (winsA, winsB) def Intro (): print "This program simulates a gsme of volleyball between" print "two players called A and B." print "player A always has the first serve" def getInputs (): a = input ("Player A wins a serve") b = input ("Player B wins a serve") n = input ("How many games do you want to simulate?") return a, b, n def simNGames(n, probA, probB) : winsA= winsB = 0 for i in range(n): scoreA, scoreB = simOneGame (probA, probB) if scoreA > scoreB: winsA =winsA + 1 else: winsB = winB + 1 return winsA, winsB def simOneGame (probA, probB): serving= "A" scoreA = 0 scoreB = 0 while not gameOver (scoreA, scoreB): if serving == "A": if random () < probA: scoreA = scoreA + 1 else: serving = "B" else: if random() < probB: scoreB = scoreB + 1 else: serving = "A" return scoreA, scoreB def gameOver(a, b): if (a - b) > 2 or < -2 def printSummary(winsA, winsB): n= winsA + winsB print "\nGames simulated", n print "Wins for A: %d (%0.1f%%)" % (winsA, float(winsA)/n*100) print "Wins for B: %d (%0.1f%%)" % (winsB, float(winsA)/n*100) if __name__=='__main__':main()
I am developing a simple job card creator application with VB.net 2012, using Access 2010 as database.
The code I have generated to write data from a datagridview to the database table is successfully saving the data, but with an error "Parameter @name has no default value". The ...
write a C++ program which take inputs from the user/keyboard and calculate his ZAKAT.
get the input from user may include
-Amount invested in business
-Amount given to other business partners as loan
-Amount payable to others
I made a prime number finder, it finds the nearest prime that is above and below any integer (Does not work that well with giant numbers.)
Made this in cpp.sh
Why would I need the x=y+1-1;?
x=y; just doesnt seem to work
Why is this?
And I know my coding ...