Created
April 12, 2015 06:51
-
-
Save drldcsta/3adcf26176f925f365e9 to your computer and use it in GitHub Desktop.
Crispy's C# homework in Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AirBoxOmega:Projects d$ python crispy.py | |
What is the Diver's name? Darrell | |
What is the Diver's city? W.Village | |
What is the Diver's difficulty? 3 | |
What is Judge 1's score?? 10 | |
What is Judge 2's score?? 1 | |
What is Judge 3's score?? 4 | |
What is Judge 4's score?? 5 | |
What is Judge 5's score?? 6 | |
[4, 5, 6] | |
15 | |
5.0 | |
15.0 | |
Darrell from W.Village's score is 15 which is 5 * 3 | |
Want to go again? y/n? y | |
What is the Diver's name? Crispy | |
What is the Diver's city? BK | |
What is the Diver's difficulty? 5 | |
What is Judge 1's score?? 9 | |
What is Judge 2's score?? 2 | |
What is Judge 3's score?? 3 | |
What is Judge 4's score?? 4 | |
What is Judge 5's score?? 5 | |
[3, 4, 5] | |
12 | |
4.0 | |
20.0 | |
Crispy from BK's score is 20 which is 4 * 5 | |
Want to go again? y/n? n | |
AirBoxOmega:Projects d$ cat crispy. | |
crispy.py crispy.sublime-project crispy.sublime-workspace | |
AirBoxOmega:Projects d$ cat crispy.py | |
#!/usr/bin/python | |
#Set a variable that says the comp is in progress | |
comp_in_prog = True | |
#Start a loop that goes for as long as it's true the comp is in progress | |
while comp_in_prog: | |
#This is creating an array called diver(list) with 2 arrays inside of it | |
#the 0th element of the array has 3 itens | |
#the 1st element of the array has 5 items | |
diver = [[None] * 3 , [None] * 5] | |
#Get the diver's name | |
diver_name = raw_input("What is the Diver's name? ") | |
#get the diver's city | |
diver_city = raw_input("What is the Diver's city? ") | |
#get the diver's difficulty rattng (make it an int) | |
diver_diff = int(raw_input("What is the Diver's difficulty? ")) | |
#create an array with 5 elements and then make each element the judges score | |
#this could be done by assigning the scores directly, but this looks neater | |
diver_score = [None] * 5 | |
diver_score[0] = raw_input("What is Judge 1's score?? ") | |
diver_score[1] = raw_input("What is Judge 2's score?? ") | |
diver_score[2] = raw_input("What is Judge 3's score?? ") | |
diver_score[3] = raw_input("What is Judge 4's score?? ") | |
diver_score[4] = raw_input("What is Judge 5's score?? ") | |
#use a loop to insert the judgest scores into the 1st element of the diver array | |
for i in xrange(0,5): | |
diver[1][i] = int(diver_score[i]) | |
#print the 1st to next to last element of the array diver after it's been sorted | |
#This is the same as dropping the high and low score | |
#just for debut | |
print sorted(diver[1])[1:-1] | |
#print sum of the above, again just for debug | |
print sum(sorted(diver[1])[1:-1]) | |
#Calculate the avg | |
judge_avg = float(sum(sorted(diver[1])[1:-1]) / 3 ) | |
#print the avg for debug | |
print judge_avg | |
#the score is the avg times the difficulty | |
score = judge_avg * diver_diff | |
#print score | |
print score | |
#print the results | |
print "%s from %s's score is %i which is %i * %i" % (diver_name,diver_city,score,judge_avg,diver_diff) | |
#Prmpt user to find out if there's another diver | |
keep_going = raw_input("Want to go again? y/n? ") | |
if keep_going == "y": | |
comp_in_prog = True | |
else: | |
comp_in_prog = False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment