Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

M110: Python Programming

Tutor-Marked Assignment (TMA) Spring 22/23

Cut-Off Date: Based on the Published Deadline.


Total Marks: 30 marks turned to 15 marks

Contents
Warnings and Declaration…………………………………….………………………………......1
Question 1 ……………….…………………………………. ………………………………...…..2
Question 2 ………………………………………………………………………………….…..…..2-3
Question 3 ………………………………………………………………………………….…..…..3

Plagiarism Warning:
As per AOU rules and regulations, all students are required to submit their own TMA
work and avoid plagiarism. The AOU has implemented sophisticated techniques for
plagiarism detection. You must provide all references in case you use and quote
another person's work in your TMA. You will be penalized for any act of plagiarism as
per the AOU's rules and regulations.

Declaration of No Plagiarism by Student (to be signed and submitted by student


with TMA work):

I hereby declare that this submitted TMA work is a result of my own efforts and I have
not plagiarized any other person's work. I have provided all references of information
that I have used and quoted in my TMA work.
Name of Student:……………………………..
Signature:…………………………………………...
Date:…………………………………………………

M110 / TMA Page 1 of 3 2022/2023 Spring


Question 1:(10 marks)
Given the problem specification below, you are asked to answer the corresponding
questions: Problem specification:
We need to calculate the average salary for a group of employees, given their individual
salaries.
As such, we should prompt the user to enter the salaries one by one and should continue
prompting until the user enters a negative number to indicate the end of the entries.

a- Draw the flowchart that represents the above problem. (4 marks)


b- Write down the pseudocode of the above problem. (3 marks)
c- Write the Python code of the above problem. Include a screenshot that shows the
output after executing the program. (3 marks)

Question 2:(10 marks)


Turtle Graphics is a Python feature like a drawing board, which lets us command a turtle
to draw all over it! We can use functions like forward(…) and right(…) which can move the
turtle around. Commonly used turtle methods are found in the posted pdf file “turtle —
Turtle graphics — Python 3.10.2 documentation”
To make use of the turtle methods and functionalities, we need to import turtle. “turtle”
comes packed with the standard Python package and need not be installed externally.
The roadmap for executing a turtle program follows 3 steps:
a- Import the turtle module.
b- Create a turtle to control.
c- Draw around using the turtle methods.

Problem: Based on the material presented in SS1 lecture and referring to the above
reference, write a python program that produces the below diagram.

M110 / TMA Page 2 of 3 2022/2023 Spring


Instructions:
- You should use different colors for the squares.
- You can choose any side’s length for each square, keeping the general view of the
output similar to the given diagram.
- You might place the desired colors in a list to access them by index in the drawing
loop.
- Make sure to properly set the starting position (x & y) of your drawing, to maintain
the above diagram.

Question 3:(10 marks)


Based on what have learned in lecture 8 in addition to some research that you should do
a- Write a Python code that creates the below file.

- You should prompt the user to input the name of the file. (Use your first name as
the file’s name to be entered).
- Use your last five university ID numbers to input the values.
For example, if your ID is 2315161678235, then you will use the numbers 7,8,2,3, and
5 as the values to be entered and added to the list that should show in the file.
b- Write a Python code that reads the above file content, and displays the list as shown
below.

c- Assemble both parts in one program and run it, show a screenshot of your program
and its output in addition to a screenshot of the text file that has been created.

End of TMA

M110 / TMA Page 3 of 3 2022/2023 Spring

You might also like