ICT 2013: COMPUTATIONAL
THINKING & CODING
ACTIVITY CLO3_1
COURSE LEARNING OUTCOME: CLO3
CHAPTERS:
COGNITIVE LEVELS: APPLY
AIM: WRITE SELECTION STATEMENTS AND ALGORITHMS
TOOLS: PYTHON/[Link]
PROCEDURE: CODING
DOCUMENT REVISION CONTROL: 1.0
Version Author Effective Date Change Description DCR No
1.0 Dr Madeleine Togher 1.0
1
EXERCISE 1-APPLY
Write a python program using selection that will read two different ages and display the
youngest age (use [Link]). Create an algorithm first using simple English words and then
translate it into the code.
Algorithm Solution
Read in a value and assign it to age1
Read in a value and assign it to age2
if the age1 is less than age2
assign age1 to youngest, print it
else
assign age2 to youngest, print it
Code Solution
age1= int(input("Enter the first person age: "))
age2= int(input("Enter the second person age: "))
if (age1 < age2):
young = age1
else:
young = age2
print ("The Youngest age is ", young)
EXERCISE 2 -APPLY
Write a program that displays a menu of two choices “1. Express, 2. Standard”. The user will
then select their option. The program should then display 4000 for express cost or 2500 for
stander visa processing (use [Link]). Create an algorithm first using simple English words and
then translate it into the code.
Screenshot
2
Algorithm Solution
Ask user to input a Visa Type of either 1 for Express or 2 for Standard
Read in the value entered and assign it to Visa Type
Reset the Visa Charge to 0
if the Visa Type is 1
assign 4000 to the Visa Charge
Else if the Visa Type is 2
assign 2500 to the Visa Charge
else
assign 0 to the visa charge
Print error message “invalid choice.”
print the Visa Charge
Solution
VisaType= int(input("Select the visa type? \[Link] \[Link]\n"))
VisaCharge=0
if (VisaType==1):
VisaCharge=4000
else:
VisaCharge=2500
print ("Visa Charge is ", VisaCharge)
EXERCISE 3-APPLY
Write a program that reads the student mark and absent percentage and display proper
message considering the pass mark is 60 and the course drop rate is 15%. Create an algorithm
first using simple English words and then translate it into the code.
Screenshot
3
Algorithm Solution
Ask user to input the mark
Read in the value entered and assign it to mark
if the mark >= 60
print pass
else
print fail
Ask user to input the absence rate
Read in the value entered and assign it to absence
if the absence >= 15
print drop from course
else
print continue on course
Solution
mark = input("Enter your mark: ")
mark = float(mark)
if (mark>=60):
print ("Pass")
else:
print ("Fail")
absence = input("Enter your absence percentage: ")
absence = float(absence)
if (absence>=15):
print ("Drop from the course ")
else:
print ("Continue the course")
EXERCISE 4 -APPLY
Write a program that displays a menu of two choices “1. UAE, 2. Non-UAE” and the user
will select his option, the program read the user age and display if he is eligible for the
National Medial Card or not. Users with UAE citizenship and age greater than 18 years old
4
are eligible (use [Link]). Create an algorithm first using simple English words and then
translate it into the code.
Screenshot
Algorithm Solution
Ask user to input a Nationality Code of either 1 for UAE or 2 for Non-UAE
Read in the value entered and assign it to Nationality Code
Ask user to input age
Read in the value entered and assign it to age
if the Nationality code is 1 and the age >= 18
print You are eligible for the National Medical Card
else
print You are NOT eligible for the National Medical Card
Solution
Ncode = input("Choose your nationality: \[Link] \[Link] UAE\n")
Ncode=int(Ncode)
age =input("Enter your age: ")
age=int(age)
if ((Ncode==1) and (age >= 18)):
print ("You are eligible for the National Medical Card")
else:
PRINT ("YOU ARE NOT ELIGIBLE FOR THE NATIONAL MEDICAL
CARD")
EXERCISE 5 -APPLY
5
Write a program that reads age of a person and displays “Entry restricted to mall” if the given
age is below 10 or above 69, otherwise display “You can enter the mall”(use [Link]). Create
an algorithm first using simple English words and then translate it into the code.
Algorithm Solution
Ask user to input age
Read in the value entered and assign it to age
if the age <10 or the age > 69
print Entry restricted to mall
else
print You can enter the mall
Solution
age =input("Enter your age: ")
age=int(age)
if ((age < 10) or (age > 69)):
print ("Entry restricted to mall ")
else:
PRINT ("YOU CAN ENTER THE MALL ")
CASE STUDY-COGNITIVE LEVEL
THIS CASE STUDY IS EXTRACTED FROM XXXX.
IT WILL BE INCLUDED IN ALL COURSE ACTIVITIES.
STUDENTS ARE INVITED TO WORK IN GROUP TO ANSWER
ALL QUESTIONS.
AUTHOR
AIM
CASE DESCRIPTION
QUESTIONS
1. Question 1 description
2. Question 1 description
3. Question 3 description
6
4. Question 4 description
5. Question 5 description
6. Question 6 description
Green color means these questions were solved in the previous activities
Black color indicates that the question be will treated in the current activity
Gray color means that these questions will be investigated during the upcoming activities