#🔒 need help

172 messages · Page 1 of 1 (latest)

karmic iron
#

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.

placid oysterBOT
#

@karmic iron

Python help channel opened

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.

karmic iron
#

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.

quaint quartz
#

What does your code look like?

placid oysterBOT
#
Formatting code on Discord

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

For long code samples, you can use our pastebin.

karmic iron
#
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. ")
quaint quartz
#

Double check the equation you used

karmic iron
#

it told me to use the equation in the picture up there and i did i think

quaint quartz
#

Yours looks like it has "50 + ..." instead of "50 - ..."

karmic iron
#

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.

pure edge
karmic iron
#

well i have the full pdf of instructions

pure edge
#

any way that you can share it somehow?

karmic iron
#

i can DM it to you, one sec.

quaint quartz
#

Yeah, that equation doesn't seem right. At least it's not goving the results in the example

karmic iron
#

i just sent it, it could be possible I'm greatly misinterpreting the instructions but im still very confused.

pure edge
#

yea you omitted a lot of info

karmic iron
#

oh, oops sorry.

pure edge
#

Have you done the Pseudocode yet @karmic iron ?

karmic iron
#

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

pure edge
# pure edge

According to this, you have to do 3 conditional checks with these 3 different formulas.

karmic iron
#

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.

pure edge
#

OK it took me awhile to understand it

karmic iron
#

i have no idea ow you do lol I've been stressing out and trying for three days now lmao

pure edge
#

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

karmic iron
#

so i need to add all three formulas in the code somehow?

pure edge
#

yes

#

OK focus on the first equation

#

Do you know what the first equation is calculating for?

karmic iron
#

i assumed the mark needed to pass the class

pure edge
#

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?

karmic iron
#

one sec

pure edge
#

thats a long one sec

karmic iron
#

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

pure edge
#

This is a pseudocode. Everything is spelled out

karmic iron
#

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

pure edge
#

ok anyways

karmic iron
#

Yeah

pure edge
#

So you're using the 75, 75 and it should return 35

#

Lets use those values for now

karmic iron
#

Okay so I did something wrong in my calculations obviously

pure edge
karmic iron
#

12.5

#

Sorry

pure edge
#

I got the same

#

And it should be that way

karmic iron
#

Oh okay so I didn’t do something wrong!

pure edge
#

Because if you read the 2nd condition to check

#

Sorry, I meant the first condition to check

#

Do you understand this?

karmic iron
#

That condition would be good because it’s not above 100% and you need a minimum of 50% overall to pass.

#

I assume

pure edge
#

You're half right

#

If the minimum final exam mark is more than 100%, the marks needed is 100

#

Do you understand?

karmic iron
#

Okay so, if the calculation I get is over 100 then I need 100 to pass

pure edge
#

exactly

karmic iron
#

Okay so that check is kind of redundant in this case because we get 12.5 right?

pure edge
#

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

karmic iron
#

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?

karmic iron
#

Hell yeah! And it would equal 48 so that condition would be met?

pure edge
#

With the current test case of 12.5, show me in your paper manual calculation, does it equal or greater than 32?

karmic iron
#

Yes. Why the hell is that sideways

#

Sorry, yes it’s greater then 32

pure edge
#

Try again

karmic iron
#

Hm.

pure edge
#

Double check your formula

#

Against the one in the assignment

#

You're using the wrong value

karmic iron
#

Oh wait the 12.5 not 75

#

duh

#

It’s 23

pure edge
#

Thats right

karmic iron
#

so it’s not equal or greater then 32.

pure edge
#

Which means its ?

karmic iron
#

It’s false?

pure edge
#

💯

#

You keep scoring good points so far

karmic iron
#

Fuck yeah. lol

pure edge
#

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

karmic iron
#

I think I did it wrong, that doesn’t seem right.

pure edge
#

yeah that's wrong.

#

look at the formula again. One of the values is incorrect from the beginning

karmic iron
#

Is the midterm average not 75?

pure edge
#

it is

#

but thats not the wrong value

#

try again

karmic iron
#

Ohhh the 0.4 is 0.24

#

oops

pure edge
#

bingo

#

Recalculate and show me

karmic iron
#

35

pure edge
#

You got it now?

karmic iron
#

Yeah that makes more sense, so now I just try to turn this into code. Somehow.

pure edge
#

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

karmic iron
#

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

karmic iron
pure edge
#

Go on

karmic iron
#

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

pure edge
#

!code

placid oysterBOT
#
Formatting code on Discord

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

For long code samples, you can use our pastebin.

pure edge
karmic iron
#

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

pure edge
#

you're right. Something's wrong at equation 3

karmic iron
#

AH HA!

pure edge
#

double check your brackets

karmic iron
#

just did that IT WORKS NOW!!

#

YES!

#

Thank you so much! so much stress relived i cant belive i did it.

pure edge
#

np

karmic iron
#

thank you for the help.

pure edge
#

Be sure to not let this habit of last minute assignments get to you

#

Its bad for your health

karmic iron
#

now time to write a 4 page essay for another class. damn

karmic iron
#

!close

placid oysterBOT
#
Python help channel closed

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.