hmao
今天比昨天好,明天就有希望!
hmao的日记

20211113笔记

第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)

赞赏
20211113笔记》中出现的部分内容可能已经过时,您可以按需阅读。
除特殊声明本站均采用署名-相同方式共享 4.0 国际 (CC BY-SA 4.0)
切勿相信验证码内的任何广告

hmao

文章作者

发表回复

textsms
account_circle
email

CAPTCHAis initialing...

hmao的日记

20211113笔记
第36课 1.random随机数库 import random #while True: r=random.randint(0,8568487509) print(r) 2.程序休眠 import random import time while True: print(random.randi…
扫描二维码继续阅读
2021-11-13