Created
March 27, 2018 15:18
-
-
Save edipetres/61ca41b7ffc01dbb5f3857ab7014d4a6 to your computer and use it in GitHub Desktop.
Algorithms Compulsory Assignment 2 - trees
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
RESP_GOOD = 'You should be able to pass the exam.' | |
RESP_BAD = 'You could easily fail the exam.' | |
def decision_tree(): | |
hand_ins_made_on_time = get_answer("Hand-ins made on time?") | |
if hand_ins_made_on_time == True: | |
attend_lectures = get_answer('Attended lectures?') | |
make_exercise = get_answer('Did you make the exercises?') | |
read_textbook = get_answer('Did you read the textbook?') | |
if attend_lectures == False: | |
if make_exercise == False or read_textbook == False: | |
return print(RESP_BAD) | |
return print(RESP_GOOD) | |
else: | |
return print(RESP_BAD) | |
# Asks the user a question and returns True or False based on the result | |
def get_answer(question): | |
res = input(question + ' (y/n)\n') | |
if res == 'y' or res == 'yes': | |
return True | |
elif res == 'n' or res == 'no': | |
return False | |
else: | |
raise Exception('Wrong value given.') | |
decision_tree() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment