Wa0042
Wa0042
Tanbin Ahmed
DOC-20250131-WA0042.docx
yiukfyuj
PAW
Accounting Department
Document Details
Submission ID
trn:oid:::1:3142192811 31 Pages
Download Date
File Name
DOC-20250131-WA0042.docx
File Size
2.3 MB
Quoted Text
0 Missing Citation 0%
Matches that have quotation marks, but no in-text citation
0 Missing Citation 0%
Matches that have quotation marks, but no in-text citation
Top Sources
The sources with the highest number of matches within the submission. Overlapping sources will not be displayed.
1 Internet
www.coursehero.com 22%
2 Internet
philosophy-question.com 2%
3 Internet
support.rocketleague.com <1%
4 Internet
memoria.ifrn.edu.br <1%
5 Publication
6 Publication
Computer Science
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 this portfolio answer
booklet.
1 ● 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.
6 1. Explain why Python has become one of the most popular programming languages. Include examples of two real-world applications
built with Python and discuss their impact. Additionally, explain why Python is often recommended as an easier language for beginners 15
1 to learn. Your response should be approximately 250 words.
2. Write and run a Python program to print the following five lines: The first and fifth line should comprise a line of hashtags (#). The
second, third and fourth line should be your name, eye colour and your favourite movie.
3. Explain the meaning of the term ‘syntax error’ by modifying your program from question 2.
1 a) Introduce a syntax error into your program.
a. Add a screen shot to your portfolio of the results of attempting to run the program. Explain the meaning of the error
message(s).
1 Ans:- Python is one of the current generation programming languages due to its readability, well structured
and can handle multiple requests. Python appeals to diverse programmers through its simple syntax that enables both beginner-friendly
interface alongside expert productivity alongside its ability to work with different programming paradigms. Through its expansive standard
library alongside its broad collection of third-party libraries Python enables development across web development and artificial
intelligence as well as data analysis and machine learning and automation technology. The open-source platform together with its devoted
supportive community enables both extensive learning resources and sustained development. The combination of industry demand and
emerging technology capabilities and its flexible character has established Python as a dominant programming language.
Python remains the recommended programming language for beginners because its syntax looks like natural language while remaining
easy to learn and code with. Python achieves proper code structure through indentation which replaces traditional symbols commonly
1 used for braces. The versatility of Python allows programmers to learn from three programming paradigms including procedural and
Page 5Booklet
Portfolio 24-25 Answer of 34 - Integrity Submission © NCUK Ltd 2024 2 Submission ID trn:oid:::1:3142192811
Page 6 of 34 - Integrity Submission Submission ID trn:oid:::1:3142192811
object-oriented and functional programming. Through its rich standard library and wide array of third-party modules beginners can
construct applications from web development to data processing without difficulty. Top among its benefits for new programmers is the
Python community along with the plentiful learning resources such as tutorials and forums that offer first-rate support.
2 Ans:-
Page 6Booklet
Portfolio 24-25 Answer of 34 - Integrity Submission © NCUK Ltd 2024 3 Submission ID trn:oid:::1:3142192811
Page 7 of 34 - Integrity Submission Submission ID trn:oid:::1:3142192811
2 3 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.
Page 7Booklet
Portfolio 24-25 Answer of 34 - Integrity Submission © NCUK Ltd 2024 4 Submission ID trn:oid:::1:3142192811
Page 8 of 34 - Integrity Submission Submission ID trn:oid:::1:3142192811
(b)
Page 8Booklet
Portfolio 24-25 Answer of 34 - Integrity Submission © NCUK Ltd 2024 5 Submission ID trn:oid:::1:3142192811
Page 9 of 34 - Integrity Submission Submission ID trn:oid:::1:3142192811
Page 9Booklet
Portfolio 24-25 Answer of 34 - Integrity Submission © NCUK Ltd 2024 6 Submission ID trn:oid:::1:3142192811
Page 10 of 34 - Integrity Submission Submission ID trn:oid:::1:3142192811
1 4. Write a Python program that shows the precedence rules Python applies to multiplication, division, and addition of three numbers
5
Page 10
Portfolio 24-25 Answer of 34 - Integrity Submission
Booklet © NCUK Ltd 2024 7 Submission ID trn:oid:::1:3142192811
Page 11 of 34 - Integrity Submission Submission ID trn:oid:::1:3142192811
Page 11
Portfolio 24-25 Answer of 34 - Integrity Submission
Booklet © NCUK Ltd 2024 8 Submission ID trn:oid:::1:3142192811
Page 12 of 34 - Integrity Submission Submission ID trn:oid:::1:3142192811
Page 12
Portfolio 24-25 Answer of 34 - Integrity Submission
Booklet © NCUK Ltd 2024 9 Submission ID trn:oid:::1:3142192811
Page 13 of 34 - Integrity Submission Submission ID trn:oid:::1:3142192811
Page 13
Portfolio 24-25 Answer of 34 - Integrity Submission
Booklet © NCUK Ltd 2024 10Submission ID trn:oid:::1:3142192811
Page 14 of 34 - Integrity Submission Submission ID trn:oid:::1:3142192811
1 5. Design and write a program that calculates the perimeter and area of a triangle. The program should:
a. Import the Math module
1 b. Print your name and the purpose of the program.
1 c. Prompt for the length of each of the 3 sides of the triangle and input each value.
d. Calculate the area and perimeter of the triangle.
e. Output the area and perimeter with suitable messages. 10
1
6. Explain the meaning of the term ‘logic error’.
a. Introduce one into your program to calculate area/perimeter of a triangle.
b. Add a screen shot of the results to your portfolio and explain what is wrong with the program.
Page 14
Portfolio 24-25 Answer of 34 - Integrity Submission
Booklet © NCUK Ltd 2024 11Submission ID trn:oid:::1:3142192811
Page 15 of 34 - Integrity Submission Submission ID trn:oid:::1:3142192811
Page 15
Portfolio 24-25 Answer of 34 - Integrity Submission
Booklet © NCUK Ltd 2024 12Submission ID trn:oid:::1:3142192811
Page 16 of 34 - Integrity Submission Submission ID trn:oid:::1:3142192811
Page 16
Portfolio 24-25 Answer of 34 - Integrity Submission
Booklet © NCUK Ltd 2024 13Submission ID trn:oid:::1:3142192811
Page 17 of 34 - Integrity Submission Submission ID trn:oid:::1:3142192811
1 7. Design and write a program to calculate the area and circumference of a circle. The program should
a. Import the math module.
1 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
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.
f. Output the area and circumference with suitable messages, all on one line.
Page 17
Portfolio 24-25 Answer of 34 - Integrity Submission
Booklet © NCUK Ltd 2024 14Submission ID trn:oid:::1:3142192811
Page 18 of 34 - Integrity Submission Submission ID trn:oid:::1:3142192811
Page 18
Portfolio 24-25 Answer of 34 - Integrity Submission
Booklet © NCUK Ltd 2024 15Submission ID trn:oid:::1:3142192811
Page 19 of 34 - Integrity Submission Submission ID trn:oid:::1:3142192811
Page 19
Portfolio 24-25 Answer of 34 - Integrity Submission
Booklet © NCUK Ltd 2024 16Submission ID trn:oid:::1:3142192811
Page 20 of 34 - Integrity Submission Submission ID trn:oid:::1:3142192811
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,
4 but as a programmer you will need to become familiar with it. https://docs.python.org/3/library/turtle.html
Page 20
Portfolio 24-25 Answer of 34 - Integrity Submission
Booklet © NCUK Ltd 2024 17Submission ID trn:oid:::1:3142192811
Page 21 of 34 - Integrity Submission Submission ID trn:oid:::1:3142192811
Page 21
Portfolio 24-25 Answer of 34 - Integrity Submission
Booklet © NCUK Ltd 2024 18Submission ID trn:oid:::1:3142192811
Page 22 of 34 - Integrity Submission Submission ID trn:oid:::1:3142192811
Page 22
Portfolio 24-25 Answer of 34 - Integrity Submission
Booklet © NCUK Ltd 2024 19Submission ID trn:oid:::1:3142192811
Page 23 of 34 - Integrity Submission Submission ID trn:oid:::1:3142192811
Page 23
Portfolio 24-25 Answer of 34 - Integrity Submission
Booklet © NCUK Ltd 2024 20Submission ID trn:oid:::1:3142192811
Page 24 of 34 - Integrity Submission Submission ID trn:oid:::1:3142192811
Page 24
Portfolio 24-25 Answer of 34 - Integrity Submission
Booklet © NCUK Ltd 2024 21Submission ID trn:oid:::1:3142192811
Page 25 of 34 - Integrity Submission Submission ID trn:oid:::1:3142192811
9. Design and write a program incorporating a user-defined function. You should base the program on the code you wrote for Portfolio
exercise 8. 15
● The function should take one parameter (turtleShape) and should draw the initials using turtle graphics code you wrote in steps f, g
of Portfolio exercise 8.
● The program should initialise the window, turtle, background colour as in steps a-e and then call the function to draw your initials,
where the shape of the turtle is a circle. It should then call the function again to draw your initials where the icon is a square.
10. Modify program 9 to include TWO (2) more parameters (x,y), which represent the co-ordinates at which the turtle starts drawing.
The first line of the function should move the turtle to those co-ordinates. (Look up the goto(x,y) method).
11. Explain the benefits of using functions and modular software, giving TWO examples, including ONE from your portfolio exercises.
Page 25
Portfolio 24-25 Answer of 34 - Integrity Submission
Booklet © NCUK Ltd 2024 22Submission ID trn:oid:::1:3142192811
Page 26 of 34 - Integrity Submission Submission ID trn:oid:::1:3142192811
Page 26
Portfolio 24-25 Answer of 34 - Integrity Submission
Booklet © NCUK Ltd 2024 23Submission ID trn:oid:::1:3142192811
Page 27 of 34 - Integrity Submission Submission ID trn:oid:::1:3142192811
Page 27
Portfolio 24-25 Answer of 34 - Integrity Submission
Booklet © NCUK Ltd 2024 24Submission ID trn:oid:::1:3142192811
Page 28 of 34 - Integrity Submission Submission ID trn:oid:::1:3142192811
12. Design and write a user-defined function that takes an integer parameter representing the level of discount obtained based on
amount of sales. It should return the discount according to the following table:
Sales Discount
0-9 No discount
3 10-19 Bronze
20-29 Silver
30-39 Gold
>=40 Platinum 10
a) The function should include validation so that if any other number is entered (negative or >100) the function should return
the string “Error out of range” (You have no need to check for non-integer inputs in this program).
b) The main program should input a number from the user (with suitable prompt), call the function and print the grade.
c) The program should first line of the program should be a comment with the content: Portfolio exercise 11.
13. Create a test plan and include it in your portfolio. It should show input, expected output and actual output for a suitable range of test
data.
Page 28
Portfolio 24-25 Answer of 34 - Integrity Submission
Booklet © NCUK Ltd 2024 25Submission ID trn:oid:::1:3142192811
Page 29 of 34 - Integrity Submission Submission ID trn:oid:::1:3142192811
12 Ans:-
Page 29
Portfolio 24-25 Answer of 34 - Integrity Submission
Booklet © NCUK Ltd 2024 26Submission ID trn:oid:::1:3142192811
Page 30 of 34 - Integrity Submission Submission ID trn:oid:::1:3142192811
Page 30
Portfolio 24-25 Answer of 34 - Integrity Submission
Booklet © NCUK Ltd 2024 27Submission ID trn:oid:::1:3142192811
Page 31 of 34 - Integrity Submission Submission ID trn:oid:::1:3142192811
Page 31
Portfolio 24-25 Answer of 34 - Integrity Submission
Booklet © NCUK Ltd 2024 28Submission ID trn:oid:::1:3142192811
Page 32 of 34 - Integrity Submission Submission ID trn:oid:::1:3142192811
13 Ans:-
Page 32
Portfolio 24-25 Answer of 34 - Integrity Submission
Booklet © NCUK Ltd 2024 29Submission ID trn:oid:::1:3142192811
Page 33 of 34 - Integrity Submission Submission ID trn:oid:::1:3142192811
Page 33
Portfolio 24-25 Answer of 34 - Integrity Submission
Booklet © NCUK Ltd 2024 30Submission ID trn:oid:::1:3142192811
Page 34 of 34 - Integrity Submission Submission ID trn:oid:::1:3142192811
Page 34
Portfolio 24-25 Answer of 34 - Integrity Submission
Booklet © NCUK Ltd 2024 31Submission ID trn:oid:::1:3142192811