Home > Article > Backend Development > How to input the grades of ten students in python
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)...".
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!