当前位置:网站首页>Have a look at this generation
Have a look at this generation
2022-07-06 02:02:00 【Wild universe PY】
input data
def getNum():
nums = []
iNumStr = input('please input a sequence of numbers (enter to exit): ')
while iNumStr != ‘’:
nums.append(eval(iNumStr))
iNumStr = input('please input a sequence of numbers (enter to exit): ')
return nums
The average
def average(numbers):
return sum(numbers) / len(numbers)
Standard deviation
def dev(numbers, average):
sdev = 0.0
for num in numbers:
sdev += (num - average) ** 2
return pow(sdev / len(numbers), 0.5)
Median
def median(numbers):
sorted(numbers)
size = len(numbers)
if size % 2 == 0:
return (numbers[size//2-1] + numbers[size//2]) / 2
else:
return numbers[size//2]
Absolute and relative errors
def rel_dev(numbers, average):
_max = max(abs(max(numbers) - average), abs(min(numbers) - average))
return _max, _max / average
def main():
nums = getNum()
if len(nums) == 0:
print(‘no data’)
else:
ave = average(nums)
devs = rel_dev(nums, ave)
print(‘ and :{:.4f}, The average :{:.4f}, Median :{:.4f}, variance :{:.4f}, Absolute error :{:4f}, Relative error :{:.4f}’
.format(sum(nums), ave, median(nums), dev(nums, ave), devs[0], devs[1]))
if name == ‘main’:
main()
边栏推荐
- Blue Bridge Cup embedded_ STM32 learning_ Key_ Explain in detail
- GBase 8c数据库升级报错
- PHP campus financial management system for computer graduation design
- [depth first search notes] Abstract DFS
- 剑指 Offer 38. 字符串的排列
- Concept of storage engine
- Kubernetes stateless application expansion and contraction capacity
- [depth first search] Ji Suan Ke: Betsy's trip
- Cadre du Paddle: aperçu du paddlelnp [bibliothèque de développement pour le traitement du langage naturel des rames volantes]
- 插卡4G工业路由器充电桩智能柜专网视频监控4G转以太网转WiFi有线网速测试 软硬件定制
猜你喜欢
![[technology development -28]: overview of information and communication network, new technology forms, high-quality development of information and communication industry](/img/94/05b2ff62a8a11340cc94c69645db73.png)
[technology development -28]: overview of information and communication network, new technology forms, high-quality development of information and communication industry
![[flask] official tutorial -part2: Blueprint - view, template, static file](/img/bd/a736d45d7154119e75428f227af202.png)
[flask] official tutorial -part2: Blueprint - view, template, static file

Extracting key information from TrueType font files

Campus second-hand transaction based on wechat applet
![Grabbing and sorting out external articles -- status bar [4]](/img/1e/2d44f36339ac796618cd571aca5556.png)
Grabbing and sorting out external articles -- status bar [4]

Leetcode skimming questions_ Sum of squares

A basic lintcode MySQL database problem

Initialize MySQL database when docker container starts

Card 4G industrial router charging pile intelligent cabinet private network video monitoring 4G to Ethernet to WiFi wired network speed test software and hardware customization

Force buckle 1020 Number of enclaves
随机推荐
Redis list
剑指 Offer 12. 矩阵中的路径
Grabbing and sorting out external articles -- status bar [4]
阿里测开面试题
leetcode3、實現 strStr()
竞赛题 2022-6-26
【Flask】静态文件与模板渲染
Leetcode3, implémenter strstr ()
Computer graduation design PHP part-time recruitment management system for College Students
Win10 add file extension
Leetcode sum of two numbers
LeetCode 322. Change exchange (dynamic planning)
Sword finger offer 12 Path in matrix
leetcode-2. Palindrome judgment
[technology development -28]: overview of information and communication network, new technology forms, high-quality development of information and communication industry
竞价推广流程
Shutter doctor: Xcode installation is incomplete
[width first search] Ji Suan Ke: Suan tou Jun goes home (BFS with conditions)
同一个 SqlSession 中执行两条一模一样的SQL语句查询得到的 total 数量不一样
3D vision - 4 Getting started with gesture recognition - using mediapipe includes single frame and real time video