Example of Python code (C code to Python code)

Ken Seehof 12klat at sightreader.com
Tue Jun 6 22:58:14 EDT 2000


Ack!  Somebody else beat me to it.  And for free!  I Hate Open Source!
 :-(

Robin Porter wrote:

> Could someone please give me an example of some Python code.  I am just new
> to this language and would appreciate if you could re-write this simple
> piece of C code in Python.
>
> Thank you,
>
> Robin
>
> #include "stdafx.h"
> #include <stdio.h>
> #include <math.h>
>
> float
> HoursWorked,PayRate,Overtime,IncomeTaxes,GrossPay,NetPay,TaxPayable,Overtime
> Hours;
>
> const float TaxRate=.23;
> const MinPay=300;
> const RegHours=40;
>
> main()
> {
>
> TaxPayable=0;
> Overtime=0;
> OvertimeHours=0;
>
>  printf("\nPlease enter the hours worked per week? ");
>  scanf("%f",&HoursWorked);
>
>  printf("\nPlease enter the rate of pay? ");
>  scanf("%f",&PayRate);
>
>  if (HoursWorked>RegHours)
>  {
>   OvertimeHours =HoursWorked-RegHours;
>   Overtime = (OvertimeHours)*(PayRate*1.5);
>  }
>
>  GrossPay = ((HoursWorked-OvertimeHours)*PayRate)+Overtime;
>
>  if (GrossPay>MinPay)
>  {
>   TaxPayable = (GrossPay-MinPay)*TaxRate;
>  }
>
>  NetPay = (GrossPay-TaxPayable);
>
>  printf("\nThe gross pay is %f",GrossPay);
>  printf("\nThe net pay is %f",NetPay);
>
>  return 0;
> }

--
Ken Seehof
kens at sightreader.com
starship.python.net/crew/seehof
Hi! I'm a .signature virus! copy me into your .signature file to help me spread!


-------------- next part --------------
A non-text attachment was scrubbed...
Name: 12klat.vcf
Type: text/x-vcard
Size: 343 bytes
Desc: Card for Ken Seehof
URL: <http://mail.python.org/pipermail/python-list/attachments/20000606/26319212/attachment.vcf>


More information about the Python-list mailing list