当前位置:网站首页>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
边栏推荐
- MySQL (IV) - MySQL storage engine
- SimpleDateFormat 线程安全问题
- MySQL(四) — MySQL存储引擎
- [AI practice] data normalization and standardization of machine learning data processing
- 微信多人聊天及轮盘小游戏(websocket实现)
- 407 stack and queue (232. implementing queue with stack, 225. implementing stack with queue)
- Spock约束-调用频率/目标/方法参数
- NPM download error NPM err code error
- SSTable详解
- codeforce 158B Taxi
猜你喜欢

Advanced drawing skills of Excel lecture 100 (VIII) -excel drawing WiFi diagram

junit单元测试报错org.junit.runners.model.InvalidTestClassError: Invalid test class ‘xxx‘ .No runnable meth

深度学习系列47:超分模型Real-ESRGAN

Unet代码实现

Yan's DP analysis

Product axure9 (English version), prototype design and production pull-down secondary menu

微信多人聊天及轮盘小游戏(websocket实现)

U-Net: Convolutional Networks for Biomedical Image Segmentation

Tp6+redis+think-queue+supervisor implements the process resident message queue /job task

闫氏DP分析法
随机推荐
313. super ugly number
20BN-Jester完整数据集下载
Heuristic search strategy
Yan's DP analysis
315. calculate the number of elements on the right that are smaller than the current element
GloRe
ldconfig 命令
407 stack and queue (232. implementing queue with stack, 225. implementing stack with queue)
都是硬盘分区 C盘和D盘到底有什么区别?
Analysis of personalized learning progress in maker Education
Nacos适配oracle11g-建表ddl语句
Technical article writing guide
yolov5检测小目标(附源码)
Regular expression graph and text ultra detailed summary without rote memorization (Part 1)
'Latin-1' codec can't encode characters in position 103-115: body ('string of Chinese ') is not valid Latin-1
Several characteristics of MySQL database
Ntu-rgbd data set download and data format analysis
Interpreting the spirit of unity and cooperation in maker Education
Flannel 工作原理
leetcode210. Schedule II 207 Curriculum topology sorting DFS BFS