1.成绩可视化,输入成绩,绘制直方图

lis_score=[]
n=int(input("输入学生人数:"))
while n<1:
    print("学生人数需大于1")
    n = int(input("输入学生人数:"))
def check_score(score):
    if score >= 0 and score <= 100:
        return score
    else:
        print("分数未符合规范,请在1~100之间,确认后重新录入。!")
        score = int(input("输入分数:"))
        score = check_score(score)  
j = 3
num_list=[]
b=[]
while j > 0 :
    num = eval(input("输入学生学号(1,2,3,4...):"))
    num_list.append(num)
    i = n
    a = []
    while i > 0:
        score = check_score(int(input("输入该学生分数:")))
        a.append(score)
        i -= 1
    ave_score = (sum(a) / n)
    lis_score.append([num,round(ave_score,2),max(a),min(a)])
    j -= 1
    print('最高分{:.2f}分,最低分{:.2f}分,平均分{:.2f}分'.format(max(a),min(a),ave_score))
    print("总分{:.2f}分".format(sum(a)))
    b.append(a)
print(lis_score)
print(b)
import csv
list=lis_score
f = open('成绩表.csv','w',newline='')
writer = csv.writer(f)
for i in list:
    writer.writerow(i)
f.close()
import matplotlib.pyplot as plt
plt.rcParams['font.family'] = ['SimHei']
plt.title("成绩分布柱状图")
for i in range(num): 
    x=[num_list[i]]
    height=[lis_score[i][1]]
    plt.bar(x,height) 
plt.xlabel("学生学号——平均分")#设置x轴标签
plt.ylabel("成绩分数段")#设置y轴标签
plt.xlim(0,10)#设置x轴区间
plt.xticks(range(1,10))#设置x轴刻度
plt.yticks([0,10,20,30,40,50,60,70,80,90,100]) #设置y轴刻度
plt.grid()
plt.show()
for i in range(num): 
    x=[num_list[i]]
    height=[lis_score[i][2]]
    plt.bar(x,height) 
plt.xlabel("学生学号——最高分")#设置x轴标签
plt.ylabel("成绩分数段")#设置y轴标签
plt.xlim(0,10)#设置x轴区间
plt.xticks(range(1,10))#设置x轴刻度
plt.yticks([0,10,20,30,40,50,60,70,80,90,100]) #设置y轴刻度
plt.grid()
plt.show()
for i in range(num): 
    x=[num_list[i]]
    height=[lis_score[i][3]]
    plt.bar(x,height) 
plt.xlabel("学生学号——最低分")#设置x轴标签
plt.ylabel("成绩分数段")#设置y轴标签
plt.xlim(0,10)#设置x轴区间
plt.xticks(range(1,10))#设置x轴刻度
plt.yticks([0,10,20,30,40,50,60,70,80,90,100]) #设置y轴刻度
plt.grid()
plt.show()
for i in range(num): 
    x=[num_list[i]]
    height=[b[i][0]]
    plt.bar(x,height) 
plt.xlabel("学生学号——高数")#设置x轴标签
plt.ylabel("成绩分数段")#设置y轴标签
plt.xlim(0,10)#设置x轴区间
plt.xticks(range(1,10))#设置x轴刻度
plt.yticks([0,10,20,30,40,50,60,70,80,90,100]) #设置y轴刻度
plt.grid()
plt.show()
for i in range(num): 
    x=[num_list[i]]
    height=[b[i][1]]
    plt.bar(x,height) 
plt.xlabel("学生学号——物理")#设置x轴标签
plt.ylabel("成绩分数段")#设置y轴标签
plt.xlim(0,10)#设置x轴区间
plt.xticks(range(1,10))#设置x轴刻度
plt.yticks([0,10,20,30,40,50,60,70,80,90,100]) #设置y轴刻度
plt.grid()
plt.show()
for i in range(num): 
    x=[num_list[i]]
    height=[b[i][2]]
    plt.bar(x,height) 
plt.xlabel("学生学号——英语")#设置x轴标签
plt.ylabel("成绩分数段")#设置y轴标签
plt.xlim(0,10)#设置x轴区间
plt.xticks(range(1,10))#设置x轴刻度
plt.yticks([0,10,20,30,40,50,60,70,80,90,100]) #设置y轴刻度
plt.grid()
plt.show()

----------------------------------------分割线--------------------------------------------------------------------------------

2.输入选手,评委,分数,统计得分,绘制直方图

import matplotlib.pyplot as plt
lis_score=[]
n=int(input("输入评委人数:"))
while n<5:
    print("评委人数需大于5")
    n = int(input("输入评委人数:"))
    
player = int(input("参赛人数:"))
while player < 1:
    print("参赛人数需大于2")
    player = int(input("参赛人数:"))
    
def check_score(score):
    if score >= 0 and score <= 100:
        return score
    else:
        print("分数未符合规范,请在1~100之间,确认后重新录入。!")
        score = int(input("输入分数:"))
        score = check_score(score)

j = player
num_list=[]
while j > 0 :
    num = eval(input("输入选手序号:"))
    num_list.append(num)
    i = n
    a = []
    while i > 0:
        score = check_score(int(input("输入该选手分数:")))
        a.append(score)
        i -= 1
    final_score = (sum(a) - min(a) - max(a)) / (n-2)
    lis_score.append([num,final_score])
    j -= 1
    print('去掉一个最高分{:.2f}分,去掉一个最低分{:.2f}分'.format(max(a),min(a)))
for i in range(player):
    print("选手序号:",num_list[i])
    print('选手最后得分是:{:.2f}分'.format(lis_score[i][1]))

plt.rcParams['font.family'] = ['SimHei']
plt.title("决赛成绩分布柱状图")
for i in range(num): 
    x=[num_list[i]]
    height=[lis_score[i][1]]
    plt.bar(x,height) 
plt.xlabel("选手序号")#设置x轴标签
plt.ylabel("成绩分数段")#设置y轴标签
plt.xlim(0,10)#设置x轴区间
plt.xticks(range(1,10))#设置x轴刻度
plt.yticks([0,10,20,30,40,50,60,70,80,90,100]) #设置y轴刻度
plt.grid()
plt.show()

-----------------------------------------------------分割线-------------------------------------------------------------------

turtle绘图

import turtle as t
t.speed("fast")

#小人

t.pensize(10)
t.pu()
t.rt(180)
t.fd(500)
t.rt(180)
t.pd()

t.circle(50)
t.rt(90)
t.fd(100)
t.rt(55)
t.fd(55)
t.up
t.rt(180)
t.fd(55)
t.rt(35)
t.fd(45)
t.rt(45)
t.fd(50)
t.rt(180)
t.fd(50)
t.lt(45)
t.fd(45)
t.rt(90)
t.fd(50)
t.rt(90)
t.fd(75)
t.lt(45)
t.fd(45)
t.rt(180)
t.fd(45)
t.lt(90)
t.fd(45)
t.lt(45)
t.pu()
t.fd(75)
t.lt(45)
t.fd(24)
t.pd()

#星1
t.pensize(1)
t.color('yellow', 'yellow')
t.begin_fill()
for i in range(5):
    t.fd(100)
    t.rt(144)
t.end_fill()
t.pu()
t.rt(45)
t.fd(200)
t.pd()
t.pensize(1)

#国旗

t.color('red', 'red')
t.begin_fill()
t.fd(750)
t.lt(90)
t.fd(450)
t.lt(90)
t.fd(750)
t.lt(90)
t.fd(450)
t.end_fill()
 
t.pu()
t.lt(180)
t.fd(200)
t.rt(90)
t.fd(35)
t.pd()

#星2

t.color('yellow', 'yellow')
t.begin_fill()
for i in range(5):
    t.fd(35)
    t.rt(144)
t.end_fill()

t.penup()
t.goto(10, 100)
t.pendown()
t.seth(0)
t.left(21)
t.penup()
t.goto(10, 163)
t.pendown()

#星3

t.color('yellow', 'yellow')
t.begin_fill()
for i in range(5):
    t.fd(35)
    t.rt(144)
t.end_fill()
t.penup()
t.goto(275, 115)
t.pendown()
t.seth(0)
t.right(25)
t.penup()
t.goto(75, 250)
t.pendown()

#星4

t.color('yellow', 'yellow')
t.begin_fill()
for i in range(5):
    t.fd(35)
    t.rt(144)
t.end_fill()
t.penup()
t.goto(275, 115)
t.pendown()
t.seth(0)
t.right(25)
t.penup()
t.goto(75, 250)
t.pendown()

#星5

t.color('yellow', 'yellow')
t.penup()
t.goto(275, 115)
t.pendown()
t.seth(0)
t.left(21)
t.penup()
t.goto(35, 300)
t.fd(75)
t.pendown()
t.begin_fill()
for i in range(5):
    t.fd(35)
    t.rt(144)
t.end_fill()

t.penup()
t.goto(-275, 115)
t.pendown()
t.seth(0)
t.right(21)
t.penup()
t.goto(-147, 93)
t.pendown()

#爱心
t.pu()
t.goto(-250,30)
t.pd()
t.setheading(0)
def curvemove():
    for i in range(200):
        t.right(1)
        t.forward(1)
t.color('red','pink')        
t.begin_fill()
t.left(140)
t.forward(111.65)
curvemove()
t.left(120)
curvemove()
t.forward(111.65)
t.end_fill()
t.penup()
t.goto(-250,95)
love=("我爱你\n  中国")
t.color('white')
t.write(love, font=('STCaiyun', 25,), align="center")
t.hideturtle()
t.done()
————————————————
版权声明:本文为CSDN博主「weixin_51446993」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:

https://blog.csdn.net/weixin_51446993/article/details/118467147

python绘制直方图(成绩可视化),turtle绘图相关推荐

  1. python画直方图代码-Python绘制直方图及子图的方法分析(代码示例)

    本篇文章给大家带来的内容是关于Python绘制直方图及子图的方法分析(代码示例),有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助. 1.直方图的绘制也需要用到matplotlib下的py ...

  2. 2021-04-29 Python绘制柱状图之可视化神器Pyecharts

    Python绘制柱状图之可视化神器Pyecharts 昨晚写了关于Matplotlib的可视化,今天推荐一个可视化的利器-pyecharts. 前文链接:Python可视化图表生成-Matplotli ...

  3. python画直方图成绩分析-使用Python绘制直方图和正态分布曲线

    本文主要介绍两个内容: 如何使用记事本生成包含某一数据集的CSV文件: 如何使用Python绘制给定数据集的直方图和正态分布曲线. 1. 使用记事本创建CSV文件 ① 新建一个文本文件,打开后输入数据 ...

  4. python画直方图成绩分析-python plotly绘制直方图实例详解

    计算数值出现的次数 import cufflinks as cf cf.go_offline() import numpy as np import pandas as pd set_slippage ...

  5. python画直方图成绩分析-Python数据分析:直方图及子图的绘制

    1.直方图的绘制也需要用到matplotlib下的pylab,只不过在绘制折线图时我们采用的是plot(),而绘制直方图时我们需要采用hist().由于在绘制过程中缺少真实数据,我在这里采用np.ra ...

  6. Python绘制直方图案例一则

    参考代码: 运行结果: ---------董付国老师Python系列教材-------- 1)<Python程序设计(第2版)>(2018年7月第7次印刷) 2)<Python可以这 ...

  7. python绘制直方图显示数字_Python实现绘制双柱状图并显示数值功能示例

    本文实例讲述了Python实现绘制双柱状图并显示数值功能.分享给大家供大家参考,具体如下: # -*- coding:utf-8 -*- #! python3 import matplotlib.py ...

  8. python画直方图成绩分析-使用Python进行描述性统计

    2 使用NumPy和SciPy进行数值分析 2.1 基本概念 1 from numpy importarray2 from numpy.random importnormal, randint3 #使 ...

  9. Python代码画小猪佩奇--turtle绘图

    Python代码小猪佩奇–turtle绘图 效果图 代码 import time import turtle as tt.pensize(4) # 设置画笔的大小 t.colormode(255) # ...

最新文章

  1. 数学建模——评卷问题
  2. 计算机与采集卡无法通信,通信工程毕业设计(论文)-基于.NET平台的高速图像采集.doc...
  3. IDEA查看Java源码
  4. solaris 常用软件安装
  5. 微服务宏观把控与深入剖析
  6. P4899-[IOI2018]werewolf 狼人【Kruskal重构树,主席树】
  7. docker中centos遇到sudo: command not found
  8. 用Python抓取网页并解析
  9. 内核编译报错Fedora20(友善)
  10. linux 禁 ip 分片,Linux iptables 设置允许(禁止)IP范围
  11. 海力士固态测试软件,【海力士 256G MSATA固态硬盘使用总结】性能|接口|数据|品牌_摘要频道_什么值得买...
  12. php日历排班表,如何用Word制作超精美的日历、值班表、计划表?
  13. Photoneo Montion L3D相机安装和注意事项
  14. 十年老码农,现场教你写简历!
  15. 车牌识别 php,智能车牌识别系统
  16. Zebras CodeForces - 950C(思维)
  17. 连接本地数据库,mysql提示Can‘t connect to MySQL server on localhost (10061)解决办法
  18. SpringBoot mybatis多数据源配置,记录下我磕磕碰碰的三个月找工作经历
  19. 【Html——浪漫花瓣特效(效果+代码)】
  20. Windows Presentation Foundation 用户指南

热门文章

  1. 什么是进程?什么是线程?什么是协程?
  2. 销售管理系统软件免费版(超实用销售管理系统)
  3. 华为荣耀6计算机,华为荣耀6怎么开启和打开usb调试模式
  4. python opencv numpy旋转图片
  5. 本地计算机上的服务启动后停止。某些服务在未由其他服务或程序使用时将自动停止。
  6. pythonpath windows_如何添加在Windows 7中的PYTHONPATH
  7. 集显笔记本可不可以学计算机,说买电脑是为了学习,可你的笔记本选对了吗?...
  8. 老生常谈:中文输出出现乱码问号的问题
  9. mysql 日语拼音排序,如何在日语版的MySQL中设置架构排序规则
  10. 2023年全国职业院校技能大赛-应用软件系统开发赛项(高职组)赛题第9套