*******PLEASE ANSWER QUESTION C******* Question 4 (23 marks) This question tests your understanding of Block 1 Part 4. A

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

*******PLEASE ANSWER QUESTION C******* Question 4 (23 marks) This question tests your understanding of Block 1 Part 4. A

Post by answerhappygod »

*******PLEASE ANSWER QUESTION C*******
Question 4 (23 marks)
This question tests your understanding of Block 1 Part
4.
A program is required to print the age of a student on the
cut-off date for this TMA (5 May 2022).
The program will take three integers to represent the day, month
and year of a person’s birth date. For example, if a person was
born on 23 September 1998, the three integers would be 23, 9 and
1998. You can assume that the month of the birthday is represented
by an integer between 1 and 12 (inclusive) and that the day an
integer valid for that month. The year will be an integer from 1922
to 2010 inclusive.
The program should output a string of the form
On 5 May 2022 I am xx years old
Where xx is the age of the person on 5 May
2022
You are given the following test data and an incomplete and
error-filled program which you can download from the assessment
page.
Table 3: Test table for Birthday problem
# Problem: Check how old you are on 5 May 2022
# Input: day of birthday as an integer from 1 to 31
# Input: month of birthday as an integer from 1 to 12
# Input: year of birthday as an integer from 1922 to 2010
day = 2
month = 3
year = 1998
# Calculate age based only on year
age = 2022 – year
# Adjust for month
if month > 5 :
if month == 5 and day <= 5
print('On 5 May 2022 I am age ' , age , years old')
a.
(5 marks)
b.
(8 marks)
c.
(6 marks)
d.This part of the question involves writing Python code. Name
your Python file Q4_OUCU.py, where ‘OUCU’ is your OU computer
username, e.g. abc123. Write your code in this file. Then include
the code file in your TMA zip file.
Produce code corresponding to your algorithm. Include comments.
Use the test table to check your code works. You do not need to
submit test outputs.
Paste your completed Python code into your solution document as
text.
(4 marks)
(Total 23 marks)
-------------------------
Pattern 4.3
Please Answer Question C Question 4 23 Marks This Question Tests Your Understanding Of Block 1 Part 4 A 1
Please Answer Question C Question 4 23 Marks This Question Tests Your Understanding Of Block 1 Part 4 A 1 (17.39 KiB) Viewed 34 times
Pattern 4.2
Please Answer Question C Question 4 23 Marks This Question Tests Your Understanding Of Block 1 Part 4 A 2
Please Answer Question C Question 4 23 Marks This Question Tests Your Understanding Of Block 1 Part 4 A 2 (24.01 KiB) Viewed 34 times
Pattern 4.3 Case analysis (multiple cases) (B1 P4, p. 217) (Generates an output that depends on a case-by-case analysis of the inputs from multiple cases and appropriate selection.) 1 initialise the input variables 2 if the input values fall into the first case: 2a calculate the outputs according to the first case 3 if input values fall into the second case: 3a calculate the outputs according to the second case 4 etc. 01 print the outputs
Pattern 4.2 Case analysis (two cases) (B10 P4, p. 209) (Generates an output that depends on a case-by-case analysis of the inputs from two cases and appropriate selection.) 1 initialise the input variables 2 if the input values fall into the first case: 2a compute the outputs according to the first case 3 otherwise За compute the outputs according to the second case 4 print the outputs The selection of which case to handle (step 2) is always based on a Boolean expression, i.e. an expression that has a true or false value. The expression must capture the condition for the first case, i.e. if the expression is true, it must be the first case; if it is false it must be the second case, by elimination.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply