0%

1.栈与队列

剑指09.用两个栈实现队列

用两个栈实现一个队列。队列的声明如下,请实现它的两个函数 appendTaildeleteHead ,分别完成在队列尾部插入整数和在队列头部删除整数的功能。(若队列中没有元素,deleteHead 操作返回 -1 )

阅读全文 »

Basic properties of Arrays

数组:

​ 1.任意维度,包括0(a scalar)

​ 2.类型: np.unit8, np.int64, np.float32, np.float64

​ 3.密集的,元素的类型相同

​ 4.不同shape无法combine

1
2
a = np.array([1,2,3],[4,5,6],dtype = np.float32)
print(a.ndim, a,shape, a.dtype)
1
2 (2,3) float32
阅读全文 »

Lab8 Pandas_1

Exam1

1. Create a 5-D random numpy list var_list

1
2
import numpy as np
var_list = np.random.randn(5)

2. use “uuid” to generate 5 random keys (use str(uuid.uuid4())), and store them into a list key_list

1
2
import uuid
key_list = [str(uuid.uuid4())[:6] for i in range(5)]
阅读全文 »

Lab4 IO

Q1

1
2
3
4
5
6
file = open('./districts.txt','r')
districts = [line for line in file]
districts.sort()
for i in range(0,18):
print(districts[i])
file.close()
阅读全文 »