本答案对应课程为:点我自动跳转查看
本课程起止时间为:2020-03-02到2020-07-03
本篇答案更新状态:已完结

【作业】Week 1: Python Preliminaries I Homework for Week 1

1、 问题:Set up your Python developping envrionment. Print ‘Hello World!’ in your Jupyter Notebook. Then upload the screenshot.Upload your screenshot using the picture button as shown in the following picture.
评分规则: 【 If the screenshot is right, e.g., like the following one, give the score 100. Otherwise, 0. 

Week 1: Python Preliminaries I Have a try with Python!

1、 问题:Use the Spyder Python IDE, run the following code:import string
s = ‘Welcome to the course Python for Data Analysis.’
string.capwords(s)what is the output?
选项:
A:’Welcome To The Course Python For Data Analysis.’
B:Welcome To The Course Python For Data Analysis.
C:Welcome to the Course Python for Data Analysis.
D:’Welcome to the Course Python for Data Analysis.’
答案: 【‘Welcome To The Course Python For Data Analysis.’

2、 问题:This question is about regular expression. What is the output of the following code?import re
pattern = ‘this’
text = ‘Does this text match the pattern?’
match = re.search(pattern, text)
s = match.start()
e = match.end()
print(‘Found "{}"in "{}"from {} to {} ("{}")’.format(match.re.pattern, match.string, s, e, text[s:e]))
选项:
A:Found "this"in "Does this text match the pattern?"from 5 to 9 ("this")
B:Found "this" in "Does this text match the pattern?"from 5 to 9 ("this")
C:Found "this" in "Does this text match the pattern?" from 5 to 9 ("this")
D:Found"this"in "Does this text match the pattern?"from 5 to 9 ("this")
答案: 【Found "this"in "Does this text match the pattern?"from 5 to 9 ("this")

3、 问题:Each time you run the following code, you will get different output.import random
for i in range(5):
    print(‘%04.3f’ % random.random(), end=’ ‘)
选项:
A:正确
B:错误
答案: 【正确

4、 问题:a = [1, 2, 3]
b = a
b.append(4)After the running the above code, the variable ‘a’ has value [1, 2, 3].
选项:
A:正确
B:错误
答案: 【错误

5、 问题:What is the output of the following code?import math
for i in range(5):
    print(‘{}/2 = {}’.format(i, math.modf(i / 2.0)))
答案: 【0/2 = (0.0, 0.0)
1/2 = (0.5, 0.0)
2/2 = (0.0, 1.0)
3/2 = (0.5, 1.0)
4/2 = (0.0, 2.0)

6、 问题:What is the output of the following code?from statistics import *
data = [1, 2, 2, 5, 10, 12]
print(‘{:0.2f}’.format(mean(data)))
答案: 【5.33

【作业】Week 2: Python Preliminaries II Homework for Week 2

1、 问题:Accept two int values from the user and return their product. If the product is greater than 1000, then return their sum.
建议:【本题是主观题,暂无解析

2、 问题:Accept string from the user and display only those characters which are present at an even index.
建议:【本题是主观题,暂无解析

Week 2: Python Preliminaries II Quiz for Week 2

1、 问题:Which code prints “rest apples are less than 9” and only once?
选项:
A:apples = 100
while True:
    if apples < 9:
        break
        print("rest apples are less than 9")
    apples -= 9
B:apples = 100
while True:
    if apples < 9:
        continue
        print("rest apples are less than 9")
    apples -= 9
C:apples = 100
while apples >= 1:
    if apples < 9:
        print("rest apples are less than 9")
        break
    apples -= 9
D:apples = 100
for a in reversed(xrange(apples)):
    if a < 9:
        print("rest apples are less than 9")
        continue
        apples -= 9
答案: 【apples = 100
while apples >= 1:
    if apples < 9:
        print("rest apples are less than 9")
        break
    apples -= 9

2、 问题:If the type of k is int, what is the number of iterations of the following while loop?k = 50 
while k > 1: 
    print(k) 
    k = k // 2
选项:
A:3
B:4
C:5
D:6
答案: 【5

3、 问题:What kind of error will be given by running the next code?>>> a = 3
>>> print(a ** b)
选项:
A:IndexError
B:ValueError
C:TypeError
D:NameError
答案: 【NameError

4、 问题:import random
random.______()The output is between 0 and 1. Which function in the random library can be filled in the black?
选项:
A:randint
B:random
C:uniform
D:shuffle
答案: 【random

5、 问题:Which code return False?
选项:
A:(3 is 4) == 0
B:’abc’ < ‘ABC’
C:9 < 1 and 10 < 9 or 2 > 1
D:8 > 4 > 2
答案: 【‘abc’ < ‘ABC’

6、 问题:Which code cannot print "hello world" in one line?
选项:
A:print(‘hello world’)
B:print("hello world")
C:print(”’hello world”’)
D:print(‘hello \world’)
答案: 【print(”’hello world”’)

7、 问题:What type is returned by the input function in Python?
选项:
A:int
B:str
C:list
D:dict
答案: 【str

8、 问题:Which statement about module is wrong?
选项:
A:A complete Python file is a module, serving as an extension of Python’s functionality.
B:After a module is imported by import, its functions can be used by using the format "module.function".
C:You can use variable to refer to function, e.g., bar=math.sqrt, and then use bar to calculate the squre root. For example, bar(9) returns 3.0.
D:Python does not support import several modules at one time.
答案: 【Python does not support import several modules at one time.

9、 问题:Which statement regarding the Python assignment is wrong?
选项:
A:The same variable name can be given different type of values in different location.
B:In Python, you do not need to explicitly declare the type of a variable. The type is set according its value. 
C:Python allows chain assignment and multiple assignment.
D:Python assignment is case insensitive. 
答案: 【Python assignment is case insensitive. 

10、 问题:Which statement is true?
选项:
A:For the codex and ywhen x is False,it directly returns False,not calculate the value of y
B:ifruns from top to bottom. If some codition is True, then it will run the corresponding code, ignoring the rest elif and else.
C:In while and forflow, continue can stop the present loop, and run the code right after.
D:In whileandforflow, break can stop the present loop and enter the next loop.
答案: 【For the codex and ywhen x is False,it directly returns False,not calculate the value of y;
ifruns from top to bottom. If some codition is True, then it will run the corresponding code, ignoring the rest elif and else.

11、 问题:Which code returns 3 or 3.0?

本门课程剩余章节答案为付费内容
本文章不含期末不含主观题!!
本文章不含期末不含主观题!!
支付后可长期查看
有疑问请添加客服QQ 2356025045反馈
如遇卡顿看不了请换个浏览器即可打开
请看清楚了再购买哦,电子资源购买后不支持退款哦

   

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注