成绩表增删改查遍历操作classmate = list("123321123321")
print(classmate)classmate.append('3')
print(classmate[-1])classmate.pop()
print(classmate[-1])classmate[-1] = 2
print(classmate[-1])print(classmate.index('3'))
print(classmate.count('1'))
print(classmate.count('3'))

================ RESTART: C:/Users/Administrator/Desktop/1.py ================
['1', '2', '3', '3', '2', '1', '1', '2', '3', '3', '2', '1']
3
1
2
2
3
4
>>> 

建立学生学号成绩字典

score = {10:'41',20:'64',30:'71',40:'81',50:'91'}
print(score)
score[6] = '90'
print(score)
score.pop(6)
print(score)for i in score:print("{:>2} : {:<2}".format(i,score.get(i)))

================ RESTART: C:/Users/Administrator/Desktop/1.py ================
{10: '41', 20: '64', 30: '71', 40: '81', 50: '91'}
{10: '41', 20: '64', 30: '71', 40: '81', 50: '91', 6: '90'}
{10: '41', 20: '64', 30: '71', 40: '81', 50: '91'}
10 : 41
20 : 64
30 : 71
40 : 81
50 : 91
>>>

列表,元组,字典,集合。ls=list("4613125646")
tu=tuple("4613125646")
se=set("4613125646")
d={'阿一':93,'阿二':74,'阿三':45,'阿四':66}
print("列表:",ls)
for i in ls:print(i,end=' ')
print("\n")
print("元组:",tu)
for i in tu:print(i,end=' ')
print("\n")
print("集合:",se)
for i in se:print(i,end=' ')
print("\n")
print("字典:",d)
for i in d:print(i,end='\t')print(d[i],end='\n')

================ RESTART: C:/Users/Administrator/Desktop/1.py ================
列表: ['4', '6', '1', '3', '1', '2', '5', '6', '4', '6']
4 6 1 3 1 2 5 6 4 6 元组: ('4', '6', '1', '3', '1', '2', '5', '6', '4', '6')
4 6 1 3 1 2 5 6 4 6 集合: {'4', '2', '6', '3', '5', '1'}
4 2 6 3 5 1 字典: {'阿一': 93, '阿二': 74, '阿三': 45, '阿四': 66}
阿一  93
阿二  74
阿三  45
阿四  66

歌词统计 song = '''Vincent,Don McLean. Starry starry night paint your palette blue and grey look out on a summer\'s day with eyes that know the darkness in my soul. Shadows on the hills sketch the trees and the daffodils catch the breeze and the winter chills in colors on the snowy linen land. And now I understand what you tried to say to me and how you suffered for your sanity and how you tried to set them free. They would not listen they did not know how perhaps they\'ll listen now. Starry starry night flaming flowers that brightly blaze swirling clouds in violet haze reflect in Vincent\'s eyes of China blue. Colors changing hue morning fields of amber grain weathered faces lined in pain are smoothed beneath the artist\'s loving hand. And now I understand what you tried to say to me and how you suffered for your sanity and how you tried to set them free. They would not listen they did not know how perhaps they\'ll listen now. For they could not love you but still your love was true and when no hope was left in sight on that starry starry night. You took your life as lovers often do, But I could have told you Vincent this world was never meant for one as beautiful as you. Starry starry night portraits hung in empty halls frameless heads on nameless walls with eyes that watch the world and can\'t forget. Like the stranger that you\'ve met the ragged men in ragged clothes the silver thorn of bloddy rose lie crushed and broken on the virgin snow. And now I think I know what you tried to say to me and how you suffered for your sanity and how you tried to set them free. They would not listen they\'re not listening still perhaps they never will.'''song = song.lower()
for i in '?!,.\'\n':song = song.replace(i,' ')
words = song.split(' ')dic={}
keys = set(words)
for i in keys:dic[i]=words.count(i)c = list(dic.items())
c.sort(key=lambda x:x[1],reverse=True)for i in range(10):print(c[i])

================ RESTART: C:/Users/Administrator/Desktop/1.py ================
('', 112)
('and', 15)
('you', 14)
('the', 13)
('they', 10)
('to', 9)
('starry', 8)
('how', 8)
('in', 8)
('not', 7)
>>>

  

  

  

  

  

  

  

转载于:https://www.cnblogs.com/55lsk/p/7567232.html

课堂练习 组合数据练习相关推荐

  1. 组合数据浅析之“幻方”

    组合数据又称离散数学,个人理解,就相当于对一些数据的排序问题,随着计算机的日益发展,大数据问题就会凸显而出,这样就会需要组合数据的思维方式设计程序,从而使系统运行快速. 今天主要理解一下"幻 ...

  2. Python组合数据

    大家好,一晃眼,一天又过去了.粉丝也多了几位,非常感谢你们.尤其感谢QQ名为irid****ent的朋友对我技术的信任,从而来询问我的问题.望大家多多提问,喜欢的点个赞.加个关注! (好了,又在凑字数 ...

  3. 沉吟放拨插弦中,整顿衣裳起敛容——python组合数据

    沉吟放拨插弦中,整顿衣裳起敛容. 自言本是京城女,家在虾蟆陵下住. 十三学得琵琶成,名属教坊第一部. 曲罢曾教善才服,妆成每被秋娘妒. 五陵年少争缠头,一曲红绡不知数. 钿头银篦击节碎,血色罗裙翻酒污 ...

  4. 五行各500字,2位字符串组合,数据量大而采取分段输出表格形式方程式

    /*文字组合情况分析:缺1时取五行相生按顺序及自组合:缺>=2时按结果的前后,最多缺不会5:皆取2字名采用大名和小名并用.*/ void 五行名字(){ /*文字组合情况分析:缺1时取五行相生按 ...

  5. 第九章 使用结构体类型处理组合数据——用户自定义数据类型

    9.1 定义和使用结构体变量 例9.1 把一个学生的信息放在一个结构体变量中,然后输出这个学生的信息. 程序代码如下: #include <stdio.h> int main() {str ...

  6. C语言程序设计 使用结构体类型处理组合数据——用户自定义数据类型

    1 定义和使用结构体变量 1.1 自定义建立结构体类型 好处:反映出成员之间的内在联系. 在程序中建立所需要结构体类型.例如: 指定了一个新的结构体类型struct student. struct是声 ...

  7. 用C++求出组合个数and具体的组合数据

    文章目录 关于题目 `可是有没有想过要是这样那如何得出组合的具体数据呢?` 关于解题 关于代码 关于题目 题目描述:取n个数组成为数组,从其中取m个数字组成一个组合,共有多少个这样的组合,并把具体的组 ...

  8. python之组合数据

    一.list列表 定义: 列表是组合数据类型中的一种,可以按照有顺序的方式.存储不同数据类型的,可以重复的多个数据. 操作方式: 1.声明列表 2.列表(数据容器)可以执行增删改查操作 声明列表 py ...

  9. 【Python】局部变量和全局变量以及组合数据(列表)类型

    局部变量和全局变量是不同的变量 局部变量是函数内部的占位符,与全局变量可能重名但不同.函数运算结束后,局部变量就会被释放,它只是用于函数内部运算,可以用global保留字在函数内部使用全局变量 n,s ...

最新文章

  1. Unhandled exception 0xC0000005: Access violation writing location
  2. 去哪面试都会问的HashMap
  3. JAVA调用shell脚本实例
  4. 获取当日零点 PHP
  5. uboot命令及内核启动参数
  6. CMarkup类简介
  7. 升级tomcat遇到的坑
  8. 软件设计师考试详细介绍(最全)
  9. Linux补全命令分析,实现Linux下上下键和命令补全
  10. ENVI实现带DN值保存为TIFF格式
  11. Sematic UI框架的学习-button样式(2)
  12. 系统架构师从入门到精通1.0 Ceph集群部署无报错流畅版本
  13. Mysql语句(二)
  14. C/C++ Linux 后台服务器开发高级架构师学习知识路线总结
  15. 英语日常短语积累(1)
  16. 古有陈天华万字血书抗沙俄,今有本剧蒻万字背包虐dp(01,完全,多重,分组,混合等各种背包详解 + 板子题+ 奇奇怪怪滴变式题)
  17. 区块链-拜占庭将军问题介绍
  18. 80秒验证13亿个身份证号码,包含省市县验证
  19. 技术人员如何写好一封邮件
  20. 学硬件好还是软件好?软件和硬件哪个更吃香?

热门文章

  1. .NET中方法的注意事项 明细
  2. sql server 2000的数据库还原
  3. 挣脱浏览器的束缚(5) - 哭笑不得的IE Bug
  4. JAVA锁之公平锁和非公平锁
  5. windows下,linux下elasticsearch安装插件head插件的步骤
  6. Linux下安装MySQL数据库、禅道
  7. python 获取点击按钮名称_python如何获取tkinter组件的名称?比如按下多个Button中的一个,返回这个被按下的Button的text?...
  8. es6添加删除class_es6-class的基本用法
  9. 未能加载文件或程序集_完美解决未能正确加载Visual C++资源编辑器包问题
  10. arial unicode ms字体_适合海报设计的最佳字体