Professional Documents
Culture Documents
P3 - Yong Wai Kin
P3 - Yong Wai Kin
1. Write a program that will receive two integer items from a terminal operator, and display to
the screen their sum, difference, product and quotient. [Note that the quotient calculation
(first integer divided by second integer) is only being performed if the second integer does
not equal zero.]
num_1 = int(input("Please key in the number: "))
num_2 = int(input("Please key in the number: "))
quotient = (num_1/num_2)
if num_2 != 0:
quotient = num_1/num_2
print("Quotient = math error")
else:
print("Quotient = %.2f" %quotient)
2. Write a program that reads an employee’s number, hours worked, and hourly rate and
calculates his or her wages. All hours over 40 are paid at 1.5 times the regular hourly rate.
An extra bonus RM200 will be given to those who worked more than 100 hours in total.
id = input("Insert your employee id: ")
hours = float(input("Hours work: "))
rate = float(input("rate per hour:RM "))
if hours>40:
if hours>100:
wages=40*rate+((hours-40)*1.5*rate)+200
else:
wages=40*rate+((hours-40)*1.5*rate)
else:
wages=hours*rate
Age Fee
>55 RM 7
13-55 RM 10
3-12 RM 5
<3 Free
age = int(input("Please enter age: "))
if age<= 55:
if age < 13:
if age< 3:
print("Free")
else:
print("Fee:RM5")
else:
print("Fee: RM10")
else:
print("Fee: RM7")