Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Vairables
#4
I am attempting to obtain the weighted grade categories and their weight value; however, the number of categories are not defined (no pun intended). This means that the iteration will loop based on the number input by the user. For example, the program will ask "how many categories?". If the user indicates 5 categories, then I want the program to create 5 variables for those categories. If the user input 9 categories, then there will need to be 9. My question is there a way to program these variables based on the number of categories without having a fixed number of variables. I can easily tell my basic program to have 5 variables in a somewhat static state, but what if the weighted categories are 9, instead of 5. Hope this helps to understand my problem.

Sorry I cannot produce any code, because I haven't written the code yet...I am only in my 4th week of learning Python...professor is asking to develop pseudo code for calculating weighted grades; however, I cannot get to the next step in my planning if I don't understand the constraints of the language.

Something just came to me. Can I build a loop that has a range of available variables, for example a-z, and assign those variables to the user-input categories based on a number input by the user?

For example -

pseudo code:
define a-z as available variables

input "How many categories?"

#User inputs x number of categories

#x of the range of variables are assigned to the user input categories


What do you think?
Reply


Messages In This Thread
Vairables - by Phynomeagle - Feb-05-2019, 02:54 PM
RE: Vairables - by Larz60+ - Feb-05-2019, 03:29 PM
RE: Vairables - by ichabod801 - Feb-05-2019, 03:51 PM
RE: Vairables - by Phynomeagle - Feb-05-2019, 04:01 PM

Forum Jump:

User Panel Messages

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