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
Release: 2021-04-14 11:38:12
Original
21356 people have browsed it

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)
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template