Question: THE HONG KONG POLYTECHNIC UNIVERSITY Computer Programming ( ENG 2 0 0 2 ) Class 5 Programming Test 1 Name: q , Student No .

THE HONG KONG POLYTECHNIC UNIVERSITY Computer Programming (ENG2002) Class 5 Programming Test 1
Name: q, Student No.q,
A. Instructions
Create a folder yyyyyyyy, where yyyyyyyy stands for your student ID number (omitting the last letter 'D') under PolyU Home Drive (P: ). All your Jupyter Notebook files should be stored under this folder yYYYyYyy. Note: this drive and folder location MUST be strictly followed. Do NOT use anv other locations.
At the beginning of each Python program file, add a comment to show your student ID and name.
This paper comprises 3 parts. You may use a new Jupyter Notebook file for each part. Create the files under the folder you created in Step 1.
It is an open-book test; any documents, online or offline, can be consulted during the test.
Your programs need to be well commented. Lacking comments will result in down-grading.
Your programs need to have a good structure. Never write a long program without calling functions.
Do NOT use any techniques that were not mentioned in the lessons. Also, do NOT call a function recursively, i.e., call functionA () inside functionA ().
Do NOT import any library module (except math).
Save your files frequently to avoid any accidental loss of data.
After the test, upload the three Jupyter Notebook files under the yYyYyyYy folder to Blackboard as attachments. (Click the switch "Browse Local Files".)
Time allowed: 1 hour 45 minutes.
B. The Programming Task
Background
It is given that the cosine function can be approximated by a series of summation and subtraction of many terms:
cos(x)=k=0(-1)k(x2k(2k)!)~~1-x221+x44321-x6654321+x887654321-cdots
where kx(2k)2k(2k)(2k)(2k-1)cdots21cos(-1.571)=-0.00020367~~1-ubrace((-1.571)221ubrace){:[Firstterm]k=1+ubrace((-1.571)44321ubrace){:[Secondterm]k=2-(-1.571)6654321+cdotsq-3.1416.It should be noted that kis the term number, xis measured in radian, and (2k)!isto find the factorial of2k, which is given by(2k)(2k)(2k-1)cdots21. For example,
cos(-1.571)=-0.00020367~~1-ubrace((-1.571)221ubrace){:[Firstterm]k=1+ubrace((-1.571)44321ubrace){:[Secondterm]k=2-(-1.571)6654321+cdots
Q1. Create a new Jupyter Notebook file with the name "PT1Q1".On starting, the application should cal function showMenu () that shows the following main menu:
[t] Get a term in cosine function
[a] Get the terms in cosine function
[c] Get cosine ofan angle in radian
[q] Quit
State your choice (t,a,c,orqto quit):THE HONG KONG POLYTECHNIC UNIVERSITY Computer Programming (ENG2002) Class 5 Programming Test 1
Name: q, Student No.q,
A. Instructions
Create a folder yyyyyyyy, where yyyyyyyy stands for your student ID number (omitting the last letter 'D') under PolyU Home Drive (P: ). All your Jupyter Notebook files should be stored under this folder yYYYyYyy. Note: this drive and folder location MUST be strictly followed. Do NOT use anv other locations.
At the beginning of each Python program file, add a comment to show your student ID and name.
This paper comprises 3 parts. You may use a new Jupyter Notebook file for each part. Create the files under the folder you created in Step 1.
It is an open-book test; any documents, online or offline, can be consulted during the test.
Your programs need to be well commented. Lacking comments will result in down-grading.
Your programs need to have a good structure. Never write a long program without calling functions.
Do NOT use any techniques that were not mentioned in the lessons. Also, do NOT call a function recursively, i.e., call functionA () inside functionA ().
Do NOT import any library module (except math).
Save your files frequently to avoid any accidental loss of data.
After the test, upload the three Jupyter Notebook files under the yYyYyyYy folder to Blackboard as attachments. (Click the switch "Browse Local Files".)
Time allowed: 1 hour 45 minutes.
B. The Programming Task
Background
It is given that the cosine function can be approximated by a series of summation and subtraction of many terms:
The user is expected to enter a character of 't','a','c' or '
THE HONG KONG POLYTECHNIC UNIVERSITY Computer

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!