摘要: 一、散列函数:无论你给它什么数据,它都还你一个数字。 要求: 1.一致:输入apple时得到的是4,那么每次输入apple时,得到的必须都是4。 2.将不同的输入映射到不同的数字。 结合散列函数(输出为索引)和数组创建散列表(hash table)的数据结构。python提供的散列表实现为字典。 二 阅读全文
posted @ 2020-04-11 20:01 闪亮可可仙 阅读(137) 评论(0) 推荐(0) 编辑
摘要: 一、分而治之(divide and conquer,D&C) d&c解决问题的两个步骤: 1.找基线条件(最小单位)or(只剩一个或为空); 2.将问题的规模缩小,不断递归直到基线条件; 利用循环求和: 1 def sum(arr): 2 total = 0 3 for i in arr: 4 to 阅读全文
posted @ 2020-04-09 22:57 闪亮可可仙 阅读(236) 评论(0) 推荐(0) 编辑
摘要: 一、类 1 class CocaCoca: 2 formula = ['caffeine','sugar','water','soda'] #类的变量(属性) 3 4 coke_for_me = CocaCoca() #类的实例化 5 coke_for_you = CocaCoca() 6 7 pr 阅读全文
posted @ 2020-04-09 14:50 闪亮可可仙 阅读(135) 评论(0) 推荐(0) 编辑
摘要: 1.检查手机号 1 def sendTextNumber(): 2 3 CN_mobile = ['134','135','136','137','138','139', 4 '150','151','152','157','158','159', 5 '182','183','184','187' 阅读全文
posted @ 2020-04-08 22:49 闪亮可可仙 阅读(194) 评论(0) 推荐(0) 编辑
摘要: 一、二分查找 思想:从中间开始查找。 时间复杂度:O(logN)。 eg.查英文字典。 eg.猜0-100大小数从50开始猜。 二分查找是一种算法,其输入一个有序的元素列表。如果要查找的元素包含在列表中,二分查找返回其位置,否则返回null(或者-1)。 1 import math 2 3 def 阅读全文
posted @ 2020-04-07 14:01 闪亮可可仙 阅读(323) 评论(0) 推荐(0) 编辑
摘要: 参考:https://www.runoob.com/python/python-files-io.html 1.open()函数 用于打开一个文件,创建一个 file 对象,相关的方法才可以调用它进行读写。 1 f = open('C:/Users/LKX/Desktop/first.txt') 2 阅读全文
posted @ 2020-04-05 20:15 闪亮可可仙 阅读(276) 评论(0) 推荐(0) 编辑
摘要: 一、缺失数据NaN 1 from pandas import Series,DataFrame 2 import numpy as np 3 import pandas as pd 4 string_data = Series(['musickness','choke',np.nan,'love'] 阅读全文
posted @ 2019-12-13 11:18 闪亮可可仙 阅读(332) 评论(0) 推荐(0) 编辑
摘要: 1.查询和学号11328、11427同学同年出生的所有学生的stu_num、stu_name、stu_birth; 查询11328与11427: mysql> select * from student where stu_num in (11328,11427); + + + + + + | st 阅读全文
posted @ 2019-12-04 16:56 闪亮可可仙 阅读(291) 评论(0) 推荐(0) 编辑
摘要: 1.查询所有学生的stu_name,cour_num,degree列: 其中stu_name字段来自于student表;cour_num和degree字段来自于score表; mysql> select * from student; + + + + + + | stu_num | stu_name 阅读全文
posted @ 2019-12-04 16:53 闪亮可可仙 阅读(201) 评论(0) 推荐(0) 编辑
摘要: 1.查询每门课的平均成绩: mysql> select * from course; + + + + | cour_num | cour_name | tea_num | + + + + | 1-245 | Math | 0438 | | 2-271 | Circuit | 0435 | | 3-1 阅读全文
posted @ 2019-12-04 16:48 闪亮可可仙 阅读(574) 评论(0) 推荐(0) 编辑