Anyways, here is a recent practice problem. All three teams were able to pseudocode or flowchart the general algorithm OK, but only one was able to put it to code within the time limit. I work alone to try and solve the problems myself while they work, and I find the challenge of it quite fun.
2 Beginning — Probability
Below are the probabilities for desired outcomes for each six different football games:
Game number 0 1 2 3 4 5
Probability 0.5 0.4 0.6 0.75 0.3 0.83
Some combination of these outcomes must occur in order for a certain team to make the playoffs. Write a program that takes as input a nonnegative integer n giving the number of relevant games, then n different game numbers. It then outputs the probability that all n of these games have the desired outcome, assuming the above probabilities and that the games are independent. In order to compute this probability, you will need to multiply together all of the probabilities for the selected games (if no games are selected, the probability is 1). You may assume that 0 _ n _ 6 and that the n game numbers are all valid and distinct.
prob = [.5,.4,.6,.75,.3,.83]
def probcalc():
gamenum = int(input("How many games?"))
probag = 1
if gamenum <= 0:
print(1)
else:
for i in range(gamenum):
probag *= prob[int(input("Game Number:"))]
print(probag)
probcalc()
How many teams can you bring? Are they leveled (A team B team?)?
ReplyDeleteIn general I like it when the kids have to work in teams. The only downside is that to do their best they have to practice as a unit and if you have LOTS of kids it could mean directing your energies to the few rather than the many.