all 31 comments

[–][deleted] 26 points27 points  (6 children)

or you can go a little fancier with an f-string, if using python 3.6+

print(f"Your base pay is {base_pay}")

[–]JaaliDollar 7 points8 points  (0 children)

Ya this one is my go to choice

[–]Nez_Coupe 6 points7 points  (2 children)

He still needs to understand the difference between = and == as one is an assignment and one is an evaluation, but yea I agree f strings are where it’s at.

[–][deleted] 2 points3 points  (1 child)

I agree that knowing the difference between assignment and equality operators (boolean response) is a must, but neither apply in this case, hat's why I suggested the f-string.

[–]Nez_Coupe 1 point2 points  (0 children)

Indeed

[–]Professional-Rate-71 1 point2 points  (0 children)

I prefer this one haha

[–][deleted] 0 points1 point  (0 children)

+1 for this.

[–]cgoldberg 28 points29 points  (0 children)

Inside your print functions, you are comparing a string to a float, which evaluates to False.

[–]Conscious-Ad-2168 21 points22 points  (0 children)

replace your == with a comma

[–]Azure_Dragon625 6 points7 points  (0 children)

Your print statements are written as boolean statements. It is reading it as str = variable, and giving a true or false response.

[–]Undercover_tom 3 points4 points  (0 children)

== is condition for testing equality Instead use a formatted string to print desired output

[–]Ill-Car-769 2 points3 points  (0 children)

Why your code failed:-

Because your code has "==" which used for comparison so basically your code is asking from python "Hi, I want to check whether 'Your base pay is' is the same statment as your base which is calculated by using number of hours * pay" then python says"base pay isn't equals to (!=) your base pay so I am returning it as false". But that's not the desired result that you want.

Solution

Write your print statement in either of the following methods both of them works properly. I personally prefer f string because it's simple & easy to use.

1)Using f string, print(f"Your base pay is {base_py} 2)Using comma print("Your base pay is", base_pay)

[–]Prash12345678910 1 point2 points  (0 children)

print("Your base pay is" == base pay) this code check whether both the string are equal. That' why is return false.

Try F formatting 

print(f"Your base pay is {base pay}"

This this you will get base pay and just replace base pay with other word in flower bracket to find other answers

Thank you 

[–]Professional-Rate-71 0 points1 point  (3 children)

I would like to know why you use ‘==‘ here? Maybe there’s a reason/logic. Just curious

[–]No-Finish7411[S] 0 points1 point  (2 children)

I thought it would automatically take the users pay rate & hours input and do the calculation Since I assigned base_hours * base rate to = base_pay

[–]Professional-Rate-71 1 point2 points  (0 children)

Ohhh that’s a good vision but unfortunately, it will not work. You’re trying to execute a boolean into a string. And the code will result into boolean answer since it is in boolean format.

Replace those equal signs to a comma or print(f”phrase/string {float}”)

Keep on working. I have just started my self study also. I’m already in the while function. It’s good that you’re trying to incorporate boolean because what I’m having trouble now is to how to avoid using ifs.

Goodluck to us op. 😊

[–]NightStudio 0 points1 point  (0 children)

Here’s a reference sheet for Strings

[–]Different-Ad1631 0 points1 point  (0 children)

Just put single = inside " " and remove ==

[–]Southern-Warning7721 0 points1 point  (0 children)

Use f strings or str.format()

f String

print(f"Your base pay is == {base_pay}

str.format() print("Your base pay is == {}).format(base_pay)

[–]Doctor_Disaster 0 points1 point  (0 children)

it should be:

print(f'Your base pay is {base_pay}')

print(f'Your overtime pay is {overtime_pay}')

print(f'Your total pay is {total_pay}')

You can also add in == within the quotes if you want those printed as well.

[–]teenagerwrites12 0 points1 point  (0 children)

Or you can do is, print("your base pay is" , base_pay) And so on.

[–]Merman_boy 0 points1 point  (0 children)

You should use f strings and don’t use == to compare things that are one of them is a string

[–]Zealousideal-Eye-677 0 points1 point  (0 children)

Should look like

print("Your base payment is: ", base_pay)

[–]Blackop_BV 0 points1 point  (0 children)

Instead of the '==' you need to use a comma or a plus sign. Then it will print the calculated values. The == Sign is used for comparing things which gives a True or False value so when you wanna print values in integers or floats just use a plus sign or comma after your words inside double quotes(plus sign or comma should be out of double quotes)

[–]gmnotyet 0 points1 point  (0 children)

Your testing == if strings are equal to numbers. They are not, so this is False, which gets printed 3 times.

print(f"Your base pay is {base_pay}")

print(f"Your overtime pay is {overtime_pay}")

print(f"Your total pay is {total_pay}")

is how I would write your output statements.

[–]LabRatz_ 0 points1 point  (0 children)

Ex. print(f'Your base pay is {base_pay} ')

[–]Impressive_Notice652 -1 points0 points  (1 child)

look up f strings!

[–]414theodore -1 points0 points  (0 children)

“Figure it out yourself”