Example of Python code (C code to Python code)

Robin Porter mogul at primus.ca
Tue Jun 6 21:08:45 EDT 2000


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;
}






More information about the Python-list mailing list