Python Forum
How to make a dynamic variable based on input
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to make a dynamic variable based on input
#1


Okay so I'm working on this super basic program for my AP Comp Sci class, and I've only just recently started Python so I'm a little lost. I'm making a program in which a student can enter their current grade and then, depending on what grade they would like to end the class with, they are told what grade they need to make on their final exam. Here is my code as it stands:

---------------------------------------------------------------------

cGrade = int(input("What is your current grade in the class?"))
cGrade = cGrade * 4 #to fit the formula to find exam grade needed
A = 450 - int(cGrade)
B = 400 - int(cGrade)
C = 450 - int(cGrade)
D = 300 - int(cGrade)

fGrade = input("What letter grade would you like to end with?")

---------------------------------------------------------------------

(We're working exclusively in PythonRoom right now if that is important)

I want fGrade, the user input, to be entered as a letter grade. So for example if they want their final grade to be A, the program will say something like

if variable(user input = A):
print("In order to end with an A, you will need to score ") + A + (" on your final exam.")

I hope this was clear, as I said I'm super new so I'll take all the tips y'all have to offer.
Reply


Messages In This Thread
How to make a dynamic variable based on input - by loltylerdowney - Nov-29-2017, 06:44 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to calculate tax with a variable input and if else afefDXCTN 12 22,938 Mar-15-2024, 01:58 AM
Last Post: nave
Question Simulate an answer based on user input [Beginner needs guidance] Bombardini 1 1,288 Nov-12-2022, 03:47 AM
Last Post: deanhystad
  [split] How to calculate tax with a variable input and if else rokemas 1 2,126 Dec-28-2020, 06:53 AM
Last Post: buran
  Changing Directory based on user input paulmerton4pope 13 8,053 Aug-14-2020, 11:48 AM
Last Post: GOTO10
  How to make a variable contain multiple values stevenjwilliams83 10 3,552 Apr-30-2020, 07:22 AM
Last Post: pyzyx3qwerty
  Writing a function that changes its answer based on user input SirRavenclaw 2 2,818 Dec-21-2019, 09:46 PM
Last Post: Clunk_Head
  New to Python - tiny coding assistance on user input function and assign to variable Mountain_Duck 1 2,516 Mar-23-2019, 06:54 PM
Last Post: Yoriz

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020