#dict
#Python内置了字典:dict的支持,dict全称dictionary,在其他语言中也称为map,使用键-值(key-value)存储,具有极快的查找速度。
d={‘Michael‘:95,‘Bob‘:75,‘Tracy‘:85}
print(‘dictgetMichael:‘,d[‘Michael‘])
#addaelement
d[‘Adam‘]=67
print(‘dictd‘,d)
#change..
分类:
编程语言 时间:
2017-08-02 13:58:00
阅读次数:
177
Alice and Bob play 5-in-a-row game. They have a playing field of size 10?×?10. In turns they put either crosses or noughts, one at a time. Alice puts ...
分类:
其他好文 时间:
2017-08-02 10:16:25
阅读次数:
134
#循环
#Python的循环有两种,一种是for...in循环,一种是while循环
#for...in循环
print(‘for...in循环‘)
print(‘#1依次把list或tuple中的每个元素迭代出来‘)
names=[‘Micheal‘,‘Bob‘,‘Tracy‘]
fornameinnames:
print(name)
print(‘#2计算1-10的整数之和‘)
s=0
forxin[1,2,3..
分类:
编程语言 时间:
2017-08-02 10:01:50
阅读次数:
171
#list
#Python内置的一种数据类型
classmates=[‘Michael‘,‘Bob‘,‘Tracy‘]
print("classmates",classmates)
print("getcountofthelist:",len(classmates))
print("classmates[0]:",classmates[0])
print("classmates[1]:",classmates[1])
print("classmates[2]:",classmates[2..
分类:
编程语言 时间:
2017-08-01 21:54:38
阅读次数:
168
#tuple
#tuple和list非常类似,但是tuple一旦初始化就不能修改
classmates=(‘Michael‘,‘Bob‘,‘Tracy‘)
print("classmates(tuple)",classmates)
#定义一个空的tuple
t=()
print("t(emptytuple)",t)
#定义一个只有1个元素的tuple,要加逗号
t=(1,)
#tuple在显示只有一个元素的..
分类:
编程语言 时间:
2017-08-01 21:44:34
阅读次数:
132
L = [('Bob', 75), ('Adam', 92), ('Bart', 66), ('Lisa', 88)] print(sorted(L,key=lambda i:i[0])) #按名字排序 print(sorted(L,key=lambda i:i[1])) #按成绩排序 .count ...
分类:
编程语言 时间:
2017-07-31 16:27:46
阅读次数:
124
You are fishing with polar bears Alice and Bob. While waiting for the fish to bite, the polar bears get bored. They come up with a game. First Alice a ...
分类:
其他好文 时间:
2017-07-30 23:56:12
阅读次数:
398
Help Bob Time Limit: 2 Seconds Memory Limit: 65536 KB There is a game very popular in ZJU at present, Bob didn't meant to participate in it. But he de ...
分类:
其他好文 时间:
2017-07-29 18:13:32
阅读次数:
88
题目描述: Bob和他的朋友从糖果包装里收集贴纸。Bob和他的朋友总共n人。共有m种不同的贴纸。每人手里都有一些(可能有重复的)贴纸,并且只跟别人交换他所没有的贴纸。贴纸总是一对一交换。Bob比这些朋友更聪明,因为他意识到只跟别人交换自己没有的贴纸并不总是最优的。在某些情况下,换来一张重复的贴纸更划 ...
分类:
其他好文 时间:
2017-07-29 18:12:17
阅读次数:
118
Cipher 时限:1000MS Description Bob and Alice started to use a brand-new encoding scheme. Surprisingly it is not a Public Key Cryptosystem, but their enc ...
分类:
其他好文 时间:
2017-07-26 22:11:36
阅读次数:
155