#SAT_M = [54: 800, 25: 500, -2:200] #M_wrong = float(raw_input("How many math questions did you get wrong in the first math section?")) #M_wrong = M_wrong + float(raw_input("How many math questions did you get wrong in the second math section?")) #M_wrong = M_wrong + float(raw_input("How many math questions did you get wrong in the third math section?")) def tally(number_of_sections, right_or_wrong): ##Takes the number of sections and prompts user for number of right/wrong answers in each. Returns tally. ##Input: number_of_sections = int, right_or_wrong = string tally = 0 for number in range(number_of_sections): question = "How many questions did you get ", right_or_wrong, "in section number ", number, "?" tally = tally + int(raw_input(question)) print tally return tally def wrong_ans_deduction(tally_wrong): tally_wrong = tally_wrong + 2 #exploits Python's floor division to mimic the effect of rounding deduction = tally_wrong / 4 section = raw_input("Which section do you want to score?") if section == "writing": number_of_sections = 2 else: number_of_sections = 3 tally_right = tally(number_of_sections, "right") tally_wrong = tally(number_of_sections, "wrong") raw_score = tally_right - wrong_ans_deduction(tally_wrong) #print raw_score
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question