+ 2

Please,help me to write a program to prompt the user for Hours and Rate Per Hour to compute Gross Pay

Assignment

15th Jul 2021, 6:01 PM
Ibrahim Fomba Mansaray
Ibrahim Fomba Mansaray - avatar
10 Antworten
+ 5
Please show us your attempt and link your code here.
15th Jul 2021, 6:02 PM
Lisa
Lisa - avatar
+ 2
Ok,l will get back. Thanks 👍
15th Jul 2021, 6:07 PM
Ibrahim Fomba Mansaray
Ibrahim Fomba Mansaray - avatar
+ 2
If you're looking to have the output more visually appealing, do this instead to get your desired effect. x = float(input("Enter your hours: ")) print(str(x)) y = float(input('Enter your hourly rate: ')) print(str(y)) pay = str(x*y) print('Pay: ' + pay) https://code.sololearn.com/cA182a24A19A ::INPUT:: 35 2.75 ::OUTPUT:: Enter your hours: 35.0 Enter your hourly rate: 2.75 Pay: 96.25
15th Jul 2021, 7:02 PM
Jakko Jak
Jakko Jak - avatar
+ 1
print('Enter your hours:') x = float(input()) print('Enter your hourly rate:') y = float(input()) pay = str(x*y) print('Pay: ' + pay) INPUT: 40 10 OUTPUT: 400.0 Code Playground: https://code.sololearn.com/cA182a24A19A input() is how you get the prompt, and you assign it to a variable to store the value that's inputted. You wrap it in float() to ensure the value is stored as an int that we can use to do calculations, and then I used str() to ensure it's a text string that we can easily print out to display the result. Hope that helps. Good luck in your learning.
15th Jul 2021, 6:10 PM
Jakko Jak
Jakko Jak - avatar
+ 1
In the CodePlayground, you have to input all inputs into the same box when you run it. So for example you would put: 35 2.75 ^Put that into the input box on separate lines as above. Then when it finishes execution it'll output 96.25 as you expect. This is a security feature since you're executing code through the servers instead of locally.
15th Jul 2021, 6:57 PM
Jakko Jak
Jakko Jak - avatar
0
Ok,l will get back. Thanks 👍
15th Jul 2021, 6:07 PM
Ibrahim Fomba Mansaray
Ibrahim Fomba Mansaray - avatar
0
Lisa
15th Jul 2021, 6:08 PM
Ibrahim Fomba Mansaray
Ibrahim Fomba Mansaray - avatar
0
Lisa, thanks 👍 very much may God bless you.
15th Jul 2021, 6:25 PM
Ibrahim Fomba Mansaray
Ibrahim Fomba Mansaray - avatar
0
Jako jak,the code only give me output like this: "Enter hours :35" But, this is how my question should be Outputted; Enter Hours: 35 Enter Rate: 2.75 Pay: 96.25
15th Jul 2021, 6:52 PM
Ibrahim Fomba Mansaray
Ibrahim Fomba Mansaray - avatar
0
Thank you for the tuition,I will try it and then get back to you.
15th Jul 2021, 10:54 PM
Ibrahim Fomba Mansaray
Ibrahim Fomba Mansaray - avatar