This is too long for a comment, so I'll point out a few things and give some next steps to help you solve your issue and improve your question on this site for now and the future:
First there are a few errors in your code:
return scorePercent
should be indented to be part of the score
function.
score
requires a second argument overallWeight
but you do not pass this in when you call it
- In
score
you assign the value of scorePercent
three times - only the last performed assignment will define what scorePercent
is.
grade
is never called - possibly part of the issue
You will need to fix these errors, then consider more what exactly you are doing in calculating the score. If you are a beginner I would recommend using a text editor or IDE that has IntelliSense so it can warn you about these errors and help you solve them as you go.
Then once you are getting errors out of the way, you can use StackOverflow to ask more specific questions such as "How do I format this output to have a %" for example. The code you posted does not run, and there is no specific question so it is harder for the community to help you solve your problem.
If you fix those errors and edit your post to have a more specific question I will edit my answer to better help as well. Also keep in mind that it can be helpful to use a debugger or just print out values throughout your code to track what things are and see if they are coming out as what you'd expect.
Two arguments in function
When you define a function as you have here, you've set it to take two inputs already: def score(earnedPercent, overallWeight):
takes earnedPercent
and overallWeight
as inputs. So when you call (use) score
it needs these two values. Going to where you call it:
calculatedNumber = score(lab_percent)
You only give it one of the parameters, you need to give it another. Say I had lab_weight = 0.2
then I could say:
lab_score = score(lab_percent, lab_weight)
Then you can use this lab_score
elsewhere.
Scope
For grade
, you don't want to delete it - the problem is you just aren't using it. Later in your code you say earnedPercent = gradePercent
but gradePercent
is only defined in the scope of your grade
function. You need to think of each function as its own black box, you can only give it inputs and get out whatever it returns.
I really suggest using some sort of editor with Python IntelliSense so that these errors are pointed out for you as you write code. It also might be helpful for you to look at a tutorial like this on scope so you can get a more in depth explanation of this as it is really really important when you're learning to code.
Incremental Building
Also, consider doing things piece by piece. You have a decent amount of code here but there are errors throughout and its going to take time to track all of them down. For example, write your score function give it an input and print the result. If it's what you expect, then do it again and assign it to a variable, print. Then do it with another variable (you tend to overwrite your variables a lot so this will help you resolve that). Do it step by step and learn through the process and you'll find you can rebuild this code and get it running while also getting more practice and better understanding.