You are on page 1of 2

FHCT1022 PROGRAMMING CONCEPTS

PRACTICAL 3: Selection Control Structure

Develop a complete Python program for each question.

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: "))

summation = (num_1 + num_2)


subtraction = (num_1 - num_2)
product = (num_1 * num_2)

print("Summation =", summation)


print("subtraction =", subtraction)
print("product =", product)

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

print("Your pay is RM%.2f"%wages)


3. An Admission charge for The Little Rep Theater varies according to the age of the person.
Develop a program to print out the ticket charge given the age of the person. The charges are
as follows:

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")

You might also like