Skip to content

Instantly share code, notes, and snippets.

@JudoWill
Created November 8, 2012 04:25
Show Gist options
  • Save JudoWill/4036785 to your computer and use it in GitHub Desktop.
Save JudoWill/4036785 to your computer and use it in GitHub Desktop.
Simple script
nbowlers = 5
nscores = 3
team_score = 0
for bowlernum in range(nbowlers):
bowler_scores = []
for game_num in range(nscore):
prompt_string = “Please enter Bowler %i’s game score in game %i: \n” % (bowlernum+1, game_num+1) #because counting starts at zero
score = int(raw_input(prompt_string))
bowler_scores.append(score) #keep track of this bowler
team_score += score #keep track of team
print 'Bowler %i had scores of: %s' % str(bowler_scores)
bowler_avg = sum(bowler_scores)/nscores
print 'Bowler %i had an average score of %f' % (bowler_num+1, bowler_avg)
team_avg = team_score/(nbowlers*nscores)
print "The team average is %f" % team_avg
#table stuff
populations = [5000] #starting with 5,000 people
food = [10000] #and food for 10,000
for year in range(50):
cur_pop = populations[-1]
next_pop = cur_pop*1.5 #getting bigger by 50%
populations.append(next_pop)
cur_food = food[-1]
next_food = cur_food*1.2 #only grows by 20%
food.append(next_food)
if next_food < cur_pop:
break
print zip(populations, food)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment