20211113笔记

20211113笔记

hmao

20211113笔记

发布于:2021-11-13 17:21:09
别名:20211113笔记

第36课

1.random随机数库
[code]
import random
#while True:
r=random.randint(0,8568487509)
print(r)
[/code]

2.程序休眠
[code]
import random
import time
while True:
print(random.randint(0,2981329))
time.sleep(0.1)
[/code]

3.飞机大战实战模拟
[code]
import random
x=random.randint(0,480-57)
print(‘坐标为:’+str(x))
[/code]

4.例子
[code]
import random
import easygui
num=random.randint(0,100)
re=101
n=0
while guise !=num:
re=int(easygui.enterbox(“cai”))
if re>num:
easygui.msgbox(‘猜大了’)
if re<num:
easygui.msgbox(‘猜小了’)
n+=1
easygui.msgbox(‘duile’+str(n)+’次’)
[/code]

第37课

1.单词
[code]
weapon武器
[/code]

2.回忆如何定义Hero对象
[code]
class Hero():
def init(self,name,gender,weapon):
self.name=name
self.gender=gender
self.weapon=weapon

hero_list=[Hero('关羽','男','青龙~'),Hero('赵云','男','龙胆~'),Hero('吕布','男','方天~')]
print(hero_list[0].name,hero_list[0].gender,hero_list[0].weapon)
print(hero_list[1].name,hero_list[1].gender,hero_list[1].weapon)
print(hero_list[2].name,hero_list[2].gender,hero_list[2].weapon)

[/code]


暂无评论

  • 标题: 20211113笔记
  • 作者: hmao
  • 创建于 : 2021-11-13 17:21:09
  • 更新于 : 2026-08-19 14:26:00
  • 链接: https://blog.imce.cn/20211113-biji/
  • 版权声明: 本文章采用 CC BY-NC-SA 4.0 进行许可。
评论
目录
20211113笔记