Repeat the exercise in the task 3 (version 2), where in addition you need to ask the user for their citizenship and if they are currently in prison convicted for a criminal offence. Your program should print a nice message telling the user if they are eligible to vote (i.e. if they are 18+, Canadian and do not live in prison convicted for a criminal offence, then they can vote. Otherwise not). You should modify function is_eligible so it takes to additional paramters as input. In particular the head of the function should be: is_eligible(age, citizenship, prison)

Respuesta :

Using knowledge in phyton it is possible to write code that uses program should print a nice message telling the user if they are eligible to vote.

Writting in python:

def is_eligible(age, citizenship, prison):

 # Converting the inputs into lower for validation

 citizenship = citizenship.lower()

 prison = prison.lower()

 # 18+ Canadian and do not live in prison can vote

 if(age >= 18 and prison == "yes" and (citizenship == "canada" or citizenship == "Canadian")):

   return True

 return False

# Implement your I/O here

# getting required inputs from user

citizenship = input("Please Enter your Citizenship: ")

prison = input("Please Enter if you are in prison YES/NO: ")

age = int(input("Please Enter your Age: "))

is_eligible = is_eligible(age, citizenship, prison)

if is_eligible:

 print("Congratulations, You are eligible to Vote!!")

else:

 print("Sorry, You can't Vote")

See more about python at brainly.com/question/18502436

#SPJ1

Ver imagen lhmarianateixeira
ACCESS MORE
EDU ACCESS