关于写作业发现的问题

1.有关random函数的使用的忘却

 

 具体的用法

 

然后又是喜闻乐见的输入多个数据

 

 进行深度解析一下

首先list函数的作用是建造一个列表
然后map

 

 spilt

 

 

 

 这样就完成了这个作业

 

 关于狐狸游戏

 

 

import random


print("狐狸在1,2,3,4,5中的一个洞里面!!!!")
n = int(input("你打算抓那个洞里面的狐狸:"))
i = 0
a = 0
i = random.randint(1,5)
while i!=n:
    a = random.randint(1,2)
    if a == 1 and i != 5:
        i+=1
    elif a == 2 and i != 0:
        i-=1
    else:
        continue
    if i == n:
        continue
    else:
        print(i)
        n = int(input("继续抓吧!"))
print('你抓到了!!!')

  

posted @ 2022-10-01 22:15  湖南陈冠希  阅读(28)  评论(0)    收藏  举报