当前位置:网站首页>Basic experiment of data statistics and analysis - basic grammar and operation
Basic experiment of data statistics and analysis - basic grammar and operation
2022-06-23 07:27:00 【Hebuter-Rui】
The experimental requirements
Students are required to be familiar with practical software ( Such as python、Matlab、R etc. ) Basic programming content in , Master the methods of debugging practical software and running programs 、 The idea of task oriented programming , The idea of data statistics and analysis is designed for the task 、 Programming , In particular, master the practical software statements of common machine learning algorithms and various graphics and image rendering methods . We should pay attention to cultivating students' good programming habits , Implement the programming style introduced in the course from beginning to end . In order to ensure that the programming task can be completed within the uniformly arranged computer time , Students should do problem analysis in advance , And conduct static inspection . Students should record the problems encountered in the experiment , And write a detailed experimental report . Prepare the computer program before class , Start the machine and debug carefully , Write an experiment report after class , The experiment report includes the purpose of the experiment 、 Experimental content 、 Source program and experimental results .
The experiment purpose
Master practical software ( Such as python、Matlab、R Wait, choose one ) Basic syntax 、 How to use basic data types , Master inputting and calculating basic types of data from the keyboard , Proficient in branch 、 Loop and other statements control program flow .
Experimental content
1. Programming , Record the information of ten students , At least include the name 、 Age 、 Year of birth 、 Experimental results of data statistical analysis course , Before program output n The average age of a student 、 Average experimental score of data statistical analysis course ,n Is the input parameter of the function .
Source code :
import numpy as np
import xlrd # read excel
stu_name = [] # Define a list of names
stu_age = [] # Define age list
stu_year = [] # Define the birth year list
stu_score = [] # Define the score list
data = xlrd.open_workbook('E:\ Learning materials \ Basis of data statistics and analysis \ experiment 1\student.xls')
table = data.sheets()[0]
def get(): # Read from file 10 Student information
for i in range(table.nrows):
stu_name.append(str(table.cell_value(i, 0)))
stu_age.append(int(table.cell_value(i, 1)))
stu_year.append(int(table.cell_value(i, 2)))
stu_score.append(int(table.cell_value(i, 3)))
def avg(n): # Before calculation n Average score and average age of students
avg_age = np.mean(np.array(stu_age)[:n])
avg_score = np.mean(np.array(stu_score)[:n])
return avg_age, avg_score
def main():
get()
n = int(input(" Input n:"))
print(" The average age is :%.2f" % avg(n)[0])
print(" The average score is :%.2f" % avg(n)[1])
if __name__ == '__main__':
main()2. find 1 to 999 Between 13 The multiple of or the first two digits are 13 The number of , Output these numbers , And count how many .
Source code :
import numpy
def main():
num = 0
for i in range(1,1000,1):
if i%13 == 0 or i//10 == 13:
num += 1
print(i)
if __name__ == '__main__':
main()3. Write a function that converts grades to grade points , use 98,93,89,73,66 Call the function separately , Generate corresponding grade point .
Source code :
import numpy
def jd(i):
if i >= 90:
n = 4.0
else:
n = (i-50)/10
print(" The grade point is :",n)
def main():
for j in range(5):
i = int(input(" Please enter the grade :"))
jd(i)
if __name__ == '__main__':
main()4. Randomly generate two with a length of 100 And obey the standard normal distribution vector , Then swap the values of all even bits of the two vectors , Output all 4 Vector ( Before the exchange 2 individual , After the exchange 2 individual ).
Source code :
import numpy as np
def main():
a = np.random.randn(100)
b = np.random.randn(100)
print(a)
print(b)
for i in range(1,100,2):
t = a[i]
a[i] = b[i]
b[i] = t
print(a)
print(b)
if __name__ == '__main__':
main()5、 It is known that XYZ+YZZ=532, among X、Y and Z Is the number , Calculate by programming X,Y and Z Value .
Source code :
import numpy
def main():
for x in range(6):
for y in range(6):
for z in range(10):
if 100*x+10*y+z+100*y+10*z+z == 532:
print("x=",x,"\ty=",y,"\tz=",z)
if __name__ == '__main__':
main()Search for
Copy
边栏推荐
- 100 GIS practical application cases (79) - key points of making multi plan integrated base map
- leetcode210. 课程表 II 207. 课程表 拓扑排序 dfs bfs
- 微信多人聊天及轮盘小游戏(websocket实现)
- 作为思摩尔应对气候变化紧急事件的一项举措,FEELM加入碳披露项目
- MySQL Niuke brush questions
- Nacos adapts to oracle11g- modify the source code of Nacos
- 301. delete invalid brackets
- 【AI实战】XGBRegressor模型加速训练,使用GPU秒级训练XGBRegressor
- 309. the best time to buy and sell stocks includes the freezing period
- Realization of rolling broadcast effect
猜你喜欢

UNET code implementation

In depth learning series 47:stylegan summary

【PyQt5系列】修改计数器实现控制

MySQL Niuke brush questions

407 stack and queue (232. implementing queue with stack, 225. implementing stack with queue)

How flannel works
![[* * * array * * *]](/img/fe/2520d85faab7d1fbf5036973ff5965.png)
[* * * array * * *]

Product axure9 (English version), prototype design background dynamic secondary menu display content

MYSQL牛客刷题

20bn Jester complete dataset Download
随机推荐
SSTable详解
User mode and kernel mode
Both are hard disk partitions. What is the difference between C disk and D disk?
898. subarray bitwise OR operation
启发式的搜索策略
UNET code implementation
Sstable details
The List
Analyzing the creation principle in maker Education
How to solve CSRF attack in laravel
Unet代码实现
Deep learning series 47: Super sub model real esrgan
What is the experience of being a data product manager in the financial industry
数据库原理实验测试题,关于图书分类表
GINet
【2022毕业季】从毕业到转入职场
Arthas-thread命令定位线程死锁
SimpleDateFormat 线程安全问题
leetcode210. 课程表 II 207. 课程表 拓扑排序 dfs bfs
Regular expression graph and text ultra detailed summary without rote memorization (Part 1)