hmao的日记

hmao的日记



20211113笔记

hmao · 2021年11月13日 05:21 pm · 0浏览 · 长文


第36课

1.random随机数库

import random
#while True:
r=random.randint(0,8568487509)
print(r)

2.程序休眠

import random
import time
while True:
    print(random.randint(0,2981329))
    time.sleep(0.1)

3.飞机大战实战模拟

import random
x=random.randint(0,480-57)
print('坐标为:'+str(x))

4.例子

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)+'次')

第37课

1.单词

weapon武器

2.回忆如何定义Hero对象

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)




thumb_up赞赏文章


comment 评论区

添加新评论





  • ©2025 bilibili.com

textsms
内容不能为空
account_circle
昵称不能为空
email
邮件地址格式错误
web
beach_access
验证码不能为空
keyboard发表评论


star_outline 咱快来抢个沙发吧!