首页 » cs代考 » Python代写|Final Exam CSC108H5F

Python代写|Final Exam CSC108H5F

本次加拿大代写是一个Python相关的限时测试

Question 1. [15 marks]

You MUST enter the responses to these questions on to the scantron on the back of the cover page of
this test. You may wish to circle your answers here and then check them before entering the responses on
to the scantron if you are using a pen.

Part (1) [1 mark]

Suppose we define

>> H = {“one”: 0, “two”: 2, “three”: 3}

Which of the following will cause an error when typed into the Python interpreter?

A. H[“one”] += 1
B. “four” in H
C. H[2] = {“two”}
D. H.get(“five”) == 5
E. None of the above.

Part (2) [1 mark]

Suppose we define:

>> xs = “0123456789”

Which string slice would produce the empty string?

A. xs[2:7:5]
B. xs[-2:-7:-1]
C. xs[2:7:1][4:5:1]
D. xs[4:-5:-1]
E. None of the above.

Part (3) [1 mark]

What is the best description for the following function?

def mystery(xs):
… k = -1
… for x in xs:
… k += 1
… if xs[k] != x:
… return False
… return True

A. Mystery checks if all members of a list are the same.
B. Mystery checks if all members of a list are different.
C. Mystery always returns True when given a list.
D. Mystery always returns False when given a list.
E. None of the above.

Part (4) [1 mark]

Suppose we type the following code into the Python interpreter:

>> class Point():
… def __init__(self, x: int, y: int):
… self.x = x
… self.y = y

… def __str__(self):
… return ‘({},{})’.format(self.x, self.y)
>>> P = Point(2,3)
>>> Q = Point(2,3)

Which of the following will evaluate to False?

A. type(P) == type(Q)
B. P == Q
C. P.x < Q.y
D. str(P) == str(Q)
E. None of the above.


程序辅导定制C/C++/JAVA/安卓/PYTHON/留学生/PHP/APP开发/MATLAB


本网站支持 Alipay WeChatPay PayPal等支付方式

E-mail: vipdue@outlook.com  微信号:vipnxx


如果您使用手机请先保存二维码,微信识别。如果用电脑,直接掏出手机果断扫描。