Entering a percentage to a grade | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Entering a percentage to a grade

would you make variables first, and create and input?

23rd May 2017, 6:40 PM
Talia Pacelli
Talia Pacelli - avatar
5 Answers
+ 6
First, you might want to tell us the language you're using. Second, I would use an if/else structure to check if a value is in range: grade = 95 if grade >= 90 and grade <= 100: print('A')
23rd May 2017, 7:09 PM
David Hutto
David Hutto - avatar
+ 2
More information is needed. Are you adding a new percentage to a literal already existing in the code? Does the user enter an original total and enters a second added one? Either way, yes, you need variables and inputs. Gotta save the input from the user somewhere. lol
23rd May 2017, 7:00 PM
Sapphire
+ 2
I'm having a hard time figuring out how the variables are suppose to be written. So I want to be able to enter an percentage input and the output would be a letter grade. example if I got a 95 i want my output to be A
23rd May 2017, 7:02 PM
Talia Pacelli
Talia Pacelli - avatar
+ 1
You'll need conditional operators. This is a very very basic example below. You can always change and add more conditional statements. Disclaimer! No one pick on me on what the letters mean. We don't use them in this part of Canada so it was just guesses. lol xD Here's an example: u_input = int (input("Enter a percentage: )) if u_input >= 90: print ("A") elif u_input > 80: print ("B") else: print ("F")
23rd May 2017, 7:11 PM
Sapphire
+ 1
python is the language sorry.
23rd May 2017, 7:11 PM
Talia Pacelli
Talia Pacelli - avatar