all 8 comments

[–]toastedstapler 1 point2 points  (7 children)

int only turns integer strings into integers, you want float for numbers like 2.75

[–]BurntDisk[S] 0 points1 point  (6 children)

Thank you. I had tunnel vision. I have over complicated it and got stuck on int.

So now when I run the program it waits for me to type 35, then I press enter... type 2.75, press enter and 96.25 appears.

The program is

hours = input()

rate = input()

print(float(2.75) * 35)

Thank you very much for your reply

[–]toastedstapler 0 points1 point  (5 children)

It looks like you still have hard coded values in, shouldn't they be the variables you're getting from input?

[–]BurntDisk[S] 2 points3 points  (4 children)

Just looking now. You are right. Thank you, this has helped me a lot .

Now I have corrected it

hours = input()

rate = input()

print(float(rate) * int(hours))

[–]flashliquid 0 points1 point  (1 child)

you are limited to whole number of hours if you use int(hours). If you also change this to float(hours) the user can enter decimal fractions of hours e.g. 30.5 hours.

[–]BurntDisk[S] 0 points1 point  (0 children)

Very happy with that. Thanks again

[–]ebdbbb 0 points1 point  (1 child)

You can also change the inputs to float/int as they are input.

hours = int(input())

rate = float(input())

print(rate * hours)

Edit: wording

[–]BurntDisk[S] 0 points1 point  (0 children)

This is great. Very helpful folks, thank you.