Python 练习实例71

简介: Python 练习实例71

题目:编写input()和output()函数输入,输出5个学生的数据记录。

程序分析:无。

程序源代码:

实例

#!/usr/bin/python# -*- coding: UTF-8 -*- N = 3#stu# num : string# name : string# score[4]: liststudent = []for i in range(5):     student.append(['','',[]]) def input_stu(stu):     for i in range(N):         stu[i][0] = raw_input('input student num:\n')        stu[i][1] = raw_input('input student name:\n')        for j in range(3):             stu[i][2].append(int(raw_input('score:\n'))) def output_stu(stu):     for i in range(N):         print '%-6s%-10s' % ( stu[i][0],stu[i][1] )        for j in range(3):             print '%-8d' % stu[i][2][j] if __name__ == '__main__':     input_stu(student)    print student    output_stu(student)

以上实例输出结果为:

input student num:

2

input student name:

aaa

score:

89

score:

98

score:

67

input student num:

bbb

input student name:

ccc

score:

87

score:

45

score:

68

input student num:

ddd

input student name:

eee

score:

56

score:

78

score:

56

[['2', 'aaa', [89, 98, 67]], ['bbb', 'ccc', [87, 45, 68]], ['ddd', 'eee', [56, 78, 56]], ['', '', []], ['', '', []]]

2     aaa      

89      

98      

67      

bbb   ccc      

87      

45      

68      

ddd   eee      

56      

78      

56    

相关文章
|
1月前
|
前端开发 搜索推荐 编译器
【01】python开发之实例开发讲解-如何获取影视网站中经过保护后的视频-用python如何下载无法下载的视频资源含m3u8-python插件之dlp-举例几种-详解优雅草央千澈
【01】python开发之实例开发讲解-如何获取影视网站中经过保护后的视频-用python如何下载无法下载的视频资源含m3u8-python插件之dlp-举例几种-详解优雅草央千澈
111 34
【01】python开发之实例开发讲解-如何获取影视网站中经过保护后的视频-用python如何下载无法下载的视频资源含m3u8-python插件之dlp-举例几种-详解优雅草央千澈
|
1月前
|
人工智能 编译器 Python
python已经安装有其他用途如何用hbuilerx配置环境-附带实例demo-python开发入门之hbuilderx编译器如何配置python环境—hbuilderx配置python环境优雅草央千澈
python已经安装有其他用途如何用hbuilerx配置环境-附带实例demo-python开发入门之hbuilderx编译器如何配置python环境—hbuilderx配置python环境优雅草央千澈
41 0
python已经安装有其他用途如何用hbuilerx配置环境-附带实例demo-python开发入门之hbuilderx编译器如何配置python环境—hbuilderx配置python环境优雅草央千澈
|
2月前
|
数据挖掘 vr&ar C++
让UE自动运行Python脚本:实现与实例解析
本文介绍如何配置Unreal Engine(UE)以自动运行Python脚本,提高开发效率。通过安装Python、配置UE环境及使用第三方插件,实现Python与UE的集成。结合蓝图和C++示例,展示自动化任务处理、关卡生成及数据分析等应用场景。
178 5
|
3月前
|
测试技术 API 数据安全/隐私保护
Python连接到Jira实例、登录、查询、修改和创建bug
通过使用Python和Jira的REST API,可以方便地连接到Jira实例并进行各种操作,包括查询、修改和创建Bug。`jira`库提供了简洁的接口,使得这些操作变得简单易行。无论是自动化测试还是开发工作流的集成,这些方法都可以极大地提高效率和准确性。希望通过本文的介绍,您能够更好地理解和应用这些技术。
361 0
|
4月前
|
Python
Python中的push方法详解与实例
Python中的push方法详解与实例
57 3
|
4月前
|
数据可视化 Python
Python绘制基频曲线——实例解析与应用探讨
Python绘制基频曲线——实例解析与应用探讨
37 0
|
4月前
|
Python 容器
AutoDL Python实现 自动续签 防止实例过期释放 小脚本 定时任务 apscheduler requests
AutoDL Python实现 自动续签 防止实例过期释放 小脚本 定时任务 apscheduler requests
82 0
|
4月前
|
数据处理 Python
Python内置时间模块:Datetime实例详解(一)
Python内置时间模块:Datetime实例详解(一)
55 1
|
4月前
|
Python
Python内置时间模块:Datetime实例详解(二)
Python内置时间模块:Datetime实例详解(二)
100 0
|
4月前
|
Python
Python 练习实例100
Python 练习实例100

热门文章

最新文章

推荐镜像

更多