added docu
This commit is contained in:
parent
889fd2bdca
commit
71bef35994
BIN
大数据基础与应用-学习资料/PPT/第10章 Python操作数据库.pptx
Normal file
BIN
大数据基础与应用-学习资料/PPT/第10章 Python操作数据库.pptx
Normal file
Binary file not shown.
BIN
大数据基础与应用-学习资料/PPT/第11章 Numpy入门与实践.pptx
Normal file
BIN
大数据基础与应用-学习资料/PPT/第11章 Numpy入门与实践.pptx
Normal file
Binary file not shown.
BIN
大数据基础与应用-学习资料/PPT/第12章 Pandas入门与实践.pptx
Normal file
BIN
大数据基础与应用-学习资料/PPT/第12章 Pandas入门与实践.pptx
Normal file
Binary file not shown.
BIN
大数据基础与应用-学习资料/PPT/第13章 数据可视化-matplotlib.pptx
Normal file
BIN
大数据基础与应用-学习资料/PPT/第13章 数据可视化-matplotlib.pptx
Normal file
Binary file not shown.
BIN
大数据基础与应用-学习资料/PPT/第14章 机器学习库 Scikit-learn.pptx
Normal file
BIN
大数据基础与应用-学习资料/PPT/第14章 机器学习库 Scikit-learn.pptx
Normal file
Binary file not shown.
BIN
大数据基础与应用-学习资料/PPT/第1章 Python简介与环境搭建.pptx
Normal file
BIN
大数据基础与应用-学习资料/PPT/第1章 Python简介与环境搭建.pptx
Normal file
Binary file not shown.
BIN
大数据基础与应用-学习资料/PPT/第2章 Python语法基础.pptx
Normal file
BIN
大数据基础与应用-学习资料/PPT/第2章 Python语法基础.pptx
Normal file
Binary file not shown.
BIN
大数据基础与应用-学习资料/PPT/第3章 Python流程控制.pptx
Normal file
BIN
大数据基础与应用-学习资料/PPT/第3章 Python流程控制.pptx
Normal file
Binary file not shown.
BIN
大数据基础与应用-学习资料/PPT/第4章 Python的基本数据结构.pptx
Normal file
BIN
大数据基础与应用-学习资料/PPT/第4章 Python的基本数据结构.pptx
Normal file
Binary file not shown.
BIN
大数据基础与应用-学习资料/PPT/第5章 Python中的函数.pptx
Normal file
BIN
大数据基础与应用-学习资料/PPT/第5章 Python中的函数.pptx
Normal file
Binary file not shown.
BIN
大数据基础与应用-学习资料/PPT/第6章 Python异常处理.pptx
Normal file
BIN
大数据基础与应用-学习资料/PPT/第6章 Python异常处理.pptx
Normal file
Binary file not shown.
BIN
大数据基础与应用-学习资料/PPT/第7章 Python常见标准库.pptx
Normal file
BIN
大数据基础与应用-学习资料/PPT/第7章 Python常见标准库.pptx
Normal file
Binary file not shown.
BIN
大数据基础与应用-学习资料/PPT/第8章 Python文件操作.pptx
Normal file
BIN
大数据基础与应用-学习资料/PPT/第8章 Python文件操作.pptx
Normal file
Binary file not shown.
BIN
大数据基础与应用-学习资料/PPT/第9章 Python中的面向对象.pptx
Normal file
BIN
大数据基础与应用-学习资料/PPT/第9章 Python中的面向对象.pptx
Normal file
Binary file not shown.
BIN
大数据基础与应用-学习资料/安装包/Anaconda安装教程.docx
Normal file
BIN
大数据基础与应用-学习资料/安装包/Anaconda安装教程.docx
Normal file
Binary file not shown.
BIN
大数据基础与应用-学习资料/安装包/pycharm安装教程.doc
Normal file
BIN
大数据基础与应用-学习资料/安装包/pycharm安装教程.doc
Normal file
Binary file not shown.
BIN
大数据基础与应用-学习资料/安装包/python-3.8.5-amd64.exe
Normal file
BIN
大数据基础与应用-学习资料/安装包/python-3.8.5-amd64.exe
Normal file
Binary file not shown.
10
大数据基础与应用-学习资料/补交作业链接.txt
Normal file
10
大数据基础与应用-学习资料/补交作业链接.txt
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
补交作业要求:
|
||||||
|
(1)1-10周交.py文件,11-15周交.ipynb文件。
|
||||||
|
(2)每周文件名为:学号姓名
|
||||||
|
(3)若提交多个文件,将多个文件放在学号姓名文件夹下,压缩学号姓名文件夹并提交压缩文件。
|
||||||
|
|
||||||
|
23应用1:http://xzc.cn/cftBigjX14
|
||||||
|
23应用2:http://xzc.cn/s96LE4naN5
|
||||||
|
23应用3:http://xzc.cn/dq28WUyYHh
|
||||||
|
23网络:http://xzc.cn/Jy3pLpYLYo
|
||||||
|
23软件:http://xzc.cn/cRJrjkpMj3
|
343
大数据基础与应用-学习资料/课堂练习-题目.py
Normal file
343
大数据基础与应用-学习资料/课堂练习-题目.py
Normal file
@ -0,0 +1,343 @@
|
|||||||
|
# 第一周
|
||||||
|
# 打印菱形
|
||||||
|
# 效果分析
|
||||||
|
# 第 1 行4个空格,1个星号;
|
||||||
|
# 第 2 行2个空格,3个星号,星号空格隔开;
|
||||||
|
# 第 3 行0个空格,5个星号,星号空格隔开;
|
||||||
|
# 第 4 行2个空格,3个星号,星号空格隔开;
|
||||||
|
# 第 5 行4个空格,1个星号;
|
||||||
|
|
||||||
|
|
||||||
|
# 第二周
|
||||||
|
# 第一题:输出字符串
|
||||||
|
# 书本P37:2.3
|
||||||
|
|
||||||
|
|
||||||
|
# 第二题:判断某一年是闰年还是平年
|
||||||
|
# 书本P55:3.2
|
||||||
|
# 年份由用户通过键盘输入,
|
||||||
|
# (闰年的标准:能被4整除,但是不能被100整除,或者能被400整除。)
|
||||||
|
|
||||||
|
|
||||||
|
# 第三题:打印数字金字塔
|
||||||
|
# 书本P49:3.6
|
||||||
|
|
||||||
|
|
||||||
|
# 第四题:综合案例 打印对称菱形
|
||||||
|
# 书本P52:3.15
|
||||||
|
|
||||||
|
|
||||||
|
# 第三周
|
||||||
|
# # 课后练习
|
||||||
|
# 第一题: 合并排序
|
||||||
|
# 已知有两个列表 a_list = [4, 10, 12, 4, 9, 6, 3], b_list = [12, 8, 5, 6, 7, 6, 10],
|
||||||
|
# 编写程序实现以下功能:
|
||||||
|
# 将两个列表进行合并,合并时删除重复元素,合并结果存放在 c_list 中;
|
||||||
|
# 对 c_list 按照元素的大小,从大到小进行排序,并打印出排序结果。
|
||||||
|
|
||||||
|
|
||||||
|
# 第二题:统计次数
|
||||||
|
# 已知列表 a_list = [4, 6, 8, 6, 4, 2, 6, 6, 5, 7, 4, 2, 1, 7, 6, 7, 4],
|
||||||
|
# 编写程序统计列表中各元素出现的次数,并将结果按照下面格式输出:
|
||||||
|
# 元素 xxx 在列表中出现 xxx 次
|
||||||
|
|
||||||
|
|
||||||
|
# 第四周
|
||||||
|
# 第一题: 字符串
|
||||||
|
# 书上P94:4.5
|
||||||
|
|
||||||
|
# 第二题: 字符串
|
||||||
|
# 输入一个字符串,输出该字符串中出现频数最高的字符,
|
||||||
|
# 如果有多个字母出现的频数并列最高,则输出多个字母。(统计字符出现的频数)
|
||||||
|
|
||||||
|
|
||||||
|
# 第三题: 字典
|
||||||
|
# a_str = input("请输入一个字符串:")
|
||||||
|
# a_dict = {}
|
||||||
|
# for i in a_str:
|
||||||
|
# old_num = a_dict.get(i, 0)
|
||||||
|
# a_dict[i] = old_num + 1
|
||||||
|
# result = sorted(a_dict.items(), key=lambda item: item[1], reverse=True)
|
||||||
|
# for i in result:
|
||||||
|
# print(i[0], "字符出现的次数为:", i[1])
|
||||||
|
|
||||||
|
# 第五周
|
||||||
|
# 第一题 函数的定义与调用
|
||||||
|
# 自定义一个函数,实现打印菱形功能。函数包含一个参数,
|
||||||
|
# 用于控制菱形的行数。(菱形的打印可参考第三章内容)
|
||||||
|
|
||||||
|
# rows = int(input('请输入菱形的行数:'))
|
||||||
|
# half = rows // 2
|
||||||
|
# if rows % 2 == 0:
|
||||||
|
# up = half
|
||||||
|
# else:
|
||||||
|
# up = half + 1
|
||||||
|
# for i in range(1, up + 1):
|
||||||
|
# print(' ' * (up - i), "* " * (2 * i - 1))
|
||||||
|
# for i in range(half, 0, -1):
|
||||||
|
# print(' ' * (up - i), "* " * (2 * i - 1))
|
||||||
|
|
||||||
|
|
||||||
|
# 第二题:自定义一个函数,对任意两个整数之间所有整数(包含这两个整数)进行求和。
|
||||||
|
# 函数包含两个参数,用于指定起始整数和结束整数。
|
||||||
|
# 其中小的作为起始整数,大的作为结束整数,将求和结果作为返回值返回。
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# 第三题:编写函数实现如下功能,对传递的一组数据进行操作,调整数据的位置,
|
||||||
|
# 使得所有的奇数位于前半部分,所有的偶数位于后半部分,
|
||||||
|
# 并保证奇数和奇数,偶数和偶数之间的相对位置不变。
|
||||||
|
# 例如:原始数据为:[9, 6, 7, 3, 1, 8, 4, 3, 6],
|
||||||
|
# 则调整后的数据为: [9, 7, 3, 1, 3, 6, 8, 4, 6]。
|
||||||
|
|
||||||
|
|
||||||
|
# 第四题 参数类型与参数传递
|
||||||
|
# 自定义一个函数,用于计算矩形的面积和周长,
|
||||||
|
# 函数包含两个参数:长和宽,由于正方形是特殊的矩形,因此也支持传递一个参数的情况。
|
||||||
|
# 当传递一个参数时,表示长和宽相等,最后将计算结果进行返回。
|
||||||
|
# (同时支持一个参数和两个参数,同时返回多个值)
|
||||||
|
|
||||||
|
|
||||||
|
# 第五题 递归
|
||||||
|
# 角谷定理。随机输入一个自然数,若为偶数,则把它除以2,若为奇数,则把它乘以3加1。
|
||||||
|
# 经过如此有限次运算后,总可以得到自然数值1。
|
||||||
|
# 编写程序,捕获用户输入的数字,然后输出从该数字到最终结果1的过程,
|
||||||
|
# 统计需要经过多少步计算可得到自然数1。
|
||||||
|
# 如:输入22
|
||||||
|
# 输出 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1
|
||||||
|
# 步数为:15
|
||||||
|
|
||||||
|
# 第六题 递归
|
||||||
|
# 一只青蛙一次可以跳上1级台阶,也可以跳上2级。
|
||||||
|
# 求该青蛙跳上一个n级的台阶总共有多少种跳法(先后次序不同算不同的结果)。
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# 第六-七周
|
||||||
|
# 第六章 课后练习
|
||||||
|
# P127 课后练习 6.1
|
||||||
|
'''编写一个程序,提示用户输入一个整数,如果输入的不是整数,则让用户重新输入,直到是一个整数为止。
|
||||||
|
例如:第一次输入abc,第二次输入12.5,第三次输入6,执行效果如下:
|
||||||
|
请输入一个整数:abc
|
||||||
|
输入不符合要求,请重新输入!
|
||||||
|
请输入一个整数:12.5
|
||||||
|
输入不符合要求,请重新输入!
|
||||||
|
请输入一个整数:6
|
||||||
|
输入正确,你输入的整数为:6'''
|
||||||
|
|
||||||
|
# 第七章 课后练习
|
||||||
|
# P145 课后练习 7.6
|
||||||
|
# '''编写一个程序,模拟打印下载进度效果,每隔0.2秒打印一次下载进度,
|
||||||
|
# 要求下载进度只在一行打印,每次打印的进度不同,下载完成后打印下载完成!(程序休眠、同一行打印不换行)
|
||||||
|
# '''
|
||||||
|
|
||||||
|
|
||||||
|
# P145 课后练习 7.7
|
||||||
|
'''编写一个程序,随机生成1000个字母,包含大写字母和小写字母,然后统计各个字母出现的次数,
|
||||||
|
统计时忽略字母的大小写,最后将统计结果按照字母出现的次数从高到低排序输出。'''
|
||||||
|
|
||||||
|
|
||||||
|
# P145 课后练习 7.8
|
||||||
|
'''已知某个班级学生年龄分布如下:
|
||||||
|
ages = [("a", 19), ("b", 20), ("c", 20), ("d", 19), ("e", 21), ("f", 19), ("g", 18),
|
||||||
|
("h", 19), ("i", 21), ("j", 21), ("k", 18), ("l", 19), ("m", 18), ("n", 21),
|
||||||
|
("o", 18), ("p", 19), ("q", 18), ("r", 19), ("s", 20), ("t", 19), ("u", 19),
|
||||||
|
("v", 20), ("w", 19), ("x", 20), ("y", 20), ("z", 19)]
|
||||||
|
编写程序将学生按照年龄分类,并按照年龄从大到小打印出各个年龄下的学生姓名列表。
|
||||||
|
'''
|
||||||
|
|
||||||
|
|
||||||
|
# 第四周字典另一种解法
|
||||||
|
# 随机输入一个字符串,统计该字符串中各种字符出现的次数,
|
||||||
|
# 并将统计结果按照字符出现次数从高到低进行排序,最终打印排序后的信息。每行效果如下:
|
||||||
|
# xxx 字符出现次数为: xxx
|
||||||
|
# P94 4.6 字典
|
||||||
|
# from collections import Counter
|
||||||
|
# a_str = input("请输入一个字符串:")
|
||||||
|
# result = Counter(a_str)
|
||||||
|
# for i in result.most_common():
|
||||||
|
# print(i[0], "字符出现的次数为:", i[1])
|
||||||
|
|
||||||
|
# a_str = input("请输入一个字符串:")
|
||||||
|
# a_dict = {}
|
||||||
|
# for i in a_str:
|
||||||
|
# old_num = a_dict.get(i, 0)
|
||||||
|
# a_dict[i] = old_num + 1
|
||||||
|
# result = sorted(a_dict.items(), key=lambda item: item[1], reverse=True)
|
||||||
|
# for i in result:
|
||||||
|
# print(i[0], "字符出现的次数为:", i[1])
|
||||||
|
|
||||||
|
|
||||||
|
# 第八周
|
||||||
|
# # 课后练习
|
||||||
|
# # P165 课后练习8.5
|
||||||
|
# '''编写程序实现九九乘法表,并将其保存到文件test.txt中去。'''
|
||||||
|
|
||||||
|
|
||||||
|
# # P165 课后练习8.6
|
||||||
|
# '''编写程序实现递归搜索class8文件夹下所有的图片文件(例如 jpg、png文件),
|
||||||
|
# 并将所有的图片文件复制到D:\images文件夹下。(关键提示:图片文件的复制可采用二进制操作)'''
|
||||||
|
|
||||||
|
|
||||||
|
# # P165 课后练习8.7
|
||||||
|
# '''编写程序读取学校信息表内容,然后单独将所有的211高校放入一个表单,
|
||||||
|
# 将所有的985高校放入一个表单,两个表单位于同一个Excel文件。'''
|
||||||
|
# '''
|
||||||
|
|
||||||
|
|
||||||
|
# # P165 课后练习8.8
|
||||||
|
# '''编写程序读取给定的test.txt文件内容,统计该文件中各单词出现的次数,
|
||||||
|
# 并将统计结果按照单词出现的次数从高到低写入到文件result.xsl中。
|
||||||
|
# (test.txt是一个英文文本,单词之间通过空格隔开, 要求单词不区分大小写,
|
||||||
|
# 忽略逗号、句号等标点符号。result.xsl文件标题为词频统计结果,
|
||||||
|
# 包含两列名称分别为:单词和频数,所有的频数以加粗红色显示。)'''
|
||||||
|
# '''
|
||||||
|
# 见素材:测试本段代码时可以在网上查找一段英文文章保存到本地,保存为"test.txt"文件格式,然后将文件直接拖进本项目中测试
|
||||||
|
# '''
|
||||||
|
|
||||||
|
|
||||||
|
# 第九周
|
||||||
|
# # 9.1
|
||||||
|
# 设计一个 表示圆的类:Circle,这个类包含一个实例成员变量:半径,包含两个方法:求面积的方法、求周长的方法。
|
||||||
|
# 利用这个类创建半径为1~10的圆,并打印出相应的信息,运行效果如图所示,保留两位小数。
|
||||||
|
|
||||||
|
|
||||||
|
# # 9.2
|
||||||
|
# 阅读下列程序代码,思考程序执行结果。
|
||||||
|
# class Test:
|
||||||
|
# count = 0
|
||||||
|
# def __init__(self, num=10):
|
||||||
|
# Test.count = Test.count + 1
|
||||||
|
# self.__num = num
|
||||||
|
# def print(self):
|
||||||
|
# print("count=", self.count)
|
||||||
|
# print("num=", self.__num)
|
||||||
|
|
||||||
|
# t_1 = Test(5)
|
||||||
|
# t_2 = Test(8)
|
||||||
|
# t_1.print()
|
||||||
|
# t_2.print()
|
||||||
|
#
|
||||||
|
# t_1 = Test(5)
|
||||||
|
# t_2 = Test(8)
|
||||||
|
# t_1.count = 12
|
||||||
|
# t_1.print()
|
||||||
|
# t_2.print()
|
||||||
|
#
|
||||||
|
# t_1 = Test(5)
|
||||||
|
# t_2 = Test(8)
|
||||||
|
# Test.count = 12
|
||||||
|
# t_1.print()
|
||||||
|
# t_2.print()
|
||||||
|
|
||||||
|
# t_1 = Test(5)
|
||||||
|
# t_2 = Test(8)
|
||||||
|
# t_1.__num = 15
|
||||||
|
# t_1.print()
|
||||||
|
# t_2.print()
|
||||||
|
# print(t_1.__num)
|
||||||
|
# print(dir(t_1))
|
||||||
|
#
|
||||||
|
# t_1 = Test(5)
|
||||||
|
# t_2 = Test(8)
|
||||||
|
# t_1._Test__num = 15
|
||||||
|
# t_1.print()
|
||||||
|
# t_2.print()
|
||||||
|
|
||||||
|
|
||||||
|
# # 9.4
|
||||||
|
# 设计一个 银行账户类:Account,该类包含三个成员变量:账号、用户名、余额。
|
||||||
|
# 该类提供三个方法:存款、取款、转账。初始化时,账户余额为0,
|
||||||
|
# 取款和转账前需判断余额是否充足,
|
||||||
|
# 余额不足时,操作失败,打印相关提示信息。
|
||||||
|
# 如果两个账户账号相同时,则认为它们是同一个账户。
|
||||||
|
# 打印账户对象时,将会显示账号、用户名、余额等基本信息。
|
||||||
|
# (提示:重写__eq__方法、__str__方法)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# 第十周
|
||||||
|
# 书上P203: 课后练习
|
||||||
|
# 已知某个班级的某次考试成绩信息包括学号、语文、数学、英语、总分,
|
||||||
|
# 该成绩信息保存在一张Excel表中,部分信息如图所示,现在要求将其读入到数据库中去。同时实现以下功能:
|
||||||
|
# # 创建数据表score, 读取excel中数据到数据库表中
|
||||||
|
# import xlrd
|
||||||
|
# import sqlite3
|
||||||
|
# def read_excels(file_name): #读取Excel文件
|
||||||
|
# wb = xlrd.open_workbook(file_name) #打开Excel文件,返回的是一个工作簿
|
||||||
|
# sheet = wb.sheet_by_index(0) #由工作簿得到表单
|
||||||
|
# students = [] #由行和列来获取文件中的信息,用列表students保存
|
||||||
|
# for row in range(1, sheet.nrows):
|
||||||
|
# student = []
|
||||||
|
# for col in range(sheet.ncols):
|
||||||
|
# student.append(transform(sheet.cell_value(row, col)))
|
||||||
|
# students.append(student)
|
||||||
|
# return students
|
||||||
|
# #
|
||||||
|
# def transform(data): # 返回的成绩是浮点数,尝试转换成整型
|
||||||
|
# try:
|
||||||
|
# return int(data)
|
||||||
|
# except: # 不能转换原样返回
|
||||||
|
# return data
|
||||||
|
# #
|
||||||
|
|
||||||
|
|
||||||
|
# 格式化输出
|
||||||
|
# def print_data(datas): # 打印结果
|
||||||
|
# print("{:^8}{:^8}{:^8}{:^8}{:^8}".format("num", "chinese", "math", "english", "total"))
|
||||||
|
# for data in datas:
|
||||||
|
# print("{:^8}{:^8}{:^8}{:^8}{:^8}".format(data[0], data[1], data[2], data[3], data[4]))
|
||||||
|
#
|
||||||
|
|
||||||
|
# # 1.按照总分排序
|
||||||
|
|
||||||
|
# # 2.获取所有存在不及格科目的学生记录
|
||||||
|
|
||||||
|
# # 3.获取指定科目的最高分、最低分以及平均分
|
||||||
|
|
||||||
|
# # 4.查询三科都及格的学生信息
|
||||||
|
|
||||||
|
# # 5.将所有学生的数学成绩都加5分
|
||||||
|
|
||||||
|
# # 6.删除语文不及格的学生记录,并打印删除了多少条记录
|
||||||
|
|
||||||
|
|
||||||
|
# 第十一周
|
||||||
|
# 书上P248 11.1 课后练习
|
||||||
|
# import numpy as np
|
||||||
|
#
|
||||||
|
# array_1 = np.arange(1, 21).reshape(4, 5)
|
||||||
|
# print(array_1)
|
||||||
|
#
|
||||||
|
# # (1) array_1[2, 3]、array_1[2]、array_1[2][3]、array_1[2][:3]、array_1[:][:3]、array_1[:, :3]各自表示什么含义?
|
||||||
|
|
||||||
|
# # (2) 如果只想获取第2行和第4行数据,如何表示?
|
||||||
|
|
||||||
|
# # (3) 如果只想获取第3列和第5列数据,如何表示?
|
||||||
|
|
||||||
|
# # (4) 如果想获取大于10且能被3整除的数据,如何表示?
|
||||||
|
|
||||||
|
# # (5) 如何通过一个表达式获取第3行第4列、第2行第5列、第4行第1列数据?
|
||||||
|
|
||||||
|
# # (6) 将该数组垂直平均分割成2个子数组。
|
||||||
|
|
||||||
|
# # (7) 将该数组水平分割为3个子数组:第1列,第2-4列,第5列。
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# 第十二周
|
||||||
|
# 书上P287 12.10 课后练习
|
||||||
|
# 第一题
|
||||||
|
# import pandas as pd
|
||||||
|
# import numpy as np
|
||||||
|
# data_1 = pd.read_excel("exer_1.xlsx")
|
||||||
|
# print(data_1)
|
||||||
|
# data_2 = pd.read_excel("exer_2.xlsx")
|
||||||
|
# print(data_2)
|
||||||
|
# data_3 = data_1.join(data_2.set_index("姓名"), on="姓名")
|
||||||
|
# print(data_3)
|
||||||
|
|
||||||
|
# 第2-7题
|
||||||
|
|
||||||
|
# 第十三周
|
||||||
|
书上条形图、饼图、线形图例题
|
BIN
大数据基础与应用-学习资料/课堂练习素材/class10/SQLite可视化.docx
Normal file
BIN
大数据基础与应用-学习资料/课堂练习素材/class10/SQLite可视化.docx
Normal file
Binary file not shown.
33
大数据基础与应用-学习资料/课堂练习素材/class10/class10.sql
Normal file
33
大数据基础与应用-学习资料/课堂练习素材/class10/class10.sql
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
use test;
|
||||||
|
create table if not exists school (
|
||||||
|
school_code char(6) primary key,
|
||||||
|
school_name varchar(50),
|
||||||
|
province varchar(30),
|
||||||
|
is_985 varchar(10),
|
||||||
|
is_211 varchar(10),
|
||||||
|
is_self_marking varchar(10),
|
||||||
|
school_type varchar(10)
|
||||||
|
);
|
||||||
|
select * from school;
|
||||||
|
select count(*) from school;
|
||||||
|
select count(1) from school;
|
||||||
|
select count(school_code) from school;
|
||||||
|
select province, count(*) as c from school group by province order by c desc;
|
||||||
|
select * from school where province in ("江西省","湖南省");
|
||||||
|
select distinct province from school where province not in ("江西省");
|
||||||
|
select distinct province from school where province not like "%省";
|
||||||
|
select province, count(*) as c
|
||||||
|
from school
|
||||||
|
group by province
|
||||||
|
order by c desc;
|
||||||
|
drop table if exists school;
|
||||||
|
|
||||||
|
-- create table if not exists school(
|
||||||
|
-- school_code,
|
||||||
|
-- school_name,
|
||||||
|
-- province,
|
||||||
|
-- is_985,
|
||||||
|
-- is_211,
|
||||||
|
-- is_self_marking,
|
||||||
|
-- school_type
|
||||||
|
-- )
|
BIN
大数据基础与应用-学习资料/课堂练习素材/class10/school.xls
Normal file
BIN
大数据基础与应用-学习资料/课堂练习素材/class10/school.xls
Normal file
Binary file not shown.
BIN
大数据基础与应用-学习资料/课堂练习素材/class10/学生成绩表.xls
Normal file
BIN
大数据基础与应用-学习资料/课堂练习素材/class10/学生成绩表.xls
Normal file
Binary file not shown.
118
大数据基础与应用-学习资料/课堂练习素材/class10/数据库操作语句.rtf
Normal file
118
大数据基础与应用-学习资料/课堂练习素材/class10/数据库操作语句.rtf
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
{\rtf1\ansi\ansicpg936\cocoartf1671\cocoasubrtf600
|
||||||
|
{\fonttbl\f0\fnil\fcharset0 Monaco;\f1\fnil\fcharset134 PingFangSC-Regular;}
|
||||||
|
{\colortbl;\red255\green255\blue255;\red28\green0\blue207;\red255\green255\blue255;\red0\green0\blue0;
|
||||||
|
\red0\green116\blue0;\red131\green108\blue40;\red40\green108\blue131;\red255\green37\blue46;\red196\green26\blue22;
|
||||||
|
\red170\green13\blue145;}
|
||||||
|
{\*\expandedcolortbl;;\csgenericrgb\c10980\c0\c81176;\csgenericrgb\c100000\c100000\c100000;\csgenericrgb\c0\c0\c0;
|
||||||
|
\csgenericrgb\c0\c45490\c0;\csgenericrgb\c51373\c42353\c15686;\csgenericrgb\c15686\c42353\c51373;\csgenericrgb\c100000\c14510\c18039;\csgenericrgb\c76863\c10196\c8627;
|
||||||
|
\csgenericrgb\c66667\c5098\c56863;}
|
||||||
|
\paperw11900\paperh16840\margl1440\margr1440\vieww10800\viewh8400\viewkind0
|
||||||
|
\deftab720
|
||||||
|
\pard\pardeftab720\pardirnatural\partightenfactor0
|
||||||
|
|
||||||
|
\f0\fs26 \cf2 \cb3 create\cf4 \cf2 table\cf4 \cf2 if\cf4 \cf2 not\cf4 \cf2 exists\cf4 student( \cf5 --
|
||||||
|
\f1 \'b4\'b4\'bd\'a8\'ca\'fd\'be\'dd\'b1\'ed
|
||||||
|
\f0 student\
|
||||||
|
\cf4 name,\
|
||||||
|
age,\
|
||||||
|
\cf6 school\cf4 \
|
||||||
|
)\
|
||||||
|
\
|
||||||
|
\cf2 drop\cf4 \cf2 table\cf4 \cf2 if\cf4 \cf2 exists\cf4 student. \cf5 --
|
||||||
|
\f1 \'c9\'be\'b3\'fd\'ca\'fd\'be\'dd\'b1\'ed
|
||||||
|
\f0 student\
|
||||||
|
\cf4 \
|
||||||
|
\cf2 select\cf4 \cf6 school\cf4 , \cf7 province\cf4 \cf2 from\cf4 \cf6 school\cf4 \cf5 --
|
||||||
|
\f1 \'b2\'e9\'d1\'af\'d1\'a7\'d0\'a3\'b5\'c4\'c3\'fb\'b3\'c6\'d2\'d4\'bc\'b0\'cb\'f9\'d4\'da\'ca\'a1\'b7\'dd
|
||||||
|
\f0 \
|
||||||
|
\cf4 \
|
||||||
|
\cf2 select\cf4 * \cf2 from\cf4 \cf6 school\cf4 \cf5 --
|
||||||
|
\f1 \'b2\'e9\'d1\'af\'cb\'f9\'d3\'d0\'d1\'a7\'d0\'a3\'b5\'c4\'cb\'f9\'d3\'d0\'d0\'c5\'cf\'a2
|
||||||
|
\f0 \
|
||||||
|
\cf4 \
|
||||||
|
\cf2 select\cf4 \cf7 province\cf4 ,\cf8 count\cf4 (*) \cf2 as\cf4
|
||||||
|
\f1 \'d1\'a7\'d0\'a3\'ca\'fd
|
||||||
|
\f0 \cf2 from\cf4 \cf6 school\cf4 \cf2 group\cf4 \cf2 by\cf4 \cf7 province\cf4 \cf5 --
|
||||||
|
\f1 \'b8\'f9\'be\'dd\'ca\'a1\'b7\'dd\'bd\'f8\'d0\'d0\'b7\'d6\'d7\'e9\'a3\'ac\'c8\'bb\'ba\'f3\'cd\'b3\'bc\'c6\'b8\'f7\'b8\'f6\'ca\'a1\'b7\'dd\'b5\'c4\'b8\'df\'d0\'a3\'ca\'fd\'c1\'bf
|
||||||
|
\f0 \
|
||||||
|
\cf4 \
|
||||||
|
\cf2 select\cf4 * \cf2 from\cf4 \cf6 school\cf4 \cf2 where\cf4 \cf7 province\cf4 = \cf9 "
|
||||||
|
\f1 \'bd\'ad\'ce\'f7\'ca\'a1
|
||||||
|
\f0 "\cf4 \cf5 --
|
||||||
|
\f1 \'b2\'e9\'d1\'af\'bd\'ad\'ce\'f7\'ca\'a1\'b5\'c4\'cb\'f9\'d3\'d0\'b8\'df\'d0\'a3
|
||||||
|
\f0 \
|
||||||
|
\cf4 \
|
||||||
|
\cf2 select\cf4 * \cf2 from\cf4 \cf6 school\cf4 \cf2 where\cf4 \cf7 school_code\cf4 \cf2 between\cf4 \cf9 "10404"\cf4 \cf2 and\cf4 \cf9 "10410"\cf4 \cf5 --
|
||||||
|
\f1 \'b2\'e9\'d1\'af\'d4\'ba\'d0\'a3\'b4\'fa\'c2\'eb\'d4\'da
|
||||||
|
\f0 10404
|
||||||
|
\f1 \'a1\'ab
|
||||||
|
\f0 10410
|
||||||
|
\f1 \'b5\'c4\'b8\'df\'d0\'a3\'d0\'c5\'cf\'a2
|
||||||
|
\f0 \
|
||||||
|
\cf4 \
|
||||||
|
\cf2 select\cf4 * \cf2 from\cf4 \cf6 school\cf4 \cf2 where\cf4 \cf7 province\cf4 \cf2 in\cf4 (\cf9 "
|
||||||
|
\f1 \'bd\'ad\'ce\'f7\'ca\'a1
|
||||||
|
\f0 "\cf4 ,\cf9 "
|
||||||
|
\f1 \'ba\'fe\'c4\'cf\'ca\'a1
|
||||||
|
\f0 "\cf4 ) \cf5 --
|
||||||
|
\f1 \'b2\'e9\'d1\'af\'ba\'fe\'c4\'cf\'ca\'a1\'bb\'f2\'d5\'df\'bd\'ad\'ce\'f7\'ca\'a1\'b5\'c4\'b8\'df\'d0\'a3\'d0\'c5\'cf\'a2
|
||||||
|
\f0 \
|
||||||
|
\cf4 \
|
||||||
|
\cf2 select\cf4 * \cf2 from\cf4 \cf6 school\cf4 \cf2 where\cf4 \cf7 is_985\cf4 = \cf9 "
|
||||||
|
\f1 \'ca\'c7
|
||||||
|
\f0 "\cf4 \cf2 and\cf4 \cf7 is_211\cf4 = \cf9 "
|
||||||
|
\f1 \'ca\'c7
|
||||||
|
\f0 "\cf4 \cf5 --
|
||||||
|
\f1 \'b2\'e9\'d1\'af\'bc\'c8\'ca\'c7
|
||||||
|
\f0 985
|
||||||
|
\f1 \'a3\'ac\'d3\'d6\'ca\'c7
|
||||||
|
\f0 211
|
||||||
|
\f1 \'b5\'c4\'b8\'df\'d0\'a3
|
||||||
|
\f0 \
|
||||||
|
\cf4 \
|
||||||
|
\cf2 select\cf4 * \cf2 from\cf4 \cf6 school\cf4 \cf2 where\cf4 \cf6 school\cf4 \cf2 like\cf4 \cf9 "%
|
||||||
|
\f1 \'ca\'a6\'b7\'b6
|
||||||
|
\f0 %"\cf4 \cf5 --
|
||||||
|
\f1 \'b2\'e9\'d1\'af\'cb\'f9\'d3\'d0\'b5\'c4\'ca\'a6\'b7\'b6\'c0\'e0\'d4\'ba\'d0\'a3
|
||||||
|
\f0 \
|
||||||
|
\cf4 \
|
||||||
|
\cf2 select\cf4 \cf7 province\cf4 , \cf8 count\cf4 (*) \cf2 as\cf4
|
||||||
|
\f1 \'d1\'a7\'d0\'a3\'ca\'fd
|
||||||
|
\f0 \cf2 from\cf4 \cf6 school\cf4 \cf2 group\cf4 \cf2 by\cf4 \cf7 province\cf4 \cf2 order\cf4 \cf2 by\cf4
|
||||||
|
\f1 \'d1\'a7\'d0\'a3\'ca\'fd
|
||||||
|
\f0 \cf2 desc\cf4 \cf5 --
|
||||||
|
\f1 \'b6\'d4\'b8\'d5\'b2\'c5\'c9\'fa\'b3\'c9\'b5\'c4\'b8\'f7\'ca\'a1\'b7\'dd\'b8\'df\'d0\'a3\'d0\'c5\'cf\'a2\'ca\'fd\'bd\'f8\'d0\'d0\'bd\'b5\'d0\'f2\'c5\'c5\'d0\'f2
|
||||||
|
\f0 \
|
||||||
|
\cf4 \
|
||||||
|
\cf2 insert\cf4 \cf2 into\cf4 student(name, age, \cf6 school\cf4 ) \cf2 values\cf4 (\cf9 "
|
||||||
|
\f1 \'d5\'c5\'c8\'fd
|
||||||
|
\f0 "\cf4 , \cf10 20\cf4 , \cf9 "
|
||||||
|
\f1 \'bd\'ad\'ce\'f7\'b2\'c6\'be\'ad\'b4\'f3\'d1\'a7
|
||||||
|
\f0 "\cf4 ) \cf5 --
|
||||||
|
\f1 \'d4\'da\'d1\'a7\'c9\'fa\'b1\'ed
|
||||||
|
\f0 student
|
||||||
|
\f1 \'d6\'d0\'a3\'ac\'b2\'e5\'c8\'eb\'d5\'c5\'c8\'fd\'b6\'d4\'d3\'a6\'b5\'c4\'d0\'c5\'cf\'a2
|
||||||
|
\f0 \
|
||||||
|
\cf4 \
|
||||||
|
\cf2 insert\cf4 \cf2 into\cf4 student (name, \cf6 school\cf4 ) \cf2 values\cf4 (\cf9 "bbb"\cf4 , \cf9 "
|
||||||
|
\f1 \'bd\'ad\'ce\'f7\'b2\'c6\'be\'ad\'b4\'f3\'d1\'a7
|
||||||
|
\f0 "\cf4 ) \cf5 --
|
||||||
|
\f1 \'d4\'da\'d1\'a7\'c9\'fa\'b1\'ed
|
||||||
|
\f0 student
|
||||||
|
\f1 \'d6\'d0\'a3\'ac\'b2\'e5\'c8\'eb\'b6\'d4\'d3\'a6\'b5\'c4\'d0\'c5\'cf\'a2
|
||||||
|
\f0 \
|
||||||
|
\cf4 \
|
||||||
|
\cf2 update\cf4 student \cf2 set\cf4 \cf6 school\cf4 = \cf9 "
|
||||||
|
\f1 \'bd\'ad\'ce\'f7\'ca\'a6\'b7\'b6\'b4\'f3\'d1\'a7
|
||||||
|
\f0 "\cf4 \cf2 where\cf4 name = \cf9 "
|
||||||
|
\f1 \'d5\'c5\'c8\'fd
|
||||||
|
\f0 "\cf4 \cf5 --
|
||||||
|
\f1 \'bd\'ab\'d5\'c5\'c8\'fd\'b5\'c4\'d1\'a7\'d0\'a3\'b8\'c4\'ce\'aa\'bd\'ad\'ce\'f7\'ca\'a6\'b7\'b6\'b4\'f3\'d1\'a7
|
||||||
|
\f0 \
|
||||||
|
\cf4 \
|
||||||
|
\cf2 delete\cf4 \cf2 from\cf4 student \cf2 where\cf4 \cf6 school\cf4 = \cf9 "
|
||||||
|
\f1 \'bd\'ad\'ce\'f7\'b2\'c6\'be\'ad\'b4\'f3\'d1\'a7
|
||||||
|
\f0 "\cf4 \cf5 --
|
||||||
|
\f1 \'d4\'da\'d1\'a7\'c9\'fa\'b1\'ed
|
||||||
|
\f0 student
|
||||||
|
\f1 \'d6\'d0\'a3\'ac\'bd\'ab\'d1\'a7\'d0\'a3\'ca\'c7\'bd\'ad\'ce\'f7\'b2\'c6\'be\'ad\'b4\'f3\'d1\'a7\'b5\'c4\'d0\'c5\'cf\'a2\'c9\'be\'b3\'fd}
|
BIN
大数据基础与应用-学习资料/课堂练习素材/class12/exer_1.xlsx
Normal file
BIN
大数据基础与应用-学习资料/课堂练习素材/class12/exer_1.xlsx
Normal file
Binary file not shown.
BIN
大数据基础与应用-学习资料/课堂练习素材/class12/exer_2.xlsx
Normal file
BIN
大数据基础与应用-学习资料/课堂练习素材/class12/exer_2.xlsx
Normal file
Binary file not shown.
BIN
大数据基础与应用-学习资料/课堂练习素材/class12/old_man.xlsx
Normal file
BIN
大数据基础与应用-学习资料/课堂练习素材/class12/old_man.xlsx
Normal file
Binary file not shown.
BIN
大数据基础与应用-学习资料/课堂练习素材/class12/school.xlsx
Normal file
BIN
大数据基础与应用-学习资料/课堂练习素材/class12/school.xlsx
Normal file
Binary file not shown.
11
大数据基础与应用-学习资料/课堂练习素材/class13/anaconda安装jieba和wordcloud步骤.txt
Normal file
11
大数据基础与应用-学习资料/课堂练习素材/class13/anaconda安装jieba和wordcloud步骤.txt
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
方法一:使用Anaconda Navigator
|
||||||
|
打开Anaconda Navigator,选择需要安装jieba库的环境,例如“base(root)”。
|
||||||
|
在右侧的搜索栏中输入“jieba”,然后点击搜索按钮。
|
||||||
|
找到“jieba”库,勾选左侧的复选框。
|
||||||
|
点击底部的“应用”按钮来安装jieba库。
|
||||||
|
安装完成后,可以在Anaconda Navigator的“环境”选项卡下看到已安装的jieba库。
|
||||||
|
方法二:使用Anaconda Prompt
|
||||||
|
打开Anaconda Prompt。
|
||||||
|
使用以下命令通过conda-forge渠道安装jieba库:
|
||||||
|
conda install -c conda-forge jieba
|
||||||
|
conda install -c conda-forge wordcloud
|
BIN
大数据基础与应用-学习资料/课堂练习素材/class13/figure.png
Normal file
BIN
大数据基础与应用-学习资料/课堂练习素材/class13/figure.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 23 KiB |
BIN
大数据基础与应用-学习资料/课堂练习素材/class13/pikaqiu.png
Normal file
BIN
大数据基础与应用-学习资料/课堂练习素材/class13/pikaqiu.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 36 KiB |
1
大数据基础与应用-学习资料/课堂练习素材/class13/words.txt
Normal file
1
大数据基础与应用-学习资料/课堂练习素材/class13/words.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
报告分13个部分:一、过去五年的工作和历史性变革;二、新时代中国共产党的历史使命;三、新时代中国特色社会主义思想和基本方略;四、决胜全面建成小康社会,开启全面建设社会主义现代化国家新征程;五、贯彻新发展理念,建设现代化经济体系;六、健全人民当家作主制度体系,发展社会主义民主政治;七、坚定文化自信,推动社会主义文化繁荣兴盛;八、提高保障和改善民生水平,加强和创新社会治理;九、加快生态文明体制改革,建设美丽中国;十、坚持走中国特色强军之路,全面推进国防和军队现代化;十一、坚持“一国两制”,推进祖国统一;十二、坚持和平发展道路,推动构建人类命运共同体;十三、坚定不移全面从严治党,不断提高党的执政能力和领导水平。
|
151
大数据基础与应用-学习资料/课堂练习素材/class14/iris.txt
Normal file
151
大数据基础与应用-学习资料/课堂练习素材/class14/iris.txt
Normal file
@ -0,0 +1,151 @@
|
|||||||
|
"Sepal.Length" "Sepal.Width" "Petal.Length" "Petal.Width" "Species"
|
||||||
|
"1" 5.1 3.5 1.4 0.2 "setosa"
|
||||||
|
"2" 4.9 3 1.4 0.2 "setosa"
|
||||||
|
"3" 4.7 3.2 1.3 0.2 "setosa"
|
||||||
|
"4" 4.6 3.1 1.5 0.2 "setosa"
|
||||||
|
"5" 5 3.6 1.4 0.2 "setosa"
|
||||||
|
"6" 5.4 3.9 1.7 0.4 "setosa"
|
||||||
|
"7" 4.6 3.4 1.4 0.3 "setosa"
|
||||||
|
"8" 5 3.4 1.5 0.2 "setosa"
|
||||||
|
"9" 4.4 2.9 1.4 0.2 "setosa"
|
||||||
|
"10" 4.9 3.1 1.5 0.1 "setosa"
|
||||||
|
"11" 5.4 3.7 1.5 0.2 "setosa"
|
||||||
|
"12" 4.8 3.4 1.6 0.2 "setosa"
|
||||||
|
"13" 4.8 3 1.4 0.1 "setosa"
|
||||||
|
"14" 4.3 3 1.1 0.1 "setosa"
|
||||||
|
"15" 5.8 4 1.2 0.2 "setosa"
|
||||||
|
"16" 5.7 4.4 1.5 0.4 "setosa"
|
||||||
|
"17" 5.4 3.9 1.3 0.4 "setosa"
|
||||||
|
"18" 5.1 3.5 1.4 0.3 "setosa"
|
||||||
|
"19" 5.7 3.8 1.7 0.3 "setosa"
|
||||||
|
"20" 5.1 3.8 1.5 0.3 "setosa"
|
||||||
|
"21" 5.4 3.4 1.7 0.2 "setosa"
|
||||||
|
"22" 5.1 3.7 1.5 0.4 "setosa"
|
||||||
|
"23" 4.6 3.6 1 0.2 "setosa"
|
||||||
|
"24" 5.1 3.3 1.7 0.5 "setosa"
|
||||||
|
"25" 4.8 3.4 1.9 0.2 "setosa"
|
||||||
|
"26" 5 3 1.6 0.2 "setosa"
|
||||||
|
"27" 5 3.4 1.6 0.4 "setosa"
|
||||||
|
"28" 5.2 3.5 1.5 0.2 "setosa"
|
||||||
|
"29" 5.2 3.4 1.4 0.2 "setosa"
|
||||||
|
"30" 4.7 3.2 1.6 0.2 "setosa"
|
||||||
|
"31" 4.8 3.1 1.6 0.2 "setosa"
|
||||||
|
"32" 5.4 3.4 1.5 0.4 "setosa"
|
||||||
|
"33" 5.2 4.1 1.5 0.1 "setosa"
|
||||||
|
"34" 5.5 4.2 1.4 0.2 "setosa"
|
||||||
|
"35" 4.9 3.1 1.5 0.2 "setosa"
|
||||||
|
"36" 5 3.2 1.2 0.2 "setosa"
|
||||||
|
"37" 5.5 3.5 1.3 0.2 "setosa"
|
||||||
|
"38" 4.9 3.6 1.4 0.1 "setosa"
|
||||||
|
"39" 4.4 3 1.3 0.2 "setosa"
|
||||||
|
"40" 5.1 3.4 1.5 0.2 "setosa"
|
||||||
|
"41" 5 3.5 1.3 0.3 "setosa"
|
||||||
|
"42" 4.5 2.3 1.3 0.3 "setosa"
|
||||||
|
"43" 4.4 3.2 1.3 0.2 "setosa"
|
||||||
|
"44" 5 3.5 1.6 0.6 "setosa"
|
||||||
|
"45" 5.1 3.8 1.9 0.4 "setosa"
|
||||||
|
"46" 4.8 3 1.4 0.3 "setosa"
|
||||||
|
"47" 5.1 3.8 1.6 0.2 "setosa"
|
||||||
|
"48" 4.6 3.2 1.4 0.2 "setosa"
|
||||||
|
"49" 5.3 3.7 1.5 0.2 "setosa"
|
||||||
|
"50" 5 3.3 1.4 0.2 "setosa"
|
||||||
|
"51" 7 3.2 4.7 1.4 "versicolor"
|
||||||
|
"52" 6.4 3.2 4.5 1.5 "versicolor"
|
||||||
|
"53" 6.9 3.1 4.9 1.5 "versicolor"
|
||||||
|
"54" 5.5 2.3 4 1.3 "versicolor"
|
||||||
|
"55" 6.5 2.8 4.6 1.5 "versicolor"
|
||||||
|
"56" 5.7 2.8 4.5 1.3 "versicolor"
|
||||||
|
"57" 6.3 3.3 4.7 1.6 "versicolor"
|
||||||
|
"58" 4.9 2.4 3.3 1 "versicolor"
|
||||||
|
"59" 6.6 2.9 4.6 1.3 "versicolor"
|
||||||
|
"60" 5.2 2.7 3.9 1.4 "versicolor"
|
||||||
|
"61" 5 2 3.5 1 "versicolor"
|
||||||
|
"62" 5.9 3 4.2 1.5 "versicolor"
|
||||||
|
"63" 6 2.2 4 1 "versicolor"
|
||||||
|
"64" 6.1 2.9 4.7 1.4 "versicolor"
|
||||||
|
"65" 5.6 2.9 3.6 1.3 "versicolor"
|
||||||
|
"66" 6.7 3.1 4.4 1.4 "versicolor"
|
||||||
|
"67" 5.6 3 4.5 1.5 "versicolor"
|
||||||
|
"68" 5.8 2.7 4.1 1 "versicolor"
|
||||||
|
"69" 6.2 2.2 4.5 1.5 "versicolor"
|
||||||
|
"70" 5.6 2.5 3.9 1.1 "versicolor"
|
||||||
|
"71" 5.9 3.2 4.8 1.8 "versicolor"
|
||||||
|
"72" 6.1 2.8 4 1.3 "versicolor"
|
||||||
|
"73" 6.3 2.5 4.9 1.5 "versicolor"
|
||||||
|
"74" 6.1 2.8 4.7 1.2 "versicolor"
|
||||||
|
"75" 6.4 2.9 4.3 1.3 "versicolor"
|
||||||
|
"76" 6.6 3 4.4 1.4 "versicolor"
|
||||||
|
"77" 6.8 2.8 4.8 1.4 "versicolor"
|
||||||
|
"78" 6.7 3 5 1.7 "versicolor"
|
||||||
|
"79" 6 2.9 4.5 1.5 "versicolor"
|
||||||
|
"80" 5.7 2.6 3.5 1 "versicolor"
|
||||||
|
"81" 5.5 2.4 3.8 1.1 "versicolor"
|
||||||
|
"82" 5.5 2.4 3.7 1 "versicolor"
|
||||||
|
"83" 5.8 2.7 3.9 1.2 "versicolor"
|
||||||
|
"84" 6 2.7 5.1 1.6 "versicolor"
|
||||||
|
"85" 5.4 3 4.5 1.5 "versicolor"
|
||||||
|
"86" 6 3.4 4.5 1.6 "versicolor"
|
||||||
|
"87" 6.7 3.1 4.7 1.5 "versicolor"
|
||||||
|
"88" 6.3 2.3 4.4 1.3 "versicolor"
|
||||||
|
"89" 5.6 3 4.1 1.3 "versicolor"
|
||||||
|
"90" 5.5 2.5 4 1.3 "versicolor"
|
||||||
|
"91" 5.5 2.6 4.4 1.2 "versicolor"
|
||||||
|
"92" 6.1 3 4.6 1.4 "versicolor"
|
||||||
|
"93" 5.8 2.6 4 1.2 "versicolor"
|
||||||
|
"94" 5 2.3 3.3 1 "versicolor"
|
||||||
|
"95" 5.6 2.7 4.2 1.3 "versicolor"
|
||||||
|
"96" 5.7 3 4.2 1.2 "versicolor"
|
||||||
|
"97" 5.7 2.9 4.2 1.3 "versicolor"
|
||||||
|
"98" 6.2 2.9 4.3 1.3 "versicolor"
|
||||||
|
"99" 5.1 2.5 3 1.1 "versicolor"
|
||||||
|
"100" 5.7 2.8 4.1 1.3 "versicolor"
|
||||||
|
"101" 6.3 3.3 6 2.5 "virginica"
|
||||||
|
"102" 5.8 2.7 5.1 1.9 "virginica"
|
||||||
|
"103" 7.1 3 5.9 2.1 "virginica"
|
||||||
|
"104" 6.3 2.9 5.6 1.8 "virginica"
|
||||||
|
"105" 6.5 3 5.8 2.2 "virginica"
|
||||||
|
"106" 7.6 3 6.6 2.1 "virginica"
|
||||||
|
"107" 4.9 2.5 4.5 1.7 "virginica"
|
||||||
|
"108" 7.3 2.9 6.3 1.8 "virginica"
|
||||||
|
"109" 6.7 2.5 5.8 1.8 "virginica"
|
||||||
|
"110" 7.2 3.6 6.1 2.5 "virginica"
|
||||||
|
"111" 6.5 3.2 5.1 2 "virginica"
|
||||||
|
"112" 6.4 2.7 5.3 1.9 "virginica"
|
||||||
|
"113" 6.8 3 5.5 2.1 "virginica"
|
||||||
|
"114" 5.7 2.5 5 2 "virginica"
|
||||||
|
"115" 5.8 2.8 5.1 2.4 "virginica"
|
||||||
|
"116" 6.4 3.2 5.3 2.3 "virginica"
|
||||||
|
"117" 6.5 3 5.5 1.8 "virginica"
|
||||||
|
"118" 7.7 3.8 6.7 2.2 "virginica"
|
||||||
|
"119" 7.7 2.6 6.9 2.3 "virginica"
|
||||||
|
"120" 6 2.2 5 1.5 "virginica"
|
||||||
|
"121" 6.9 3.2 5.7 2.3 "virginica"
|
||||||
|
"122" 5.6 2.8 4.9 2 "virginica"
|
||||||
|
"123" 7.7 2.8 6.7 2 "virginica"
|
||||||
|
"124" 6.3 2.7 4.9 1.8 "virginica"
|
||||||
|
"125" 6.7 3.3 5.7 2.1 "virginica"
|
||||||
|
"126" 7.2 3.2 6 1.8 "virginica"
|
||||||
|
"127" 6.2 2.8 4.8 1.8 "virginica"
|
||||||
|
"128" 6.1 3 4.9 1.8 "virginica"
|
||||||
|
"129" 6.4 2.8 5.6 2.1 "virginica"
|
||||||
|
"130" 7.2 3 5.8 1.6 "virginica"
|
||||||
|
"131" 7.4 2.8 6.1 1.9 "virginica"
|
||||||
|
"132" 7.9 3.8 6.4 2 "virginica"
|
||||||
|
"133" 6.4 2.8 5.6 2.2 "virginica"
|
||||||
|
"134" 6.3 2.8 5.1 1.5 "virginica"
|
||||||
|
"135" 6.1 2.6 5.6 1.4 "virginica"
|
||||||
|
"136" 7.7 3 6.1 2.3 "virginica"
|
||||||
|
"137" 6.3 3.4 5.6 2.4 "virginica"
|
||||||
|
"138" 6.4 3.1 5.5 1.8 "virginica"
|
||||||
|
"139" 6 3 4.8 1.8 "virginica"
|
||||||
|
"140" 6.9 3.1 5.4 2.1 "virginica"
|
||||||
|
"141" 6.7 3.1 5.6 2.4 "virginica"
|
||||||
|
"142" 6.9 3.1 5.1 2.3 "virginica"
|
||||||
|
"143" 5.8 2.7 5.1 1.9 "virginica"
|
||||||
|
"144" 6.8 3.2 5.9 2.3 "virginica"
|
||||||
|
"145" 6.7 3.3 5.7 2.5 "virginica"
|
||||||
|
"146" 6.7 3 5.2 2.3 "virginica"
|
||||||
|
"147" 6.3 2.5 5 1.9 "virginica"
|
||||||
|
"148" 6.5 3 5.2 2 "virginica"
|
||||||
|
"149" 6.2 3.4 5.4 2.3 "virginica"
|
||||||
|
"150" 5.9 3 5.1 1.8 "virginica"
|
BIN
大数据基础与应用-学习资料/课堂练习素材/class8/lida-1.jpg
Normal file
BIN
大数据基础与应用-学习资料/课堂练习素材/class8/lida-1.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 747 KiB |
BIN
大数据基础与应用-学习资料/课堂练习素材/class8/lida-2.jpg
Normal file
BIN
大数据基础与应用-学习资料/课堂练习素材/class8/lida-2.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 321 KiB |
BIN
大数据基础与应用-学习资料/课堂练习素材/class8/lida/lida-3.jpg
Normal file
BIN
大数据基础与应用-学习资料/课堂练习素材/class8/lida/lida-3.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 837 KiB |
BIN
大数据基础与应用-学习资料/课堂练习素材/class8/logo.png
Normal file
BIN
大数据基础与应用-学习资料/课堂练习素材/class8/logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
BIN
大数据基础与应用-学习资料/课堂练习素材/class8/school.xls
Normal file
BIN
大数据基础与应用-学习资料/课堂练习素材/class8/school.xls
Normal file
Binary file not shown.
11
大数据基础与应用-学习资料/课堂练习素材/class8/test.txt
Normal file
11
大数据基础与应用-学习资料/课堂练习素材/class8/test.txt
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
Hello Word !1
|
||||||
|
Hello Word !2
|
||||||
|
Hello Word !3
|
||||||
|
Hello Word !4
|
||||||
|
Hello Word !5
|
||||||
|
Hello Word !6
|
||||||
|
Hello Word !7
|
||||||
|
Hello Word !8
|
||||||
|
Hello Word !9
|
||||||
|
Hello Word !10
|
||||||
|
|
8
大数据基础与应用-学习资料/课堂练习素材/class8/test_words.txt
Normal file
8
大数据基础与应用-学习资料/课堂练习素材/class8/test_words.txt
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
Here are some essential programming tips to help you enhance your coding skills:
|
||||||
|
Understand the Basics: Master fundamental concepts such as variables, data types, loops, and conditionals. A strong foundation will make learning advanced topics easier.
|
||||||
|
Practice Regularly: Like any skill, programming improves with practice. Regular coding exercises will help you retain knowledge and become more proficient.
|
||||||
|
Read and Write Code: Reading others' code can teach you new techniques and best practices. Writing your own code will help solidify your understanding.
|
||||||
|
Debug Effectively: Learn to use debugging tools and techniques to identify and fix errors efficiently. Understanding how to trace and resolve issues is crucial.
|
||||||
|
Stay Updated: The programming world is constantly evolving. Keep up with new languages, frameworks, and tools to stay competitive.
|
||||||
|
Collaborate: Working with others can provide new perspectives and solutions. Join communities or contribute to open-source projects to expand your knowledge.
|
||||||
|
By following these tips, you'll be well on your way to becoming a skilled programmer.
|
52
大数据基础与应用-学习资料/课堂练习素材/课堂练习 - 题目-5.py
Normal file
52
大数据基础与应用-学习资料/课堂练习素材/课堂练习 - 题目-5.py
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
# 第五周
|
||||||
|
# 第一题 函数的定义与调用
|
||||||
|
# 自定义一个函数,实现打印菱形功能。函数包含一个参数,
|
||||||
|
# 用于控制菱形的行数。(菱形的打印可参考第三章内容)
|
||||||
|
|
||||||
|
# rows = int(input('请输入菱形的行数:'))
|
||||||
|
# half = rows // 2
|
||||||
|
# if rows % 2 == 0:
|
||||||
|
# up = half
|
||||||
|
# else:
|
||||||
|
# up = half + 1
|
||||||
|
# for i in range(1, up + 1):
|
||||||
|
# print(' ' * (up - i), "* " * (2 * i - 1))
|
||||||
|
# for i in range(half, 0, -1):
|
||||||
|
# print(' ' * (up - i), "* " * (2 * i - 1))
|
||||||
|
|
||||||
|
|
||||||
|
# 自定义一个函数,对任意两个整数之间所有整数(包含这两个整数)进行求和。
|
||||||
|
# 函数包含两个参数,用于指定起始整数和结束整数。
|
||||||
|
# 其中小的作为起始整数,大的作为结束整数,将求和结果作为返回值返回。
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# 编写函数实现如下功能,对传递的一组数据进行操作,调整数据的位置,
|
||||||
|
# 使得所有的奇数位于前半部分,所有的偶数位于后半部分,
|
||||||
|
# 并保证奇数和奇数,偶数和偶数之间的相对位置不变。
|
||||||
|
# 例如:原始数据为:[9, 6, 7, 3, 1, 8, 4, 3, 6],
|
||||||
|
# 则调整后的数据为: [9, 7, 3, 1, 3, 6, 8, 4, 6]。
|
||||||
|
# 调用函数,并输出函数返回结果
|
||||||
|
|
||||||
|
|
||||||
|
# 第二题 参数类型与参数传递
|
||||||
|
# 自定义一个函数,用于计算矩形的面积和周长,
|
||||||
|
# 函数包含两个参数:长和宽,由于正方形是特殊的矩形,因此也支持传递一个参数的情况。
|
||||||
|
# 当传递一个参数时,表示长和宽相等,最后将计算结果进行返回。
|
||||||
|
# (同时支持一个参数和两个参数,同时返回多个值)
|
||||||
|
|
||||||
|
|
||||||
|
# 第三题 递归
|
||||||
|
# 角谷定理。随机输入一个自然数,若为偶数,则把它除以2,若为奇数,则把它乘以3加1。
|
||||||
|
# 经过如此有限次运算后,总可以得到自然数值1。
|
||||||
|
# 编写程序,捕获用户输入的数字,然后输出从该数字到最终结果1的过程,
|
||||||
|
# 统计需要经过多少步计算可得到自然数1。
|
||||||
|
# 如:输入22
|
||||||
|
# 输出 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1
|
||||||
|
# 步数为:15
|
||||||
|
|
||||||
|
|
||||||
|
# 一只青蛙一次可以跳上1级台阶,也可以跳上2级。
|
||||||
|
# 求该青蛙跳上一个n级的台阶总共有多少种跳法(先后次序不同算不同的结果)。
|
||||||
|
|
||||||
|
|
75
大数据基础与应用-学习资料/课堂练习素材/课堂练习 - 题目-9.py
Normal file
75
大数据基础与应用-学习资料/课堂练习素材/课堂练习 - 题目-9.py
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
# 第九周
|
||||||
|
# # 9.1
|
||||||
|
# 设计一个 表示圆的类:Circle,这个类包含一个实例成员变量:半径,包含两个方法:求面积的方法、求周长的方法。
|
||||||
|
# 利用这个类创建半径为1~10的圆,并打印出相应的信息,运行效果如图所示,保留两位小数。
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# # 9.2
|
||||||
|
# 阅读下列程序代码,思考程序执行结果。
|
||||||
|
class Test:
|
||||||
|
count = 0
|
||||||
|
def __init__(self, num=10):
|
||||||
|
Test.count = Test.count + 1
|
||||||
|
self.__num = num
|
||||||
|
def print(self):
|
||||||
|
print("count=", self.count)
|
||||||
|
print("num=", self.__num)
|
||||||
|
|
||||||
|
# t_1 = Test(5)
|
||||||
|
# t_2 = Test(8)
|
||||||
|
# t_1.print()
|
||||||
|
# t_2.print()
|
||||||
|
#
|
||||||
|
# t_1 = Test(5)
|
||||||
|
# t_2 = Test(8)
|
||||||
|
# t_1.count = 12
|
||||||
|
# t_1.print()
|
||||||
|
# t_2.print()
|
||||||
|
#
|
||||||
|
# t_1 = Test(5)
|
||||||
|
# t_2 = Test(8)
|
||||||
|
# Test.count = 12
|
||||||
|
# t_1.print()
|
||||||
|
# t_2.print()
|
||||||
|
|
||||||
|
# t_1 = Test(5)
|
||||||
|
# t_2 = Test(8)
|
||||||
|
# t_1.__num = 15
|
||||||
|
# t_1.print()
|
||||||
|
# t_2.print()
|
||||||
|
# print(t_1.__num)
|
||||||
|
# print(dir(t_1))
|
||||||
|
#
|
||||||
|
# t_1 = Test(5)
|
||||||
|
# t_2 = Test(8)
|
||||||
|
# t_1._Test__num = 15
|
||||||
|
# t_1.print()
|
||||||
|
# t_2.print()
|
||||||
|
|
||||||
|
|
||||||
|
# # 9.4
|
||||||
|
# 设计一个 银行账户类:Account,该类包含三个成员变量:账号、用户名、余额。
|
||||||
|
# 该类提供三个方法:存款、取款、转账。初始化时,账户余额为0,
|
||||||
|
# 取款和转账前需判断余额是否充足,
|
||||||
|
# 余额不足时,操作失败,打印相关提示信息。
|
||||||
|
# 如果两个账户账号相同时,则认为它们是同一个账户。
|
||||||
|
# 打印账户对象时,将会显示账号、用户名、余额等基本信息。
|
||||||
|
# (提示:重写__eq__方法、__str__方法)
|
||||||
|
|
||||||
|
# class Account:
|
||||||
|
# def __init__(self, num, name, balance=0):
|
||||||
|
# self.num = num
|
||||||
|
# self.name = name
|
||||||
|
# self.balance = balance
|
||||||
|
# print("账户创建成功,", self)
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# a = Account("007", "张三") # 创建账户
|
||||||
|
# a.put(2000) # 存款2000
|
||||||
|
# a.get(3000) # 取款2000
|
||||||
|
# a.get(800) # 取款800
|
||||||
|
# b = Account(num="009", name="李四") # 创建账户
|
||||||
|
# a.transform(b, 500) # 转账500
|
||||||
|
# b.transform(a, 1000) # 转账1000
|
||||||
|
|
117
大数据基础与应用-学习资料/课堂练习素材/课堂练习-题目-10.py
Normal file
117
大数据基础与应用-学习资料/课堂练习素材/课堂练习-题目-10.py
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
# 第十周
|
||||||
|
# 例题
|
||||||
|
# SQLite连接方式
|
||||||
|
# import sqlite3
|
||||||
|
# conn = sqlite3.connect("数据库.db")
|
||||||
|
|
||||||
|
|
||||||
|
# mysql连接方式
|
||||||
|
# pip install pymysql --trusted-host mirrors.aliyun.com
|
||||||
|
# import pymysql
|
||||||
|
# conn = pymysql.connect(host='localhost',
|
||||||
|
# port=3306,
|
||||||
|
# user='username',
|
||||||
|
# password='password',
|
||||||
|
# db='database',
|
||||||
|
# charset='utf8')
|
||||||
|
|
||||||
|
# sql server连接方式
|
||||||
|
# pip install pymssql --trusted-host mirrors.aliyun.com
|
||||||
|
# import pymssql
|
||||||
|
# conn = pymssql.connect(server='localhost',
|
||||||
|
# user='username',
|
||||||
|
# password='password',
|
||||||
|
# database='database')
|
||||||
|
|
||||||
|
|
||||||
|
# import xlrd
|
||||||
|
# import pymysql
|
||||||
|
# def read_excel(file_name):
|
||||||
|
# wb = xlrd.open_workbook(file_name)
|
||||||
|
# sheet = wb.sheet_by_index(0)
|
||||||
|
# schools = []
|
||||||
|
# for row in range(1, sheet.nrows):
|
||||||
|
# school = []
|
||||||
|
# for col in range(sheet.ncols):
|
||||||
|
# school.append(sheet.cell_value(row,col))
|
||||||
|
# schools.append(school)
|
||||||
|
# return schools
|
||||||
|
|
||||||
|
|
||||||
|
# def insert_data(schools):
|
||||||
|
# conn = pymysql.connect(host='localhost',
|
||||||
|
# port=3306,
|
||||||
|
# user='root',
|
||||||
|
# password='123456',
|
||||||
|
# database='test',
|
||||||
|
# charset='utf8')
|
||||||
|
# cursor = conn.cursor()
|
||||||
|
# insert_sql = """
|
||||||
|
# insert into school(school_code, school_name, province, is_985, is_211, is_self_marking, school_type)
|
||||||
|
# values (%s, %s, %s, %s, %s, %s, %s)
|
||||||
|
# """
|
||||||
|
# for school in schools:
|
||||||
|
# cursor.execute(insert_sql, school)
|
||||||
|
# conn.commit()
|
||||||
|
# cursor.close()
|
||||||
|
# conn.close()
|
||||||
|
#
|
||||||
|
# school_datas = read_excel("school.xls")
|
||||||
|
# insert_data(school_datas)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# # 课后练习
|
||||||
|
# 已知某个班级的某次考试成绩信息包括学号、语文、数学、英语、总分,
|
||||||
|
# 该成绩信息保存在一张Excel表中,部分信息如图所示,现在要求将其读入到数据库中去。同时实现以下功能:
|
||||||
|
# # 创建数据表score, 读取excel中数据到数据库表中
|
||||||
|
# import xlrd
|
||||||
|
# import sqlite3
|
||||||
|
# def read_excels(file_name): #读取Excel文件
|
||||||
|
# wb = xlrd.open_workbook(file_name) #打开Excel文件,返回的是一个工作簿
|
||||||
|
# sheet = wb.sheet_by_index(0) #由工作簿得到表单
|
||||||
|
# students = [] #由行和列来获取文件中的信息,用列表students保存
|
||||||
|
# for row in range(1, sheet.nrows):
|
||||||
|
# student = []
|
||||||
|
# for col in range(sheet.ncols):
|
||||||
|
# student.append(transform(sheet.cell_value(row, col)))
|
||||||
|
# students.append(student)
|
||||||
|
# return students
|
||||||
|
# #
|
||||||
|
# def transform(data): # 返回的成绩是浮点数,尝试转换成整型
|
||||||
|
# try:
|
||||||
|
# return int(data)
|
||||||
|
# except: # 不能转换原样返回
|
||||||
|
# return data
|
||||||
|
# #
|
||||||
|
# def init_db(): # 新建数据库
|
||||||
|
# pass
|
||||||
|
|
||||||
|
# def insert(students): # 插入数据
|
||||||
|
# pass
|
||||||
|
|
||||||
|
# init_db() # 调用函数新建数据库
|
||||||
|
# students = read_excels("学生成绩表.xls") # 调用函数插入数据
|
||||||
|
# insert(students)
|
||||||
|
#
|
||||||
|
|
||||||
|
# 格式化输出
|
||||||
|
# def print_data(datas): # 打印结果
|
||||||
|
# print("{:^8}{:^8}{:^8}{:^8}{:^8}".format("num", "chinese", "math", "english", "total"))
|
||||||
|
# for data in datas:
|
||||||
|
# print("{:^8}{:^8}{:^8}{:^8}{:^8}".format(data[0], data[1], data[2], data[3], data[4]))
|
||||||
|
#
|
||||||
|
|
||||||
|
# # 1.按照总分排序
|
||||||
|
|
||||||
|
# # 2.获取所有存在不及格科目的学生记录
|
||||||
|
|
||||||
|
# # 3.获取指定科目的最高分、最低分以及平均分
|
||||||
|
|
||||||
|
# # 4.查询三科都及格的学生信息
|
||||||
|
|
||||||
|
# # 5.将所有学生的数学成绩都加5分
|
||||||
|
|
||||||
|
# # 6.删除语文不及格的学生记录,并打印删除了多少条记录
|
58
大数据基础与应用-学习资料/课堂练习素材/课堂练习-题目-6-7.py
Normal file
58
大数据基础与应用-学习资料/课堂练习素材/课堂练习-题目-6-7.py
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
# 第六章 课后练习
|
||||||
|
# P127 课后练习 6.1
|
||||||
|
'''编写一个程序,提示用户输入一个整数,如果输入的不是整数,则让用户重新输入,直到是一个整数为止。
|
||||||
|
例如:第一次输入abc,第二次输入12.5,第三次输入6,执行效果如下:
|
||||||
|
请输入一个整数:abc
|
||||||
|
输入不符合要求,请重新输入!
|
||||||
|
请输入一个整数:12.5
|
||||||
|
输入不符合要求,请重新输入!
|
||||||
|
请输入一个整数:6
|
||||||
|
输入正确,你输入的整数为:6'''
|
||||||
|
|
||||||
|
|
||||||
|
# 第七章 课后练习
|
||||||
|
# P145 课后练习 7.6
|
||||||
|
# '''编写一个程序,模拟打印下载进度效果,每隔0.2秒打印一次下载进度,
|
||||||
|
# 要求下载进度只在一行打印,每次打印的进度不同,下载完成后打印下载完成!(程序休眠、同一行打印不换行)
|
||||||
|
# import time
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# P145 课后练习 7.7
|
||||||
|
'''编写一个程序,随机生成1000个字母,包含大写字母和小写字母,然后统计各个字母出现的次数,
|
||||||
|
统计时忽略字母的大小写,最后将统计结果按照字母出现的次数从高到低排序输出。'''
|
||||||
|
# import random as ra
|
||||||
|
# from collections import Counter
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# P145 课后练习 7.8
|
||||||
|
'''已知某个班级学生年龄分布如下:
|
||||||
|
ages = [("a", 19), ("b", 20), ("c", 20), ("d", 19), ("e", 21), ("f", 19), ("g", 18),
|
||||||
|
("h", 19), ("i", 21), ("j", 21), ("k", 18), ("l", 19), ("m", 18), ("n", 21),
|
||||||
|
("o", 18), ("p", 19), ("q", 18), ("r", 19), ("s", 20), ("t", 19), ("u", 19),
|
||||||
|
("v", 20), ("w", 19), ("x", 20), ("y", 20), ("z", 19)]
|
||||||
|
编写程序将学生按照年龄分类,并按照年龄从大到小打印出各个年龄下的学生姓名列表。
|
||||||
|
'''
|
||||||
|
# from collections import defaultdict
|
||||||
|
|
||||||
|
|
||||||
|
# 第四周字典另一种解法
|
||||||
|
# 随机输入一个字符串,统计该字符串中各种字符出现的次数,
|
||||||
|
# 并将统计结果按照字符出现次数从高到低进行排序,最终打印排序后的信息。每行效果如下:
|
||||||
|
# xxx 字符出现次数为: xxx
|
||||||
|
# P94 4.6 字典
|
||||||
|
# from collections import Counter
|
||||||
|
# a_str = input("请输入一个字符串:")
|
||||||
|
# result = Counter(a_str)
|
||||||
|
# for i in result.most_common():
|
||||||
|
# print(i[0], "字符出现的次数为:", i[1])
|
||||||
|
|
||||||
|
# a_str = input("请输入一个字符串:")
|
||||||
|
# a_dict = {}
|
||||||
|
# for i in a_str:
|
||||||
|
# old_num = a_dict.get(i, 0)
|
||||||
|
# a_dict[i] = old_num + 1
|
||||||
|
# result = sorted(a_dict.items(), key=lambda item: item[1], reverse=True)
|
||||||
|
# for i in result:
|
||||||
|
# print(i[0], "字符出现的次数为:", i[1])
|
67
大数据基础与应用-学习资料/课堂练习素材/课堂练习-题目-8.py
Normal file
67
大数据基础与应用-学习资料/课堂练习素材/课堂练习-题目-8.py
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
# 第八周
|
||||||
|
# # 课后练习
|
||||||
|
# # P165 课后练习8.5
|
||||||
|
# '''编写程序实现九九乘法表,并将其保存到文件test.txt中去。'''
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# # P165 课后练习8.6
|
||||||
|
# '''编写程序实现递归搜索class8文件夹下所有的图片文件(例如 jpg、png文件),
|
||||||
|
# 并将所有的图片文件复制到D:\images文件夹下。(关键提示:图片文件的复制可采用二进制操作)'''
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# # P165 课后练习8.7
|
||||||
|
# '''编写程序读取学校信息表内容,然后单独将所有的211高校放入一个表单,
|
||||||
|
# 将所有的985高校放入一个表单,两个表单位于同一个Excel文件。'''
|
||||||
|
# '''
|
||||||
|
|
||||||
|
# import xlrd
|
||||||
|
# import xlwt
|
||||||
|
# def get_schools(file_name): #读取Excel文件
|
||||||
|
# wb = xlrd.open_workbook(file_name) #打开Excel文件,返回的是一个工作簿
|
||||||
|
# sheet = wb.sheet_by_index(0) #由工作簿得到表单
|
||||||
|
# school_list = [] #由行和列来获取文件中的信息,用列表school_list保存
|
||||||
|
# for row in range(sheet.nrows):
|
||||||
|
# school = []
|
||||||
|
# for col in range(sheet.ncols):
|
||||||
|
# school.append(sheet.cell_value(row, col))
|
||||||
|
# school_list.append(school)
|
||||||
|
# return school_list
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# # P165 课后练习8.8
|
||||||
|
# '''编写程序读取给定的test.txt文件内容,统计该文件中各单词出现的次数,
|
||||||
|
# 并将统计结果按照单词出现的次数从高到低写入到文件result.xsl中。
|
||||||
|
# (test.txt是一个英文文本,单词之间通过空格隔开, 要求单词不区分大小写,
|
||||||
|
# 忽略逗号、句号等标点符号。result.xsl文件标题为词频统计结果,
|
||||||
|
# 包含两列名称分别为:单词和频数,所有的频数以加粗红色显示。)'''
|
||||||
|
# '''
|
||||||
|
# 测试本段代码的文件在class8文件夹下,文件名为"test_words.txt",然后将文件直接拖进本项目中测试
|
||||||
|
# '''
|
||||||
|
# import xlwt
|
||||||
|
|
||||||
|
# def read_text(): #读取文件进行分割等相关操作
|
||||||
|
# with open(r"D:\python\test_words.txt", mode="r", encoding="utf-8") as fp:
|
||||||
|
# 补全代码
|
||||||
|
|
||||||
|
|
||||||
|
# def sort(words): #排序
|
||||||
|
# word_value = {}
|
||||||
|
# for word in words:
|
||||||
|
# word_value[word] = word_value.get(word, 0) + 1 #统计单词的频数,判断原来是否有,如果原来没有,默认值为0,也执行"+1"操作
|
||||||
|
# result_list = sorted(word_value.items(), key=lambda item: item[1], reverse=True)#降序
|
||||||
|
# return result_list
|
||||||
|
|
||||||
|
|
||||||
|
# def write_to_excel(result_list): # 写入内容
|
||||||
|
# 补全代码
|
||||||
|
|
||||||
|
|
||||||
|
# word_list = read_text()
|
||||||
|
# results = sort(word_list)
|
||||||
|
# write_to_excel(results)
|
Loading…
x
Reference in New Issue
Block a user