In this sharing algorithm the prospectors take it in turns to get gold nuggets. Write a function called turns(n) to calculate the amount of gold that each prospector gets, and to display this in Turtle Graphics. Your function should look something like this pseudocode version. The function should have a single parameter, the number of gold nuggets to be shared between the prospectors. I expect that you will want to write other functions that are called by turns (to move the turtle, draw squares and so on).
set p1's gold to 0
set p2's gold to 0
for a given number of nuggets
set nugget to a random number between 10 and 100 (its value)
if it is prospetor1's turn
add nugget to p1
display prospector1's nugget
else
add nugget to p2
display prospector2's nugget
Here is what i have got, but i do not know how to take turns and show the result of each player
set p1's gold to 0
set p2's gold to 0
for a given number of nuggets
set nugget to a random number between 10 and 100 (its value)
if it is prospetor1's turn
add nugget to p1
display prospector1's nugget
else
add nugget to p2
display prospector2's nugget
Here is what i have got, but i do not know how to take turns and show the result of each player
Code:
x = 0
y = 0
import turtle
import random
def gold(side_length):
turtle.forward(side_length)
turtle.left(90)
turtle.forward(side_length)
turtle.left(90)
turtle.forward(side_length)
turtle.left(90)
turtle.forward(side_length)
def nugget():
import random
print random.randint(10,100)
def turn():
if
Comment