1. Dictionary. Write a function which takes dates in the DD-MM-YYYY (e.g XXXXXXXXXXformat as argument and returns the date in the DD/Mon/YYYY format (e.g. 01/Dec/2020). Perform the following checks:...

1 answer below »
1. Dictionary. Write a function which takes dates in the DD-MM-YYYY (e.g. 01- 12-2020) format as argument and returns the date in the DD/Mon/YYYY format (e.g. 01/Dec/2020). Perform the following checks: (a) Check that the input string indeed contains 2 dashes. (b) Use the string method string.isdigit() to check that the date, month and year field contains only digits. (c) Check that day numbers are between 1 and 31 and month numbers between 1 and 12. If any of these tests fails, print out Wrong format. Use a dictionary to look up the conversion from month number to string. Call this function from a loop in the main program. The loop should read dates from the keyboard in the DD-MM-YYYY format (prompt the user for the expected format). Call the function and print the converted format. The loop should be terminated if an empty string is entered (i.e. the user just hitting return). [20 marks] 2. Parametric plot. Write a function which plots this parametric trigonometric polynomial: ρ = (sin(1.2t))m + (cos(6.0t))n + 1.2 x = cos(t) ∗ ρ y = sin(t) ∗ ρ For t use the range from 0 to 10. Pick a high enough number of points to create a smooth curve. m and n should be optional arguments of the function. Pick default values producing a nice plot (I liked m = 8 and n = 5, but please experiment). The curve should be plotted in blue. Label the plot. Values of m and n should be printed as the title of the figure. The main program should read in values of m and n. If the user enters nothing (i.e. just hits return), the function should be called without arguments (i.e. the default values of m and n used). [20 marks] 1 3. Ellipsoid. This question concerns an ellipsoid with semi-major axes a, b, c aligned with the x, y and z directions, respectively. Write a function that produces a 3D plot of the ellipsoid. Arguments should be semi-major axes a, b, c and an optional argument for the number of grid lines to be plotted. Pick colours for the surface and the grid lines (edges) to produce a good contrast. To make the ellipsoid look like an ellipsoid with appropriate aspect ratios, set the x, y and z limits to the maximum of the semi-major axes. Your program should read in values for a, b and c and produce the plot. [15 marks] Total for this assignment: [55 marks] Deadline for the submission: 7 January 2021, 23:59 Electronic submission using the assignment tab on the module page. Your submission should include • For all questions: the program codes as .py file. • Submissions in Jupyter Notebook format are also welcome. • Your code should be executable and not stop with error messages (if correct input is entered, of course). If you tried parts, but did not succeed completely, block comment it and add a comment # working marks at the beginning, like: #working marks #if a>b # print (’The first number is larger’)
Answered Same DayJan 06, 2021

Answer To: 1. Dictionary. Write a function which takes dates in the DD-MM-YYYY (e.g XXXXXXXXXXformat as...

Swapnil answered on Jan 07 2021
143 Votes
74320/assignment3-vjz0bbdr-vcl4m5de.pdf
5PAM1023 Programming
CW3: Assignment 3
1. Dictionary. Write a function which takes dates in the DD-MM-YYYY (e.g. 01-
12-2020) format as argument and retur
ns the date in the DD/Mon/YYYY format
(e.g. 01/Dec/2020). Perform the following checks:
(a) Check that the input string indeed contains 2 dashes.
(b) Use the string method string.isdigit() to check that the date, month and year
field contains only digits.
(c) Check that day numbers are between 1 and 31 and month numbers between 1
and 12.
If any of these tests fails, print out Wrong format. Use a dictionary to look up the
conversion from month number to string.
Call this function from a loop in the main program. The loop should read dates
from the keyboard in the DD-MM-YYYY format (prompt the user for the expected
format). Call the function and print the converted format. The loop should be
terminated if an empty string is entered (i.e. the user just hitting return).
[20 marks]
2. Parametric plot. Write a function which plots this parametric trigonometric
polynomial:
ρ = (sin(1.2t))m + (cos(6.0t))n + 1.2
x = cos(t) ∗ ρ
y = sin(t) ∗ ρ
For t use the range from 0 to 10. Pick a high enough number of points to create a
smooth curve. m and n should be optional arguments of the function. Pick default
values producing a nice plot (I liked m = 8 and n = 5, but please experiment).
The curve should be plotted in blue. Label the plot. Values of m and n should be
printed as the title of the figure.
The main program should read in values of m and n. If the user enters nothing (i.e.
just hits return), the function should be called without arguments (i.e. the default
values of m and n used).
[20 marks]
1
3. Ellipsoid. This question concerns an ellipsoid with semi-major axes a, b, c aligned
with the x, y and z directions, respectively. Write a function that produces a 3D
plot of the ellipsoid. Arguments should be semi-major axes a, b, c and an...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here