473,503 Members | 1,747 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calculation of hours worked

64 New Member
#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
  1. workedhours = input ("\nPlease enter number of hours worked this week: ")
  2. while workedhours > 40:
  3.     workedhours = input("Incorrect, please enter worked hours this week again:")
  4.  
  5. overtime = input ("Please enter number of overtime horus worked this week: ")
  6.  
  7. if workedhours <= 40:
  8.     print "\n\nStandard hourly rate is £8 per hour, so you will get paid: \t£",8*workedhours
  9.  
  10. elif workedhours >= 40:
  11.     print "Standard hourly rate is £8 per hour, so you will get paid: \t£",8*workedhours
  12.  
  13. print "Overtime rate is £12 per hour, so you will get paid: \t\t£",12*overtime
  14.  
  15. print "\nTotal pay for the week is: \t\t\t\t\t£",8*workedhours + 12*overtime
Dec 16 '08 #1
10 9785
bvdet
2,851 Recognized Expert Moderator Specialist
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
imran akhtar
64 New Member
ok sorry, next time will do that, so can you cheak program, and see if works correclty.
Dec 16 '08 #3
bvdet
2,851 Recognized Expert Moderator Specialist
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
  1. while True:
  2.     workedhours = int(raw_input("\nPlease enter number of hours worked this week: "))
  3.     if workedhours > 40:
  4.         print "Incorrect, please enter worked hours this week again (must not be over 40)."
  5.     else: break
You don't need the if statement "if workedhours <= 40".

-BV
Dec 16 '08 #4
imran akhtar
64 New Member
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
File Type: txt circle.txt (286 Bytes, 532 views)
Dec 17 '08 #5
bvdet
2,851 Recognized Expert Moderator Specialist
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
imran akhtar
64 New Member
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
bvdet
2,851 Recognized Expert Moderator Specialist
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
imran akhtar
64 New Member
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
bigturtle
19 New Member
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
bvdet
2,851 Recognized Expert Moderator Specialist
Thanks bigturtle. I could not have said it better!

-BV
Dec 17 '08 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1244
by: David Paschall | last post by:
Can someone help me with totaling hrs worked on shift including past midnite hrs. Thanks
1
13584
by: sg_s123 | last post by:
============================================================================ 02-Feb-04 03-Feb-04 Staff Staff 0800hr- 1300hr- 1700hr- 1900hr- 0800hr- 1300hr- 1700hr- 1900hr- Number...
2
3893
by: Del | last post by:
Thanks in advance for any help. I have a database that was created in Access 2000. Several users have been upgraded to Access 2003. Since upgrading to 2003 we have noticed that some of the...
3
3975
by: Nigel C | last post by:
My problem is best explained by way of tables and examples... I am using Access 2000 (in case this is relevant) and I have a table with the following fields... Field names ------------ Code ...
10
3348
by: Drum2001 | last post by:
I have designed a "Time Tracker Database"... Basically a Time Clock. I have report that calculates the number of regular hours worked per week. Currently I am running the following query: ...
8
3970
by: King | last post by:
Hi I have following MS Acess query Here is the query ID Name Prgm ID Client ID Date Start Time End Time Minutes C4 Trisha TIP DEK0703 7 /7 /2006...
3
3321
by: Beowulf | last post by:
I have data coming from a telephony system that keeps track of when an employee makes a phone call to conduct a survey and which project number is being billed for the time the employee spends on...
9
2459
by: brendanmcdonagh | last post by:
Hi, I am designing a project for my friend as I am just a week old baby to vb and want to implement what I've learnt so far. She wants to be able to put start time, end time and lunch for each...
4
1163
lee123
by: lee123 | last post by:
i have a form with timestarted and timeended and i have asked this question before but in access the way they did it was in a query but i don't know how to work the query in vb6 so maybe one of you...
0
7203
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7087
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7281
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6993
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7462
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5579
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3156
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
383
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.