Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please write the code in python Mayor's World There is a town in which people can run for mayor if they meet the following two
Please write the code in python
Mayor's World There is a town in which people can run for mayor if they meet the following two qualifications: they are not old they like a fun color or they are in middle school A few definitions: old means: their age is over 30 a fun color is either 'red' or 'green' (color is a string) middle school is one of the following grades: 6,7,8 We will model this situation using a function for each boolean expression. Finish each of the definitions (build a boolean expression that conveys the truth value based on the input): def is_old(age) : return True def fun_color(color): return True def is_middle(grade): return True Create a function named is eligible that returns True or False based on the input parameters and the rules set up above. The function is eligible must call the functions is_old, fun_color, is_middle. Who can by major? The following people are running for mayor: Bob: age 45, likes green, is a 7th grader Pete: age 12, likes white, is in grade 12 Jane: age 14, likes red, is in grade 11 Determine who can run for mayor (e.g. test your code to determine who is eligible): # testing code bob = is_eligible (45, 'green', 7) print(bob) Hints: Do not use any variables (other than the function parameters) inside is_eligible. There is No need to use any variables other than in your test code There is No need to use any if/else or selection statements (we don't know about them yet). Do NOT use the in operator (we have not seen that as well)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started