Hi. I'm trying to make a grade forecasting program for python 2.7.
My problem is that I'm having difficulty trying to correlate the first "grade element" input with the first "grade element percentage" input.

Here's what I have so far.

``````import random

print \
"""
Instructions:
1 - View My Grade List
3 - Edit a Grade Category
4 - Delete a Grade Category
8 - Exit """

x = raw_input("Enter a Grade Category: ")
x = x.upper()
y = int(raw_input("Enter its Percentage: "))
print "Invalid input."
print "The Course should total 100%."
print "You will be able to add extra credit points later."``````

I could not get the real function of this code, so my post is pure guess....

What does it mean "associate" two lists?

If you mean to multiply each element of one list with the other list's respective element and sum them, then (given list1 and list2):
sum(a*b for a,b in zip(list1,list2))

Intuitively I think you have an error. If grade_total is invalid, you add the last y value, but you do not remove the respective grade.

I could not get the real function of this code, so my post is pure guess....

What does it mean "associate" two lists?

If you mean to multiply each element of one list with the other list's respective element and sum them, then (given list1 and list2):
sum(a*b for a,b in zip(list1,list2))

Intuitively I think you have an error. If grade_total is invalid, you add the last y value, but you do not remove the respective grade.

I've figured it out. Thanks though. Please take a look at this and provide some feedback. Thanks!

``````import random

print \
"""\t
◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌
◌ ╔╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╗ ◌
◌ ╚╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╝ ◌
◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌
"""

print \
[Quizzes, Assignments, Exam 1, Participation, Project, Final, etc.]"""

print \
You will be asked to enter its percentage in the syllabus.
\nExamples of PERCENTAGE: [74,92,85,96,etc.]
**Note: This MUST add up to 100%."""

print "\nStep 3, Recieve Your Very Own Forecast!"
print "\nEnjoy!"

x = raw_input("\nEnter a Grade Category [quiz,hw,etc.]: ")
x = x.upper()
print "**Note: The Percentages must add up to 100."
y = int(raw_input("Enter "+x+" % [out of 100]: "))
print "Invalid input."
print "The Course should total 100%."
print "You will be able to add extra credit points later."

raw_input("\nHit Enter To View Your Summary.")
ctr = 0
print "\nOptions: "
i += 1
ctr += 1

ctr = 0
y = []
while (ctr < x):
y.append(ctr)
ctr += 1

burn = []
ctr = 0
scores = []

u = "y"

while (ctr <= x and u == "y"):
choice = int(raw_input("\nWhich of the grade options would you like to fill out (0,1,2,etc): "))
if (choice in y):
print "Example: 100, 95, 81, etc."
user = float(raw_input("\tScore: "))
if user <= 100:
scores.append(user)
burn.append(choice)
y.remove(choice)
ctr += 1
print ""
for i in y:
u = raw_input("Would you like to enter another one of your scores? Y/N? ")
u = u.lower()
if (u == "n"):
raw_input("\nHit Enter To View The Results.")

else:
print "Please enter a percentage between 0-100."

elif (choice in burn):
elif (choice not in burn and choice not in y):
print "\nInvalid input."

ctr = 0
ctr2 = 0
ctr3 = len(burn)
scores_pct = []
while (ctr < ctr3):
indiv_score = float(scores[ctr])
position2 = burn[ctr]
calc = float(indiv_score * position / 100)
scores_pct.append(calc)
ctr += 1

ctr = 0
y2 = []

# remover
while (y != []):
b = y.pop(0)
y2.append(b)

i += 1
ctr += 1

ctr = 0
abc = float()
ab = float()
calc = float()

while (ctr < len(burn) and scores_pct != []):
xy = burn[ctr]
abc = float(scores_pct.pop(0))
ab += abc
ctr += 1

calc *= 100

print "Now for the Grade Forecast.."
u = 1
optimism = int(0)
while (u != 0):
optimism = raw_input(\
"""\nOn a scale of 1-5..

Enter 1 if you plan to slack off.
Enter 2 if you're feeling somewhat pessimistic
Enter 3 if you're neutral.
Enter 4 if you're feeling good about the remainder.
Enter 5 if your grades are only going UP UP and AWAY!

I feel: """)

if optimism == "1":
factor = random.uniform(0.862,0.873)
forecast = calc*factor/100
forecast += ab
raw_input("Hit Enter To View Your Forecast.")
u -= 1
elif optimism == "2":
factor = random.uniform(0.951,0.965)
forecast = calc*factor/100
forecast += ab
raw_input("Hit Enter To View Your Forecast.")
u -= 1
elif optimism == "3":
factor = random.uniform(0.989,1.01)
forecast = calc*factor/100
forecast += ab
raw_input("Hit Enter To View Your Forecast.")
u -= 1
elif optimism == "4":
factor = random.uniform(1.022,1.036)
forecast = calc*factor/100
forecast += ab
raw_input("Hit Enter To View Your Forecast.")
u -= 1
elif optimism == "5":
factor = random.uniform(1.073,1.0827)
forecast = calc*factor/100
forecast += ab
raw_input("Hit Enter To View Your Forecast.")
u -= 1
else:
print "Please enter a value between 1-5."

raw_input("Enter to exit.")``````

It is way too long. User input, output and logic is not separated.
If you are interested I can look at it, and make some changes to it.
Are you?

To start you off, look for redundant statements, like all of the if/elif at the end of the program that basically do the same thing. They can be replaced by a simple dictionary of values.

``````## The following 3 lines can be deleted for this example
#u = 1
#optimism = int(0)
#while (u != 0):
factor_dict = {"1": [0.862, 0.873],
"2": [0.951,0.965],
"3": [0.989,1.01],
"4": [1.022,1.036],
"5": [1.073,1.0827]}
optimism = ""
while optimism not in factor_dict:
optimism = raw_input(\
"""\nOn a scale of 1-5..

Enter 1 if you plan to slack off.
Enter 2 if you're feeling somewhat pessimistic
Enter 3 if you're neutral.
Enter 4 if you're feeling good about the remainder.
Enter 5 if your grades are only going UP UP and AWAY!

I feel: """)

if optimism in factor_dict:
factor = random.uniform(factor_dict[0], factor_dict[1])
forecast = calc*factor/100
forecast += ab
raw_input("Hit Enter To View Your Forecast.")
else:
print "Please enter a value between 1-5."``````

You are correct woooee, but the style of lines 12-13 I would like to write:

``````optimism = raw_input("""
On a scale of 1-5..``````

Your code is not bullet proof. its far from ok.

And i was thinking why dont you break them apart into methods in a class. It will be more handy and easy to work on it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.