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 "{}"nin "{}"nfrom {} 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

编写一个输入输出的程序(练习用,不计分)

1、判断题:
‌简单的输入输出:编程实现输入姓、名的提示语并接受用户输入,并单独显示姓、名和全名,执行效果如下所示:​‌Input your surname: ZHANG​‌Input your firstname: Dazhuang​‌Your surname is: ZHANG​‌Your firstname is: Dazhuang​‌Your full name is: ZHANG Dazhuang​‌在看参考程序之前你成功了吗?​‌​‌【参考答案】​‌surname = input('Input your surname: ')
firstname = input('Input your firstname: ')
print('Your surname is:', surname)
print('Your firstname is:', firstname)
print('Your full name is:', surname, firstname)​
选项:
A: 正确
B: 错误
答案: 【 正确

Week 15 面向对象和图形用户界面

试试理解这个小程序,并选择正确答案

1、单选题:

‍试试理解这个小程序。请选择合适的代码使得如下的程序能够实现在程序Frame中按下鼠标左键时,在鼠标按下的位置出现一个Button,如下图所示。

import wx

class MyFrame(wx.Frame):
    def __init__(self, parent, title):
        wx.Frame.__init__(self, ____, title = title)
        self.panel = wx.Panel(self)
        self.____(wx.EVT_LEFT_UP, self.OnClick)
        self.Show(True)

    def OnClick(self, event):
        posm = event.GetPosition()
        wx._____(_____, label = "Hi~~~", pos = (posm.x, posm.y))

if __name__ == '__main__':
    app = wx.App()
    frame = MyFrame(None, 'Hello Python')
    app.MainLoop()

‏选项:
A: parent, Button, panel.Bind, self.panel
B: parent, panel.Bind, Button, self.panel
C: parent, self.panel, Button, panel.Bind
D: parent, panel.Bind, self.panel, Button
答案: 【 parent, panel.Bind, Button, self.panel

Week 16 Other Examples

Python数据统计挖掘与应用单元测验

1、单选题:

观察如下基于皮尔逊相关系数绘制的热力图,判断属性sepal width(cm)和sepal length(cm)之间的相关关系可能符合如下哪一个选项?

‏选项:
A: 正强线性相关
B: 负强线性相关
C: 正弱线性相关
D: 负弱线性相关
答案: 【 负弱线性相关

2、单选题:
假设要计算可口可乐公司(假设数据保存在DataFrame对象quotesKOdf中)在近一年中开盘价在[52,54]区间的所有记录各属性的中位数,执行效果如下图所示,请选择符合两处横线处合适的代码的选项。​quotesKOdf[(quotesKOdf.open >= 52) _________ (quotesKOdf.open <= 54)].____________()​​​
选项:
A: |; mean
B: or; median
C: &; median
D: and; median
答案: 【 &; median

3、单选题:
若已从一个DataFrame对象df中选择了两部分数据(保持数据属性完整)分别存入df1和df2中,代码行如下,请从如下选项中选出可以正确合并这两部分数据的函数/方法补充完整代码。‍>>> import pandas as pd
>>> pd.___________([df1, df2])‍​‍
选项:
A: append
B: concat
C: join
D: merge
答案: 【 concat

4、多选题:
‏统计量分析分为集中趋势分析和

剩余75%内容付费后可查看

发表评论

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