Ask your own question, for FREE!
Computer Science 13 Online
Astrid1:

Coding help huehue

Astrid1:

I've gotten this but I can't get the other two?

1 attachment
Astrid1:

1 attachment
Astrid1:

^^ That is what we're supposed to end up w ith

Vocaloid:

There are some logical errors in the way the code is set up. The input statements should not include the numbers 9.00 or 20. The user is supposed to enter those numbers themselves. When the user gets those input prompts, their answers will be stored in the variables payRate and hoursWorked. Later on in the code, you should calculate payEmily by multiplying the variables payRate and hoursWorked, not the floats 9 and 20. The print statement “Emily’s weekly pay” should not include the 180 in the print statement. Instead, it should use the variable payEmily in the print statement. The way your code is set up, it will display 9.0, 20, and 180 regardless of what the user enters. The point is to take the users input, store the input as variables, and output the variables. That way, it’ll work with whatever numbers you enter.

Vocaloid:

I know this is a lot. I’m on my lunch break rn but I can help explain further tonight if you’re not in a rush. If it’s urgent you can try pinging someone else who may be able to help.

Astrid1:

I'm not in a rush, thank you for helping Voca <3 I'd be happy if you could explain further later 😭.

Vocaloid:

You have three employees, so you’ll also need to repeat the calculations for the other two employees. You could simply create new variables to store the other employees pay rate, hours worked, and pay. Ex: payRateEmily = input(“What is Emily’s pay?”) payRateMatthew = input(“What is Matthew’s pay”) payRateSarah = input(“What is Sarah’s pay?”) Repeat this logic for the hours worked. Then write three separate calculations for payEmily = payRateEmily * hoursWorkedEmily, repeat for Matthew and Sarah.

Vocaloid:

``` #payProgram.py #This program calculates a weekly pay for 3 employees. #Weekly pay is calculated by multiplying the hours worked times the pay rate. payRateEmily = input("Enter the pay rate for Emily ") # notice how the input statement does not have any numbers in it. # when the user enters a number, that number gets stored in the variable # payRateEmily. we work with the variable payRateEmily, not the number itself. # that way, if someone wants to enter a different number, the code still works. hoursWorkedEmily = input("Enter the number of hours Emily worked ") # same logic as above payEmily = float(payRateEmily) * float(hoursWorkedEmily) # calculation of the amount paid. notice how we are working directly # with the variables. print("Emily's weekly pay is:") print(payEmily) # the above code can be repeated for other employees. simply replace # the name of the employee. be careful about your variable names. ``` I'm on my PC now. I've revised your code and explained my changes in the comments. I've noticed in your original code, you create the variables payRate and hoursWorked but you don't actually use them. The point of creating a variable is to store the information and work with the variable name instead of the information directly.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!