博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
课堂练习 组合数据练习
阅读量:5890 次
发布时间:2019-06-19

本文共 3842 字,大约阅读时间需要 12 分钟。

成绩表增删改查遍历操作 classmate = list("123321123321")print(classmate)classmate.append('3')print(classmate[-1])classmate.pop()print(classmate[-1])classmate[-1] = 2print(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']312234>>>
建立学生学号成绩字典 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 : 4120 : 6430 : 7140 : 8150 : 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

你可能感兴趣的文章
jQuery EasyUI API 中文文档 - 组合(Combo)
查看>>
10个关于 Dropbox 的另类功用(知乎问答精编)[还是转来了]
查看>>
Oracle体系结构
查看>>
用Modelsim仿真QII FFT IP核的时候出现的Error: Illegal target for defparam
查看>>
javascript Error对象详解
查看>>
orm Lite的使用
查看>>
项目经理的职责(转载)
查看>>
安装rabbitmq
查看>>
Excel中 设置使得每行的颜色不一样
查看>>
JVM调优总结(四)-垃圾回收面临的问题
查看>>
nc 局域网聊天+文件传输(netcat)
查看>>
C++它 typedef void *HANDLE
查看>>
Git常用命令
查看>>
Linux下查看MySQL的安装路径
查看>>
C#获取磁盘列表与信息
查看>>
mysql学习笔记4---mysql 复制---源代码
查看>>
Linux设备驱动之semaphore机制【转】
查看>>
每天一个linux命令(25):linux文件属性详解
查看>>
【android】getDimension()、getDimensionPixelOffset()和getDimensionPixelSize()区别详解
查看>>
HDU 3280 Equal Sum Partitions(二分查找)
查看>>