0

Citizen selector program help

I'm trying to create a "citizen selector" program which basically prompt user to enter 4 inputs, name , health score (0-100), economic output (0-100), and grade(a-f). if they meet conditions like for example if their grade = a and economic output >=85. they shud get a prompt saying they met the criteria. if their health and and economic output =65 and their grade = at least a "c" they meet the criteria how shud I go on doing this. shud I use if statements?

3rd Apr 2017, 11:53 AM
Kudzai Machakanja
Kudzai Machakanja - avatar
4 odpowiedzi
+ 2
Hello, You can use a few nested ifs (if+elif+else) , every if can have all 4 conditions of your inputs with "and" and "or" . You can also prompt the user to enter a new input after every cycle of the program-making the whole code into a sort of endless loop
3rd Apr 2017, 12:11 PM
matan
+ 1
Hello, Below are some hints by using if-elif-else loop. First define variables; then use if-elif-else loop with combination conditions as required. Please note that you need to use "int()" to converse score variables into integer, otherwise you cannot compare the result of input() with integer from user's input. # citizen selector program name = input("Please enter your name here: ") health_score = int(input("Please enter your health score: ")) economic_output = int(input("Please enter your economic output here: ")) grade = input("Please enter your grade here: ") if grade == "a" and economic_output >= 85: print("A") elif grade == "b" and economic_output >=65 and economic_output < 85: print("C")
6th Apr 2017, 10:35 PM
Jeff
Jeff - avatar
0
this is what I've done so far. sorry my code looks "amateurish". the bit I'm really struggling with is whenever I enter any letter as my grade, I get an error saying something on the line of "A not defined". can you help me with this . I'm using Python 2.7 by the way https://code.sololearn.com/cnqm1Mt3W9LZ/?ref=app
4th Apr 2017, 8:30 AM
Kudzai Machakanja
Kudzai Machakanja - avatar
0
@jeff ive written the programme above. the issue im having is whenever i get the grade prompt and input a letter i keep getting "grade" is not defined. would you mind helping me with that
18th Apr 2017, 2:58 PM
Kudzai Machakanja
Kudzai Machakanja - avatar