Skip to content
Navigation Menu
Sign in
Products
Platform
GitHub
Repository hosting, code review, and collaboration
Copilot
AI coding agent for tasks, projects and automated work
Build & Ship
Actions
CI/CD and automation
Code Quality
Quality analysis, fixes, and enforcement
Codespaces
Cloud development environments
Secure
Code Security
Vulnerability detection and remediation
Secret Protection
Secret scanning and leak prevention
All Features
Developers
Learn
Documentation
Training
Certifications
Build
Build with Copilot
Customize Copilot
Integrations
Explore
Trending repos
GitHub Sponsors
Events
Changelog
Changelog
Your source for the latest features, improvements, and fixes across GitHub products, all in one place.
Businesses
By Stage
Enterprises
Team
Startups
Nonprofits
By Industry
Healthcare
Financial services
Manufacturing
Government
See all industries
Evaluate GitHub
Why GitHub
Customer Stories
Business insights
Trust Center
Add-ons
GitHub Advanced Security
Enterprise-grade code security
Copilot for business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Resources
Learn & Connect
Documentation
Resource center
Blog
Events & webinars
Community Forum
Customer Stories
Integrations
Support
Customer support
Training
GitHub Status
Company
About
Partners
Changelog
GitHub Universe
GitHub Universe
The event for developers, by developers — talks, workshops, and what’s next for GitHub.
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
KuroLight
algorithm
Repository navigation
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
More
items
Files
Expand file tree
master
Breadcrumbs
algorithm
/
2d_list.py
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
46 lines (35 loc) · 1.66 KB
master
Breadcrumbs
algorithm
/
2d_list.py
Copy path
Top
File metadata and controls
Code
Blame
46 lines (35 loc) · 1.66 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#! /usr/bin/env python
#coding:utf-8
"""
问题
定义一个20*5的二维数组,用来存储某班级20位学员的5门课的成绩;这5门课按存储顺序依次为:core C++,coreJava,Servlet,JSP和EJB。
(1)循环给二维数组的每一个元素赋0~100之间的随机整数。
(2)按照列表的方式输出这些学员的每门课程的成绩。
(3)要求编写程序求每个学员的总分,将其保留在另外一个一维数组中。
(4)要求编写程序求所有学员的某门课程的平均分。
"""
from __future__ import division
import random
def score(score_list,course_list,student_num):
course_num = len(course_list)
every_score = [[score_list[j][i] for j in range(course_num)] for i in range(student_num)]
every_total = [sum(every_score[i]) for i in range(student_num)]
ave_course = [sum(score_list[i])/len(score_list[i]) for i in range(len(score_list))]
return (every_score,every_total,ave_course)
if __name__=="__main__":
course_list = ["C++","Java","Servlet","JSP","EJB"]
student_num = 20
score_list = [[random.randint(0,100) for i in range(student_num)] for j in range(len(course_list))]
for i in range(len(course_list)):
print "score of every one in %s:"%course_list[i]
print score_list[i]
every_score,every_total,ave_one_course = score(score_list,course_list,student_num)
print "\n"
print "NEXT IS EVERY ONE SCORE IN EVERY COURSE:"
for name in course_list:
print name,
print "\t"
print every_score
print "\n"
print "every one all score:\t",every_total
print "every course of average score:\t",ave_one_course
You can’t perform that action at this time.