跳至主要內容

Math 1MP3 * Assignment 1

AI悦创原创大约 3 分钟...约 884 字

All work that you submit for grading must be your own.

You are allowed to discuss homework problems and related material with other students, or with your TA. However you are not allowed to submit work copied from others or copied from internet. Note that late work is penalized by 25% per day.

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 einstein45@mcmaster.ca, 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, M=[[1,2],[3,4]]

represents the matrix:

[1234] \begin{bmatrix} 1 & 2 \\ 3 & 4 \\ \end{bmatrix}

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

  1. [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, M=[[1,2,3],[4,5,6],[7,8,9]]

represents the matrix:

[123456789] \begin{bmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \\ \end{bmatrix}

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

  1. [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.

  1. [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’).

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

  3. [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.

公众号:AI悦创【二维码】

AI悦创·编程一对一

AI悦创·推出辅导班啦,包括「Python 语言辅导班、C++ 辅导班、java 辅导班、算法/数据结构辅导班、少儿编程、pygame 游戏开发、Web、Linux」,全部都是一对一教学:一对一辅导 + 一对一答疑 + 布置作业 + 项目实践等。当然,还有线下线上摄影课程、Photoshop、Premiere 一对一教学、QQ、微信在线,随时响应!微信:Jiabcdefh

C++ 信息奥赛题解,长期更新!长期招收一对一中小学信息奥赛集训,莆田、厦门地区有机会线下上门,其他地区线上。微信:Jiabcdefh

方法一:QQopen in new window

方法二:微信:Jiabcdefh

上次编辑于:
贡献者: AndersonHJB
你认为这篇文章怎么样?
  • 0
  • 0
  • 0
  • 0
  • 0
  • 0
评论
  • 按正序
  • 按倒序
  • 按热度