- 博客(22)
- 资源 (8)
- 问答 (1)
- 收藏
- 关注
原创 python 泰坦尼克号存活率分析
对泰坦尼克号的数据 进行特征分析、数据清理、数据填充、处理分类特征、将连续特征转化为离散特征、合并特征、制作模型、模型预测import pandas as pdimport numpy as npimport matplotlib.pyplot as plt#将警告不显示import warningswarnings.filterwarnings('ignore')#导入测试集和训练集train_df=pd.read_csv('train.csv')# train_df.head()t
2021-11-08 10:52:32 2833
原创 python分析UFO报道数据
python+numpy、pandas、matplotlib库分析UFO数据#导入库与数据import numpy as npimport matplotlib.pyplot as pltimport pandas as pddf1=pd.read_csv('nuforc_events.csv')df=df1.dropna() #把包含缺失值的整行删除# print(df.head)year=np.array(df['Year'][0:109991])month=np.array(df[
2021-11-01 09:58:18 414
原创 python 统计英文词频
python 统计英文词频 (以1986-2017年考研英语真题为例)运行截图:代码:import re#除去简单词、序号等excludes = ['the', 'of', 'to', 'and', 'in', 'a', 'is', 'were', 'was', 'you', 'I', 'he', 'his', 'there', 'those', 'she', 'her', 'their', 'that', '[a]', '[b]', '[c]',
2021-06-14 15:40:43 2885 1
原创 python 计算平均值、中位数、标准差
python计算平均值、中位数、标准差(通过导入原有txt文件中的数组)运行截图:代码:def getdata(filename): #导入原有txt文件中的数组 with open(filename, 'r') as f: numlist=f.readlines() nums=[] for data in numlist: nums.append(int(data)) return num
2021-06-14 15:30:22 8958
原创 数据结构 排序
2021.6.14 数据结构 起泡排序 快速排序(int 数组)运行截图:代码:#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>#include<string.h> #include<iostream>#include<stdlib.h>using namespace std;#define NSIZE 8//冒泡排序void InserSort(int arr[NSIZE]){
2021-06-14 15:25:49 94
原创 python网络爬虫 爬取新闻标题、时间、内容
(爬取清华大学体育部重要新闻前十页)运行截图:代码:import requestsfrom bs4 import BeautifulSoupimport csvimport time# http://www.thsports.tsinghua.edu.cn/publish/sports/1899/index.html# http://www.thsports.tsinghua.edu.cn/publish/sports/1899/index_2.html# http://www.ths
2021-05-12 18:27:36 4700 3
原创 数据结构 二叉树
4.29 数据结构 二叉树手动输入节点值,二叉树的前序、中序、后序遍历及销毁 并计算二叉树的节点数运行结果截图:代码:/*许沐 207602044.28 二叉树 */#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>#include<string.h> #include<iostream>#include<stdlib.h>using namespace std;#define MAX
2021-04-29 20:19:04 153
原创 python 爬取豆瓣top100电影页面
python 爬取豆瓣top100电影页面运行结果截图:代码:(原网站:https://movie.douban.com/top250)1、将页面保存 避免多次访问(登陆状态需页面cookie)import requestsurl="https://movie.douban.com/top250"headers={'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like
2021-04-29 18:05:01 683
原创 python 网络页面爬取
4.22 python 网络页面爬取对国家体育总局(例)页面进行简单爬取运行结果截图:代码:import requestsurl="http://www.sport.gov.cn/n316/n336/c947645/content.html"try: headers={'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.443
2021-04-22 19:30:37 184 2
原创 数据结构 判断数组元素是否互不相同
4.18 数据结构 判断数组元素是否互不相同-----题目设二维数组a、b 含有m*n 个整数。写一个算法判断a,b两个数组中所有元素是否互不相同?输出相关信息a[4][3]={1,2,3,4,5,6,7,8,9,10,11,12};b[4][3]={1,2,3,3,5,6,7,8,9,10,11,12};运行结果截图:代码:/*4.18 数组 */#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>#include<st
2021-04-18 17:35:56 2122
原创 python函数递归 汉诺塔
4.7 python函数递归 汉诺塔代码:def hanno(n,A,B,C): global step if n==1: print('{}->{}'.format(A,C)) step +=1 else: hanno(n-1,A,C,B) print('{}->{}'.format(A,C)) step += 1 hanno(n - 1,B,A,C) retur
2021-04-07 10:00:09 199
原创 python函数递归 斐波那契数列
4.7 python函数递归 斐波那契数列代码:(利用递归、format输出等)def fibonacci(n): if n==1 or n==2: f=1 else: f=fibonacci(n-1)+fibonacci(n-2) return f i=int(input("请输入一个数:"))f=fibonacci(i)print("第{0}项的斐波那契数为:{1}".format(
2021-04-07 09:07:54 991
原创 python函数递归 字符串反转
4.7 python函数递归 字符串反转代码:def fanzhuan(s): if len(s)==1: s2=s else: s2=s[-1]+fanzhuan(s[:len(s)-1]) return s2s1='132fddeewwea's2=fanzhuan(s1)print("反转前的字符串为:",s1)print("反转后的字符串为:",s2)运行结果:...
2021-04-07 08:43:11 3778
原创 python 身体BMI指数判断
3.30 python身体BMI指数判断代码:height,weight=eval(input("请输入身高(米)体重(公斤):"))bim=weight/pow(height,2)print("BIM指数为:{:.2f}".format(bim)) a,b="",""if bim<18.5: a,b="偏瘦","偏瘦"elif 18.5<=bim<24: a,b="正常","正常"elif 24<=bim<25: a,b="正常","偏
2021-04-01 17:53:17 5026
原创 python 判断闰年
4.1 python 判断闰年代码year=int(input("请输入年份:"))if(year%4==0 and year%100 !=0): print("是闰年!")elif(year%400==0): print("是闰年!")else: print("不是闰年!")运行结果截图:
2021-04-01 17:51:30 35128 9
原创 python 基础简单猜数游戏
4.1 python 猜数游戏代码import randomnumber=random.randint(1,5)guess=int(input("请输入一个1-5之间的数字:"))if guess == number: print("猜对了!")else : print("猜错了!")break运行结果
2021-04-01 17:50:18 732
原创 python 用户登录判断
4.1python 用户登录判断代码:name='admin'password='123456'n=0while(n<=3): iname=input("请输入用户名:") ipassword=input("请输入密码:") if(iname == name and ipassword == password): print("登陆成功!") break else: print("您的用户名或密码错误,
2021-04-01 17:47:02 3296
原创 数据结构 创建顺序栈
3.27数据结构——创建顺序栈结构体定义 初始化栈 入栈 出栈 销毁栈运行结果截图:代码:/*许沐 207602043.27 顺序栈*/#define _CRT_SECURE_NO_WARNINGS#define MAXSIZE 100#include<stdio.h>#include<string.h> #include<iostream>#include<stdlib.h>using namespace std;typ
2021-03-27 17:31:59 991 1
原创 数据结构 创建顺序表
3.18数据结构——创建顺序表运行结果截图:#define _CRT_SECURE_NO_WARNINGS#define MAXSIZE 100#include<stdio.h>#include<string.h> #include<iostream>typedef int ElemType;typedef struct //定义结构{ ElemType* element; int length; int lists
2021-03-25 19:32:20 5782 1
原创 python 列表
3.17python作业——列表运行结果截图:代码:1、创建一个空列表,命名为names,往里面添加 Lihua、Rain、Jack、Xiuxiu、Peiqi和Black元素。name=[ "Lihua","Rain","Jack","Xiuxiu","Peiqi","Black"]name2、往(1)中的names列表里Black前面插入一个Blue。name.insert(5,"Blue")name3、把names列表中Xiuxiu的名字改成中文。name.re
2021-03-25 19:27:32 5522 2
原创 Python温度转换器
3.16 python作业——温度转换器运行结果截图代码:TempStr = input("请输入带有符号的温度值:")if TempStr[-1] in['F','f']: C=(eval(TempStr[0:-1])-32)/1.8 print("转换后的温度是{:.2f}C".format(C))elif TempStr[-1] in ['C','c']: F=1.8*eval (TempStr[0:-1])+ 32 print("转换后的温度是{:.2f
2021-03-25 19:24:06 534
python如何获取div中的文字
2022-06-17
TA创建的收藏夹 TA关注的收藏夹
TA关注的人