- 博客(7)
- 收藏
- 关注
原创 python机器学习第一个算法“单变量线性回归”
# -*- coding: utf-8 -*-"""Created on Fri May 10 14:28:02 2019@author: Administrator"""import numpy as npimport matplotlib.pyplot as pltimport matplotlib as mplmpl.rcParams['font.sans-serif'...
2019-05-13 20:08:51
396
原创 Python实现随机DNA序列,生成文件并匹配相似度文件
#导入模块import randomseed='ABCD'f=open('dna1.txt','w')for j in range(2000): s='' for i in range(20): s+=random.choice(seed) f.write('S'+str(j).zfill(5)+'\t'+s+'\n')f.flush()f.cl...
2019-02-23 09:05:17
2505
原创 python多线程实现窗口卖票系统
例一、创建十个线程,卖100张火车票import threadinglist_ticket = []lock = threading.Lock() # 获取线程锁num = 100j = 0for i in range(1,num+1): ticket_num = '0'*(len(str(num))-len(str(i))) + str(i) list_ticke...
2019-03-15 09:41:09
4396
1
原创 python利用面向对象的思想实现功能代码练习
1.利用面向对象的思想,实现以下功能:(1)创建一个猫(Cat)类,其包含属性:名字(name)、品种(type)、价格(price)、颜色(color),并定义适当构造、析构的方法(2)创建一个老鼠(Mouse)类,其包含属性:名字(name)、颜色(color),并定义适当的构造、析构方法(3)在Cat类中定义一个属性cat_num,该属性存储的值为当前已实例化的猫的个数#(4)在...
2019-03-12 20:56:33
1848
原创 Python基础练习代码持续更新。。。。。。。
一、有1、2、3、4个数字,能组成多少个互不相同且无重复数字的三位数?for i in range(1,5): for j in range(1,5): for k in range(1,5): if i != j and i!=k and k != j: print(i,j,k,end='|') print...
2019-03-05 20:39:46
785
原创 用Python将字符串写入.txt文档,统计每个单词的个数并排序
# 读入文件‘monday.txt’.统计文件中每个单词的数量并且进行输出。# txt的文本文件为# Monday.txt的文本内容为# The pie chart above illustrates apparently the data of people doing exercise and the number of the gyms in a certain# city of c...
2019-02-27 19:27:55
3073
原创 Python函数小笔记
# 无参数无返回值def printinfo(): print('--------------') print('生命苦短我用Python') print('--------------')printinfo()# 有参函数def num_add(a,b): c = a+b print('a+b的结果:',c)num_add(3,5)# 函数...
2019-02-24 19:36:03
203
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅