赞
踩
# 打印编程词汇的含义
# 再添加5个python术语
from collections import OrderedDict
python_lists = OrderedDict()
python_lists['append'] = '将元素添加到列表末尾'
python_lists['insert'] = '可在列表的任何位置添加新元素'
python_lists['pop'] = '删除列表末尾的元素'
# 用循环遍历字典
for word, mean in python_lists.items():
print(word + ":" + mean)
from random import randint class Die(): def __init__(self, sides = 6): self.sides = sides def roll_die(self): """打印位于1和骰子面数之间的随机数""" x = randint(1, self.sides) print(x) six_die = Die() for number in range(1,11): six_die.roll_die() ten_die = Die(10) for number in range(1,11): ten_die.roll_die() twenty_die = Die(20) for number in range(1,11): twenty_die.roll_die()
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。