Hi Bob,

Thanks for your feedback. Please do not hesitate to provide more as I shall
email you personally in the future.

The script is made up of a function definition and its call prompting the
user for input.

The script itself takes "number of hours worked" and "hourly rate" as
inputs and gives gross pay as a product of the two.
As I stated in my earlier email, there is also a portion for calculating
gross pay with considerations for overtime (> 40 hours worked).

The problem was that running the code gave an error which I now do not
remember in detail as I have moved on after having fixed it.

Here's the initial email below with Sreenathan's helpful input followed by
my amendments to the code:
(I thought my initial email was quite self-explanatory but what do I
know... Please read through to the end)

On Sun, May 1, 2016 at 1:09 PM, Sreenathan Nair <sreenath...@gmail.com>
 wrote:

> On Sun, May 01, 2016 at 5:34 PM, Olaoluwa Thomas <thomasolaol...@gmail.com>
> wrote:
>
> The novice Python programmer is back.
>
> I'm trying to incorporate a function and its call in the GrossPay.py
> script
> that Alan solved for me.
> It computes total pay based on two inputs, no. of hours and hourly rate.
>
> There's a computation for overtime payments in the if statement.
>
> Something seems to be broken.
>
> Here's the code:
> def computepay(hours, rate):
>     hours = float(raw_input ('How many hours do you work?\n'))
>     rate = float(raw_input ('What is your hourly rate?\n'))
>     if hours > 40:
>         gross = ((hours - 40) * (rate * 1.5)) + (40 * rate)
>     elif hours >= 0 and hours <= 40:
>         gross = hours * rate
>     print "Your Gross pay is "+str(round(gross, 4))
>
> computepay()
>
> What am I doing wrong?
>
> *Warm regards,*
>
> *Olaoluwa O. Thomas,*
> *+2347068392705*
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
>  Hi,
> The parameters hours and rate are required when calling the method
> computepay ex: computepay(8, 200), so basically computepay() by itself will
> throw an error .... Also, as a suggestion if you're gonna get hours and
> rate via user input perhaps they can be removed from the method definition?
>
> ​Thanks, Sreenathan. These alterations solved it.

def computepay(hours, rate):
    if hours > 40:
        gross = ((hours - 40) * (rate * 1.5)) + (40 * rate)
    elif hours >= 0 and hours <= 40:
        gross = hours * rate
    print "Your Gross pay is "+str(round(gross, 4))
computepay(hours = float(raw_input ('How many hours do you work?\n')), rate
= float(raw_input ('What is your hourly rate?\n')))

*Warm regards,*

*Olaoluwa O. Thomas,*
*+2347068392705*

On Sun, May 1, 2016 at 2:13 PM, Bob Gailer <bgai...@gmail.com> wrote:

>
> On May 1, 2016 8:04 AM, "Olaoluwa Thomas" <thomasolaol...@gmail.com>
> wrote:
> >
> > The novice Python programmer is back.
> Welcome back. We are here to help you when you are stuck. Telling us
> something is broken is not adequate. Tell us-what you are expecting the
> program to do and what results you're getting.
> >
> > I'm trying to incorporate a function and its call in the GrossPay.py
> script
> > that Alan solved for me.
> > It computes total pay based on two inputs, no. of hours and hourly rate.
> >
> > There's a computation for overtime payments in the if statement.
> >
> > Something seems to be broken.
> >
> > Here's the code:
> > def computepay(hours, rate):
> >     hours = float(raw_input ('How many hours do you work?\n'))
> >     rate = float(raw_input ('What is your hourly rate?\n'))
> >     if hours > 40:
> >         gross = ((hours - 40) * (rate * 1.5)) + (40 * rate)
> >     elif hours >= 0 and hours <= 40:
> >         gross = hours * rate
> >     print "Your Gross pay is "+str(round(gross, 4))
> >
> > computepay()
> >
> > What am I doing wrong?
> >
> > *Warm regards,*
> >
> > *Olaoluwa O. Thomas,*
> > *+2347068392705*
> > _______________________________________________
> > Tutor maillist  -  Tutor@python.org
> > To unsubscribe or change subscription options:
> > https://mail.python.org/mailman/listinfo/tutor
>
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to