I've been working on this for three days now and I'm still confused on why my code isn't calculating properly. I'm supposed to write a code where you input your overall Grade in a class, you input your midterm exam test grade (worth 12%), and then use those two to calculate what grade you need in the final exam to pass (worth 50%), but the code is giving the incorrect outputs and i have no idea what I'm doing wrong.
#🔒 need help
172 messages · Page 1 of 1 (latest)
@karmic iron
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
Closes after a period of inactivity, or when you send !close.
the output is supposed to loo like this
but it comes out like this. input 75 for both the mark needed comes out as 75 instead of 35 like its supposed too. and if i input the grades as 80 and 40 the mark needed comes out as 15 instead of 55 like its supposed to above.
What does your code look like?
overall = int(input("What is your Overall Mark?: "))
print(overall)
if 0 < overall <=100:
average = int(input("What was your Midterm Average? "))
if 0 < average <=100:
print(average)
needed = ((50 + (average - overall))*0.6)/0.4
print (needed)
else:
print("Your Average has to be between 0 - 100, re-run the program and try again. ")
else:
print("Your Overall has to be between 0 - 100, re-run the program and try again. ")
Double check the equation you used
it told me to use the equation in the picture up there and i did i think
Yours looks like it has "50 + ..." instead of "50 - ..."
oh i didnt even see that. but now its worse the output is 135 when its supposed to be 55
this is the most confusing thing i think ive ever done in my life.
Is that the entire question? Feels like something is missing
well i have the full pdf of instructions
any way that you can share it somehow?
i can DM it to you, one sec.
Yeah, that equation doesn't seem right. At least it's not goving the results in the example
i just sent it, it could be possible I'm greatly misinterpreting the instructions but im still very confused.
yea you omitted a lot of info
oh, oops sorry.
i had it started:
Enter value
If value less then 0 or over 100
Invalid input
Enter second value
If value less then 0 or over 100
Invalid input
that was my first time ever doing it so i dont know how good it is but
im pretty sure i have everything correct up to the point where it calculates the minimum grade needed to pass
According to this, you have to do 3 conditional checks with these 3 different formulas.
i think I'm using the formula wrong because when i do it on my calculator i get the same result from my code, which is obviously wrong. i know th firsst condition is met because the input cant go above 100
i really have no idea what I'm doing up to the point of what i already have done. I've been trying to alter the equation a bit to try and make it work but that didnt work so i kept reverting back
it doesn't make any sense , i found a different calculation online and when both inputs are 75, it comes out as 75 like in my code.
OK it took me awhile to understand it
i have no idea ow you do lol I've been stressing out and trying for three days now lmao
You just need to do 3 different conditional checks
each conditional checks explained what you're supposed to do
So its not 1 formula
Its 3 formulas
so i need to add all three formulas in the code somehow?
yes
OK focus on the first equation
Do you know what the first equation is calculating for?
i assumed the mark needed to pass the class
it is to calculate the "minimum final exam mark"
That's correct
Can you show me in pseudocode at least on how you calculate for equation 1?
one sec
thats a long one sec
Sorry, this is how I would use the equation if the term average was 75
I didn’t know how to express that in pseudicode so I just did it
No that's not pseudocode but I guess close enough
This is a pseudocode. Everything is spelled out
I’ve never used it before I’m struggling to comprehend this first
Okay so yeah kinda what I did
Before I mean
When showed what I had started
Here
ok anyways
Yeah
Okay so I did something wrong in my calculations obviously
What is the end result here? Is that 125?
Oh okay so I didn’t do something wrong!
Because if you read the 2nd condition to check
Sorry, I meant the first condition to check
Do you understand this?
That condition would be good because it’s not above 100% and you need a minimum of 50% overall to pass.
I assume
No
You're half right
If the minimum final exam mark is more than 100%, the marks needed is 100
Do you understand?
Okay so, if the calculation I get is over 100 then I need 100 to pass
exactly
Okay so that check is kind of redundant in this case because we get 12.5 right?
Its not redundant
Its required
But since the current test case that we're using leads us to the minimum final exam mark is less than 100 AND less than 50, we move on to the 2nd condition check
Tell me what you understand here
I assume that we then take the 12.5 we got and use it for the final exam mark then solve the equation using 75 as the midpoint mark and see if it’s greater or equal to 32?
💯
You got it
Hell yeah! And it would equal 48 so that condition would be met?
With the current test case of 12.5, show me in your paper manual calculation, does it equal or greater than 32?
Hm.
Double check your formula
Against the one in the assignment
You're using the wrong value
Thats right
so it’s not equal or greater then 32.
Which means its ?
It’s false?
Fuck yeah. lol
So the last thing to do
Since its False, it says you have to recalculate the minimum exam mark with the 3rd equation
Show me on your paper calculation on how to get it
yeah that's wrong.
look at the formula again. One of the values is incorrect from the beginning
Is the midterm average not 75?
Yeah that makes more sense, so now I just try to turn this into code. Somehow.
You got this 🦾
You sorta have a pseudocode
Try to document that first before you start coding
Don't forget to use if else conditions
Okay, i vaguely think I know how to code it but I’m not 100% I’m going to try after I do that and see what happens.
Now that i actually understand the process it should be a lot easier, thank you lol
i ran into an error
Go on
TypeError: can only concatenate tuple (not "float") to tuple
markfinal2 = ((markfinal0,4) + (average0.24))
for this line of code
not sure why, the first equation worked very well and output 12.5 lie it was supposed too but then this error poped up
rewrite that in code block pls
!code
is that 0,4?
right sorry oh fuck
yes yes it is.
overall = int(input("What is your Overall Mark?: "))
if 0 < overall <=100:
average = int(input("What was your Midterm Average? "))
if 0 < average <=100:
markfinal = (50 - (overall *0.6))/0.4
markfinal2 = ((markfinal*0.4) + (average*0.24))
if (markfinal2 >= 32):
print(f'Mark Needed {markfinal2}')
else:
markfinal3 = (32 - (average * 0.24)/0.4)
print(markfinal3)
else:
print("Your Average has to be between 0 - 100, re-run the program and try again. ")
else:
print("Your Overall has to be between 0 - 100, re-run the program and try again. ")
the error dosnt pop up anymore, but the output is -13.0
not 35
so something is wrong somewhere
its has to be something in equation 3 thats wrong
you're right. Something's wrong at equation 3
AH HA!
double check your brackets
just did that IT WORKS NOW!!
YES!
Thank you so much! so much stress relived i cant belive i did it.
np
thank you for the help.
Be sure to not let this habit of last minute assignments get to you
Its bad for your health
now time to write a 4 page essay for another class. damn
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.
