SKHCYSS S.
3 ICT
Python Assignment 3
Section B: Questions (Total 15 marks)
1. Given that 1 US dollar = 7.8 HK dollar. Ask the user to input if he/she wants to convert from
HK$ to US$, or from US$ to HK$. Then ask the user to input the amount of money and
convert it to the equivalent amount in the other currency. (10m)
Sample 1
Please input 1 (HK to US) or 2 (US to HK) : 1
Please input the amount of HK$: 100
You have US$ 12.82
Sample 2
Please input 1 (HK to US) or 2 (US to HK) : 2
Please input the amount of US$: 100
You have HK$ 780
Sample 3
Please input 1 (HK to US) or 2 (US to HK) : 3
Wrong choice.
-
Write your code in the following spaces:
C =
int Sinput 1"Please input 1)HK to US) or 2 (US to HK)")(
if c = = 1 :
m =
=
int (input ("Please in put the amount of HK$")
m =
m //7 8 .
print ("You have US$" m) ,
elifc == 2 :
amount of USD "()
:
int (input ("Please input
the
m =
=
+
m =
m 7 8
US$ m)
.
print !"You have ,
print ( "Wrong choice")
else
2. Write a Python program for a bank to decide whether a loan should be offered or not. (5m)
● The customer’s age and income are input by the user in response to meaningful
prompts.
- -
● The bank will offer a customer a loan if he/she is 21 or over and has an annual income of
at least HK$200000.
● One of the following messages should be printed as the output result.
○ Congratulation, we will offer you a loan.
○ Sorry we cannot offer you a loan.
Write your code in the following spaces:
age
= int (input /"Please input age")
input annual income")
income = int (input ("Please your
if age 20000 :
21 and > =
= income
print ("Congratulation we will offer you a
loan .
")
else :
print ("Sorry "
!
we cannot offer
you
a loan