【33.0】常用语句

#coding=utf-8
# if 判断语句  注意冒号

#if else
# if elif  else
# if 嵌套

import random
player_input = input("请输入(0 剪刀,1石头,  2布):")
player =int(player_input)

computer = random.randint(0,2)
if((player == 0 and computer== 2) or (player == 1 and computer== 0)
        or (player == 2 and computer== 1)):
    print("你很厉害,电脑输了,电脑出拳%s"%computer)
elif(player == computer):
    print("你和电脑打平了电脑出拳%s"%computer)
else:
    print("你输了,电脑出拳%s"%computer)




#循环语句   while for



print(1),",",
print(2),",",
print(3)

i=1
while i< 10:
    j = 1
    while j <= i:
        print ("%d*%d=%-2d "%(i,j,i*j)),
        j+=1
    print("\n")
    i+=1



#break 结束整个循环体  跳出整个循环

#continue 语句   结束本次循环  执行下一次的循环


#break 和 continue 只能在循环中使用,不能单独使用,并且只对最近的一层起作用


#pass 是只对程序的结构保持完整,不起任何作用


#else 语句  除开能在if 中使用, 在while 和 for 中也可以使用,
# 一般 用在循环语句执行完成后  ,但是break 在跳出循环时 也要跳出这个else语句

 

posted @ 2019-02-22 17:16  科学小怪癖  阅读(96)  评论(0)    收藏  举报