INTERNATIONAL FOUNDATION YEAR
Computer Science
Portfolio Tasks Exemplar - Answer Booklet
Note:
The total marks for this Portfolio is 100.
Instructions to Students
● You should answer these questions individually after the practice exercises for
the topic you are studying. You can ask your tutor for advice if you have
difficulty.
● You should paste your answers to the portfolio questions in a portfolio
answer booklet and upload it the VLE.
● For a program, you should include the code and a screen shot of
the output.
● The first three lines of a program should be comments consisting of
• # Your Name
• # Portfolio exercise x, where x is the portfolio question number.
• # Brief description of program purpose
● You should save the program in a file called Px.py.
● You should complete the exercises during the week(s) indicated and submit
your portfolio to your tutor for assessment and feedback every 3 weeks.
Name: Tribhuban Chakma
© NCUK Ltd 2023 IFYCO001 Computer Science Portfolio Task Exemplar - Answer Booklet v1.2
Portfolio activities Marks Award
Available ed
Marks
1. Explaining why Python is one of the most widely used programming languages. Identify and describe TWO (2) applications
written in Python. Briefly describe THREE other programming languages and their application areas. Briefly describe 5
disadvantages of Python compared to other programming languages. Your answer should be around 250 words.
Write your answer here (250 words): Teacher Feedback:
Ans:-
Python is one of the current generation programming languages due to its readability, well structured and can handle
multiple requests. It has the capability to enable developer to write shorter codes and not complex ones effectively
and that’s why it’s held in high esteem by developers. Some of these are YouTube and Dropbox. YouTube utilizes
Python for handling data volumes and real-time user interactivity and Dropbox uses Python for its web and graphical
interfaces making features updates and complex changes easier.
For that, recognizing that other programming languages are optimized for different things is also useful. Java which
utilizes virtual machine technology simply means Java Virtual Machine (JVM) is mostly used in developing enterprise
systems, Android, and web applications. It has a very strong typing which enables it to bear high traffic and
complicated business applications. C++ has computing resource control capabilities, and it excels as system
programming, video games and real time simulations. Scratch; the learning language allows children to learn coding
through the block -based approach in creating games and projects.
But to a certain extent, Python has its problems. Due to the fact that it is an interpreted language it is generally
slower than the compiled typed languages such as C++ and Java. Further, it has a flexible scoping of variables results
in catching errors during runtime as opposed to the statically typed language.
Portfolio activities Marks Awarded
Available Marks
2. Write and run a python program to print the following three lines: The first and third line should comprise a line of stars (*).
The second line should be your name. 5
Write your answer here: Teacher Feedback:
Portfolio activities Marks Awarded
Available Marks
3. Explain the meaning of the term ‘syntax error’.
a) Introduce a syntax error into your program.
b) Add a screenshot to your portfolio of the results of attempting to run the program. Explain the meaning of the error 5
message(s).
Write your answer here: Teacher Feedback:
Ans:- Syntax errors are mistakes in the source code, such as spelling and punctuation errors, incorrect
labels, and so on, which cause an error message to be generated by the compiler.
(a) In this program, the syntax error which I had made was that to enter an output without the use of
an double inverted comma at one side.
(b)
Portfolio activities Marks Awarded
Available Marks
4. Explain what is meant by operator precedence in arithmetic
(a) Write a program to show the python precedence rules for arithmetic operators. Your program should include suitable
5
explanatory print statements and comments. For high marks your program should use + - * / % ** //
Teacher Feedback:
Portfolio activities Marks Awarded
Available Marks
5. Design and write a program that calculates the perimeter and area of a rectangle. The program should:
a. Print your name and the purpose of the program.
b. Prompt for the length of the rectangle and Input a value
c. Prompt for the width of the rectangle and input a value 5
d. Calculate the area and perimeter
e. Output the area and perimeter with suitable messages.
Write your answer here: Teacher Feedback:
Write your answer here: Teacher Feedback:
Portfolio activities Marks Awarded
Available Marks
6. Explain the meaning of the term ‘logic error’.
a. Introduce one into your program to calculate area/perimeter of a rectangle 5
a) Add a screen shot of the results to your portfolio and explain what is wrong with the program.
Write your answer here: Teacher Feedback:
Logic errors occur when there is a fault either in the logic or in the structure of the problem. Logic errors do not cause a program to
crash. However, logic errors can cause a program to produce unexpected results.
(a),(b) In the code below, the formula for the perimeter of a rectangle is made deliberately wrong. The perimeter is calculated as
length + width, while the correct formula should be 2 * (length + width).
# Tribhuban Chakma
# Portfolio exercise 6, where 6 is the portfolio question number.
# The purpose of this program is to show how a logical error made does not clash the whole program
length= int(input(" The length recorded is:"))
width= int(input("The width to be recorded is:"))
area_of_rectangle= length * width
perimeter_of_rectangle= length + width
print("The area of rectangle is",area_of_rectangle,".The perimeter of the rectangle is",perimeter_of_rectangle,".")
Portfolio activities Marks Awarded
Available Marks
7. Design and write a program to calculate the area and circumference of a circle. The program should
a. Import the math module.
b. Print your name and the purpose of the program.
c. Prompt for the radius of the circle and Input a value, which should be a floating-point number. 5
d. Calculate the area and circumference using the value of pi from the math module.
e. Round the area and circumference to 2 d.p.
a) Output the area and circumference with suitable messages, all on one line.
Write your answer here: Teacher Feedback:
# Tribhuban Chakma
# Portfolio exercise 7, where 7 is the portfolio question number.
# The purpose of this program is to calculate
# and display the area and circumference of a circle based on user provided radius.
import math
radius= float(input("The radius entered is:"))
Area_of_circle= math.pi * radius**2
circumference= 2*math.pi*radius
area_rounded= round(Area_of_circle,2)
circumference_rounded = round(circumference,2)
print ("My name is Tribhuban Chakma", ". The purpose of this program is to calculate")
print ("and display the area and circumference of the circle.")
print (".The area of circle is",area_rounded)
print (". While the circumference is", circumference_rounded)
Portfolio activities Marks Awarded
Available Marks
8. Design and write a program using turtle graphics to draw an approximation to the initial letters of your name on a background colour of your
choice. The program should
a. Import the turtle module
b. Create the window,
c. Set the background colour
d. Set the window title to your name. 5
e. Create a turtle object and assign it to a variable with a suitable name
f. Set the turtle pen colour and pen size, put the pen down.
g. Use the turtle built-in functions to draw out an approximation to the initial letters of your name. You may have to look up the turtle
graphics function calls (methods). These are described in the python documentation. It is not the most easy to read, but as a
programmer you will need to become familiar with it. https://docs.python.org/3/library/turtle.html
Write your answer here: Teacher Feedback:
# Tribhuban Chakma
# Portfolio exercise 8, where 8 is the portfolio question number.
#The intention of this question is to write number of Python code with turtle graphics module
# which will draw the user’s initial using turtle graphics
# along with the option for setting the window appearance and turtle characteristics.
# Import the turtle module
import turtle
# Create the window
window = turtle.Screen()
# Set the background color
window.bgcolor("Green")
# Set the window title to your name
window.title("Tribhuban")
# Create a turtle object and assign it to a variable
pen = turtle.Turtle()
# Set the turtle pen color and pen size, and put the pen down
pen.pencolor("darkblue")
pen.pensize(4)
# Speed up the drawing
pen.speed(3)
# Draw the letter "C"
pen.penup()
pen.goto(-100, 50) # Starting position for "C"
pen.pendown()
pen.setheading(0)
pen.circle(50, 180) # Semi-circle for "C"
# Draw the letter "G"
pen.penup()
pen.goto(50, 50) # Starting position for "G"
pen.pendown()
pen.setheading(0)
pen.circle(50, 270) # Three-quarters circle
pen.penup()
pen.goto(50, 0) # Short line inside "G"
pen.setheading(0)
pen.pendown()
pen.forward(30)
# Finish up
pen.hideturtle()
# Keep the window open until clicked
window.mainloop()