Home >Backend Development >Python Tutorial >How to input the grades of ten students in python

How to input the grades of ten students in python

coldplay.xixi
coldplay.xixiOriginal
2020-10-21 14:51:4021357browse

How to input ten student scores in python: first create a py sample file; then use the function alist to list the ten scores, with code such as "[random.randint(45,101) for _ in range(10)] print(alist)...".

How to input the grades of ten students in python

The operating environment of this tutorial: windows7 system, python3.5 version, Dell G3 computer.

How to input ten student scores in python:

import random
alist = [random.randint(45,101) for _ in range(10)] #在[45.101)之间生成10个随机数
print(alist)
sum = 0
for i in alist:
    sum = sum + i
ave = sum / len(alist)
print(ave)

Related free learning recommendations: python video Tutorial

The above is the detailed content of How to input the grades of ten students in python. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn