![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python练习
cs_mycsdn
慢慢整理所学的知识
展开
-
猜拳
from random import randint # 建立游戏库 gamelib=('石头','剪刀','布') print("1石头 2剪刀 3 布") opt=input("请选择具体项目:") opt=int(opt)-1 # 用户选择具体项目 optvalue=gamelib[opt%3] # 电脑随机选择 cpopt=randint(0,100) cpvalue=gamelib[c...原创 2018-05-04 16:53:46 · 153 阅读 · 0 评论 -
3局两胜猜拳
''' 老师: 我想要调用方法,或者只调用类的方式,没有写出来; 我想最终显示没想出来(应该可以通过调用输出方法来实现) 最终获胜者是: 比分为: 第一局: 第二局: ... ''' numc,nump,a=0,0,1 while numc<2 and nump<2: from random import randint # 创建数据库 data = ('石头'...原创 2018-05-07 20:12:26 · 1136 阅读 · 0 评论 -
100以内的素数
for i in range(2,101): for j in range(2,i+1): if i%j==0: break if j==i: print(i,end="\t")原创 2018-05-07 21:24:21 · 138 阅读 · 0 评论