1. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Apr 2013
Posts
6
Rep Power
0

I am stuck on this assignment and it is driving me nuts.

You will write a program that will use two functions:

computeMetric - this function will compute a metric based on grades from specific classes. This function will take four parameters (the four class scores) and will return a single floating point metric value. The multiplier for each class is also shown. Multiply each class grade by its factor, then return the sum of the classes.
ENG101 (.5)
ENG210 (1.5)
CMST210 (.75)
CMST340 (1.25)

printStudent - this function will take 5 parameters and print the name, class scores and computed metric. It will compute the metric by calling the computeMetric function. This function should print with tabs between each element. (i.e. Brian Kamp 4.0 3.0 3.5 2.0 Metric:11.625) The five parameters are:
name (str)
ENG101 (float)
ENG210 (float)
CMST210 (float)
CMST340 (float)

Your main program should ask the user input for name, English 101 score, English 210 score, Comm Studies 210 and Comm Studies 340. It will then print out the information by calling the printStudent function (above).

I have this so far....

def computeMetric(ENG101, ENG210, CMST210, CMST340):
metric = ENG101 * .5 + ENG210 * 1.5 + CMST340 * .75 + CMST340 * 1.25

2. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Apr 2013
Posts
4
Rep Power
0
Do you still need help?
This is a fairly simple program, all you need is your basic arithmetic
3. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Apr 2013
Posts
6
Rep Power
0
Do you still need help?
This is a fairly simple program, all you need is your basic arithmetic
yes i do still need help.

This is what I have so far...

def computeMetric(ENG101, ENG210, CMST210, CMST340):
metric = ENG101 * .5 + ENG210 * 1.5 + CMST340 * .75 + CMST340 * 1.25

name = str(input("Enter Student's Name:"))
ENG101 = float(input("Enter English 101 Score:"))
ENG210 = float(input("Enter English 210 Score:"))
CMST210 = float(input("Enter Comm Studies 210 Score:"))
CMST340 = float(input("Enter Comm Studies 340 Score:"))

print(name, ENG101, ENG210, CMST210, CMST340)

I am just trying to get the computed Metric back after i enter the name and grades
4. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Apr 2013
Posts
4
Rep Power
0
Originally Posted by newtothis1

I am just trying to get the computed Metric back after i enter the name and grades
Do you want the user to enter it himself like: computeMetric(78, 90, 45, 21) or do you want to present him the metric just from the input
5. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Apr 2013
Posts
6
Rep Power
0
Do you want the user to enter it himself like: computeMetric(78, 90, 45, 21) or do you want to present him the metric just from the input
just from inputting the 4 class scores when asked to type them in
6. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Apr 2013
Posts
4
Rep Power
0
Originally Posted by newtothis1
just from inputting the 4 class scores when asked to type them in
name = raw_input("Enter Student's Name:")
ENG101 = float(input("Enter English 101 Score:"))
ENG210 = float(input("Enter English 210 Score:"))
CMST210 = float(input("Enter Comm Studies 210 Score:"))
CMST340 = float(input("Enter Comm Studies 340 Score:"))
metric = ENG101 * .5 + ENG210 * 1.5 + CMST340 * .75 + CMST340 * 1.25
print(name, ENG101, ENG210, CMST210, CMST340)
print "Metric = " + str(metric)

that seems to work, do you need it in a function?

EDIT: heres the function if you want it
Code:
```def Grading():
name = raw_input("Enter Student's Name:")
ENG101 = float(input("Enter English 101 Score:"))
ENG210 = float(input("Enter English 210 Score:"))
CMST210 = float(input("Enter Comm Studies 210 Score:"))
CMST340 = float(input("Enter Comm Studies 340 Score:"))
metric = ENG101 * .5 + ENG210 * 1.5 + CMST340 * .75 + CMST340 * 1.25
return str((name, ENG101, ENG210, CMST210, CMST340)) + "\n"+ "Metric = " + str(metric)
7. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Apr 2013
Posts
6
Rep Power
0
name = raw_input("Enter Student's Name:")
ENG101 = float(input("Enter English 101 Score:"))
ENG210 = float(input("Enter English 210 Score:"))
CMST210 = float(input("Enter Comm Studies 210 Score:"))
CMST340 = float(input("Enter Comm Studies 340 Score:"))
metric = ENG101 * .5 + ENG210 * 1.5 + CMST340 * .75 + CMST340 * 1.25
print(name, ENG101, ENG210, CMST210, CMST340)
print "Metric = " + str(metric)

that seems to work, do you need it in a function?
I have tried what you have written and it gives me invalid syntax error after "Metric = "
8. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Apr 2013
Posts
4
Rep Power
0
Originally Posted by newtothis1
I have tried what you have written and it gives me invalid syntax error after "Metric = "
its working perfectly for me..
which version are you using, not exactly an expert but that might be it.
and try this
Code:
```def Grading():
name = raw_input("Enter Student's Name:")
ENG101 = float(input("Enter English 101 Score:"))
ENG210 = float(input("Enter English 210 Score:"))
CMST210 = float(input("Enter Comm Studies 210 Score:"))
CMST340 = float(input("Enter Comm Studies 340 Score:"))
metric = ENG101 * .5 + ENG210 * 1.5 + CMST340 * .75 + CMST340 * 1.25
return str((name, ENG101, ENG210, CMST210, CMST340)) + "\n"+ "Metric = " + str(metric)
9. Yes, one of you uses python2 and newtothis1 uses python3.
10. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Apr 2013
Posts
6
Rep Power
0
its working perfectly for me..
which version are you using, not exactly an expert but that might be it.
and try this
Code:
```def Grading():
name = raw_input("Enter Student's Name:")
ENG101 = float(input("Enter English 101 Score:"))
ENG210 = float(input("Enter English 210 Score:"))
CMST210 = float(input("Enter Comm Studies 210 Score:"))
CMST340 = float(input("Enter Comm Studies 340 Score:"))
metric = ENG101 * .5 + ENG210 * 1.5 + CMST340 * .75 + CMST340 * 1.25
return str((name, ENG101, ENG210, CMST210, CMST340)) + "\n"+ "Metric = " + str(metric)
i am using python 3.3 and i just tried this and it says invalid syntax and highlights Grading in red on the bottom
11. You've been given so much help please take it upon yourself to rewrite
metric = ENG101 * .5 + ENG210 * 1.5 + CMST340 * .75 + CMST340 * 1.25
as a dot product.

metric = dot(weights, grades) # something like this
12. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Apr 2013
Posts
6
Rep Power
0
Originally Posted by b49P23TIvg
You've been given so much help please take it upon yourself to rewrite
metric = ENG101 * .5 + ENG210 * 1.5 + CMST340 * .75 + CMST340 * 1.25
as a dot product.

metric = dot(weights, grades) # something like this
I honestly have no idea what is going on. This is my first program and my teacher expects this done tonight. I am going off of what I have learned in class in 2 days. This is all I have so far.

def computeMetric(ENG101, ENG210, CMST210, CMST340):
metric = ENG101 * .5 + ENG210 * 1.5 + CMST340 * .75 + CMST340 * 1.25

print(metric)

name = str(input("Enter Student's Name:"))
ENG101 = float(input("Enter English 101 Score:"))
ENG210 = float(input("Enter English 210 Score:"))
CMST210 = float(input("Enter Comm Studies 210 Score:"))
CMST340 = float(input("Enter Comm Studies 340 Score:"))

def printStudent(

I do not know what to do now. When i run the module it asks me for the data so i input random values. After i input the values i want to be able to type in the function printStudent and would like for it to show me the name, each class score, and the metric.

Help would be appreciated.
13. Code:
```def computeMetric(ENG101:float, ENG210:float, CMST210:float, CMST340:float)->float:
metric = ENG101 * .5 + ENG210 * 1.5 + CMST340 * .75 + CMST340 * 1.25 # can you spot the error in this line?
#metric = sum(w*g for (w,g,) in zip((0.5,1.5,0.75,1.25,),(ENG101, ENG210, CMST210, CMST340))) # computed as a dot product
return metric ################ return the value, don't print it.

def printStudent(name:str, ENG101:float, ENG210:float, CMST210:float, CMST340:float)->None:
'''
>>> printStudent('Brian Kamp',4,3,3.5,2)
Brian Kamp\t4.0\t3.0\t3.5\t2.0\tMetric:11.625
'''
metric = computeMetric(ENG101, ENG210, CMST210, CMST340)
print(('{}'+'\t{:.1f}'*4+'\tMetric:{}').format(name, ENG101, ENG210, CMST210, CMST340, metric))

name = str(input("Enter Student's Name:"))
ENG101 = float(input("Enter English 101 Score:"))
ENG210 = float(input("Enter English 210 Score:"))
CMST210 = float(input("Enter Comm Studies 210 Score:"))
CMST340 = float(input("Enter Comm Studies 340 Score:"))```