Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit


Math 1MP3 * Assignment 1

2022


Important notes, read carefully!

(1) To start the assignment, download the Jupyter notebook file

Assignment1_Template.ipynb

which is on Avenue, in Assignments folder.

(2) Your assignment must be submitted as a notebook Jupyter python file. Rename the file that you downloaded to

yourmacid_Assignment1.ipynb

where yourmacid is replaced with your macid from your McMaster email address. So if your McMaster email address is [email protected], then you should name your file

einstein45_Assignment1.ipynb

(3) Upload your file into Jupyter. To complete the assignment, enter your code for each question as suggested by the template.

(4) The code that you enter cannot contain any import statements. Note that the template contains several print statements that, when executed, will test your code.

(5) When finished, upload your file into Assignment1 submission folder on Avenue, by the deadline. Einstein would submit the file einstein45_Assignment1.ipynb. If you submit your assignment several times, only the latest submission will be graded. Be mindful of the penalties for late work.


Questions

This assignment is worth 10 points; the number of points a question is worth is in the square brackets next to the problem number

1. [1] Given a string str of length 3 or longer, return a string made of 4 copies of the last three characters of str.

2. [1] A 2 × 2 matrix M is given as a list with two elements, each of which is one row in M. In other words,

represents the matrix

Given a 2 × 2 matrix M, return its determinant.

3. [1] A 3 × 3 matrix M is given as a list with three elements, each of which is one row in M. In other words,

represents the matrix

Given a 3 × 3 matrix M, return True if M is symmetric, and False if it is not.

4. [1] In some parts of the world, the people born between 1945 and 1964 are referred to as the Baby boomers. Those born between 1965 and 1981 are called Generation X, whereas those born between 1982 and 1996 are known as Millennials. The people born between 1997 and 2010 are called Generation Z, and Those born in 2011 or later have been named Alpha generation.

[Note: between is inclusive; so between 1982 and 1966 means between 1982 and 1996, including 1982 and 1996.]

Given a person’s birth year (between 1945 and 2021), return the name of their genera-tion.

5. [2] Given three positive integers N, p, and q, return the sum of all integers from 1 to N (including 1 and N) which are divisible by either p or q (‘either .. or’ is inclusive ‘or’).

6. [2] Return the number of times the string ‘math’ appears in the given string str.

7. [2] Consider rounding positive integers to the nearest multiple of ten: if the last digit of a given integer is 1, 2, 3, or 4, the number is rounded down (e.g., 12 is rounded to 10, 193 is rounded to 190, 442 is rounded to 440, etc.); otherwise it is rounded up (e.g., 66 is rounded to 70, 138 is rounded to 140, 5555 is rounded to 5560, etc.)

For a given positive integer num return its value rounded to the nearest multiple of ten.

Do NOT use Python’s round command. Write your own code.