一、专业实习内容
1)python基础语法,数据类型及其操作,函数的语法结构
2)异常处理,文件操作
3)Matplotlib画图功能
4)无监督学习算法 K-MEANS算法 监督学习算法KNN算法
5)Python面向对象设计和爬虫
二、具体实习内容
1)python基础语法,数据类型及其操作:主要学习基础语法:分支结构,循环结构语句,元组,数组,字典等存储结构的基础语法和相互转化,和函数的语法结构:
name='杨满';
str1='中国高铁被外界誉为当代中国的“新四大发明”之一(新四大发明包括:高铁,扫码支付,共享单车,网上购物),据悉,中国高铁-复兴号目前最高时速为350公里每小时,5年之内将提速30%达到()公里每小时,以更快的速度助力中国经济。新华社记者-()';
a=str1.find("最高时速为")
b=str1.find("公里每小时")
tisu=str1.find("提速")
tisu+=3;
dadao=str1.find("达到")
jizhe=str1.find("记者-(")
c=a+5
currentSpeed =int(str1[c:b])
currentRate=int(str1[tisu-1:dadao-1])
currentRate=currentRate/100;
newSpeend=currentSpeed+currentSpeed*currentRate;
newspeed=str(newSpeend)
str2=list(str1);
str2.(dadao+3,newspeed)
str2.(jizhe+5,name)
greatChina=''.join(str2)
print(greatChina)
2)异常处理和文件处理:
主要学习了异常处理的基础语法,和设置异常处理的原则,文件的读写
def fun_error():
print("请重新输入,您刚才输入的省份不存在")
def fun_error2():
print("算错了")
try:
prove['广西']
except KeyError:
fun_error()
try:
print(1/0)
except ZeroDivisionError:
fun_error2()
fun_error2()
f=open("ni.txt",'r',encoding='utf-8')
data=f.read()
print(data)
f.write("欢迎")
f.close()
3)matplotlib画图实现:
主要学习将数据展示位散点图和折线图的方法:
import matplotlib.pyplot as plt
import numpy as np
plt.rcParams['font.sans-serif'] = 'SimHei'
plt.rcParams['axes.unicode_minus'] = False
p1=plt.figure()
plt.title("杨满+2015080332096+1949,1956,1960年代乘客数据分析")
plt.xlabel("月份")
plt.ylabel("人数")
plt.xlim(1,13) # 设定x轴范围
plt.ylim((100, 650))
plt.xticks(np.arange(1, 13, step=1))
plt.yticks(np.arange(0, 650, step=50))
year_1949=(112,118,132,129,121,135,148,148,136,119,104,118)
year_1956=(284,277,317,313,318,313,318,374,413,405,355,306)
year_1960=(417,391,419,461,472,535,622,606,508,461,390,432)
plt.plot(year_1949,color='red',linewidth=4.0,linestyle='-.',marker='*',markersize=10)
plt.plot(year_1956,color='blue',linewidth=3.0,linestyle='--',marker='s',markersize=10)
plt.plot(year_1960,color='yellow',linewidth=2.0,linestyle=':',marker='^',markersize=10)
plt.legend(['1949年代','1956年代','1960年代'])
plt.savefig('d:/home1.png')
plt.show()
4)k-means算法 和k-nn算法
主要学习了非监督学习和监督学习中两个最基础的算法,了解了算法的编程思想和动手实现了算法:
K-means算法:
import matplotlib.pyplot as plt
import numpy as np
import random
from numpy import *
import math
#初始图
plt.rcParams['font.sans-serif'] = 'SimHei'
plt.rcParams['axes.unicode_minus'] = False
p1=plt.figure(figsize=(8,6),dpi=80)
plt.xlabel("平均消费周期")
plt.ylabel("每次消费金额")
plt.xlim(1,100) # 设定x轴范围
plt.ylim((0, 800))
# plt.xticks(np.arange(1, 100, step=1))
# plt.yticks(np.arange(0, 800, step=10))
x=[10,13,17,67,35,1,10,12,8,1,32,3,90,1,16,31,25]
y=[317,147,172,194,789,190,281,142,186,226,287,499,181,172,190,271,382]
plt.scatter(x, y)
#参数规定
k_number=3
x_random=[]
y_random=[]
dic=[]
result_x_num0=[]
result_y_num0=[]
result_x_num1=[]
result_y_num1=[]
result_x_num2=[]
result_y_num2=[]
#随机生成类聚中心点坐标
for i in range (0,k_number):
random_kid_x=random.randint(1,100)
x_random.append(random_kid_x)
random_kid_y=random.randint(0,800)
y_random.append(random_kid_y)
x_randomz_first=x_random#存放第一次聚类中心的x坐标
y_random_first=y_random#存放第一次聚类中心的y坐标
x_randomz_second=[0,0,0]#存放第二次聚类中心的x坐标
y_random_second=[0,0,0]#存放第二次聚类中心的y坐标
result_x_num0 = []#存放0号类的x的坐标
result_y_num0 = []#存放0号类的y的坐标
result_x_num1 = []#存放1号类的x的坐标
result_y_num1 = []#存放1号类的y的坐标
result_x_num2 = []#存放2号类的x的坐标
result_y_num2 = []#存放2号类的y的坐标
result_x=0
result_y=0
相关推荐
【Python培训 】从小白到大咖 打造Python精英人才
>>本文地址:https://www.ujiuye.com/dxs/2018/45463.html
声明:本站稿件版权均属中公教育优就业所有,未经许可不得擅自转载。
1 您的年龄
2 您的学历
3 您更想做哪个方向的工作?
上一篇 【实习报告】Python实习总结