435,483 Members | 3,229 Online
Need help? Post your question and get tips & solutions from a community of 435,483 IT Pros & Developers. It's quick & easy.

# Calculation of hours worked

 P: 64 #Workers in a company are paid £8 per hour for each hour they work up to a #basic working week of 40 hours, and £12 an hour for any overtime they work. #Write a program that asks the user to enter the number of hours worked #and outputs the total pay for the week. below is the which i have made, can cheak to see if it works. thnaks you Expand|Select|Wrap|Line Numbers workedhours = input ("\nPlease enter number of hours worked this week: ") while workedhours > 40:     workedhours = input("Incorrect, please enter worked hours this week again:")   overtime = input ("Please enter number of overtime horus worked this week: ")   if workedhours <= 40:     print "\n\nStandard hourly rate is £8 per hour, so you will get paid: \t£",8*workedhours   elif workedhours >= 40:     print "Standard hourly rate is £8 per hour, so you will get paid: \t£",8*workedhours   print "Overtime rate is £12 per hour, so you will get paid: \t\t£",12*overtime   print "\nTotal pay for the week is: \t\t\t\t\t£",8*workedhours + 12*overtime Dec 16 '08 #1
10 Replies

 Expert Mod 2.5K+ P: 2,851 Please use code tags!! It works like this: [code] .......code goes here......... [/code] I created a new thread for you because you have asked a question unrelated to your previous question. -BV Dec 16 '08 #2

 P: 64 ok sorry, next time will do that, so can you cheak program, and see if works correclty. Dec 16 '08 #3

 Expert Mod 2.5K+ P: 2,851 Yes, it works. Why did you need me to test it for you? You should test your own code by using an IDE such as IDLE. You can also run your script from the command prompt. A couple of suggestions: Use raw_input() instead of input(). This will avoid the possibility of someone entering malicious code. Set up a while loop to validate the initial entry that should be 40 hours or less. Something like this: Expand|Select|Wrap|Line Numbers while True:     workedhours = int(raw_input("\nPlease enter number of hours worked this week: "))     if workedhours > 40:         print "Incorrect, please enter worked hours this week again (must not be over 40)."     else: break You don't need the if statement "if workedhours <= 40". -BV Dec 16 '08 #4

P: 64
i have to Write a function called areaOfCircle() which takes as an input the radius and outputs the area of a circle with a radius of the given input (area = r2)

basically i am confused wht it means by write a fucntion, i have the code for this, but wht does it mean wirte a function. i have attched wht i have wriiten.
Attached Files
 circle.txt (286 Bytes, 369 views)
Dec 17 '08 #5

 Expert Mod 2.5K+ P: 2,851 Please, imran akhtar, do not ask new and unrelated questions in the same thread. Start a new thread. Please post your code in your message and enclose the code with code tags. This is preferable to viewing an attachment. -BV Dec 17 '08 #6

 P: 64 ok sorry for that, silly question how do i start . Start a new thread., due to the fact i cant seem find tab which says "NEW THREAD" and how does the enclose code tags looks like. sorry for the stupid questions. Dec 17 '08 #7

 Expert Mod 2.5K+ P: 2,851 Under bytes > topic > python > answers, there should be a large button in the upper left of the window: "New Thread" Code tags work like this: [code]x + y = z print z [/code] There is a code tag button on the toolbar in the "Reply to Thread" and "Post New Thread" windows. Highlight all your code, then select the code tag button. Dec 17 '08 #8

 P: 64 no mate there is no button called NEW THREAD, thats the reason i been just posting new question and in the old thread, due to fact i could not find the button. Dec 17 '08 #9

 P: 19 Do what bvdet says -- don't just look at your own thread! Instead, go all the way up to the top of the window above your thread, where it says "bytes > topic > python > answers", and click on "answers". Then you will see the "New Thread" button. If you learn how the forum works, you will be so much more productive and people will be more willing to help you. Dec 17 '08 #10

 Expert Mod 2.5K+ P: 2,851 Thanks bigturtle. I could not have said it better! -BV Dec 17 '08 #11