- 博客(9)
- 收藏
- 关注
原创 penalty kick
from random import choiceprint 'choose one direction to shoot:'print 'left right center\n'you=raw_input()print 'you choosed '+youprintdirection=['left','right','center']keeper=choice(direction)
2017-07-22 19:47:50 252
原创 bingo using function
def ifequal(num1,num2): if num1>num2: print 'too small' return False; elif num1<num2: print 'too big' return False; else: print 'bingo' return True##########top is a function##########
2017-07-22 18:16:00 168
原创 bingo update1
from random import randintnum=randint(0,100)print 'guess the number please'bingo=Falsewhile bingo==False: ans=input() if ans<num: print '%d is too small'%ans if ans>num:
2017-07-21 16:45:29 186
原创 variable
#==== 变量命名规则 ====#变量名不是你想起就能起的:第一个字符必须是字母或者下划线“_”剩下的部分可以是字母、下划线“_”或数字(0-9)变量名称是对大小写敏感的,myname和myName不是同一个变量。几个有效的栗子: i __my_name name_23 a1b
2017-07-21 14:33:22 218
原创 python game1
num = 10 #get the numberprint 'Guess what I think?'answer = input() #input your answerwhile answer!=num: if answer print 'too small!' #if...
2017-07-21 10:38:45 160
原创 if
语法为: if 条件: 选择执行的语句特别说明:条件后面的冒号不能少,同样必须是英文字符。特别特别说明:if内部的语句需要有一个统一的缩进,一般用4个空格。python用这种方法替代了其他很多编程语言中的{}。你也可以选择1/2/3...个空格或者按一下tab键,但必须整个文件中都统一起来。千万不可以tab和空格混用,不然就会
2017-07-21 10:07:22 210
原创 bool
>:大于>=:大于等于==:等于。比较两个值是否相等。之所以用两个等号,是为了和变量赋值区分开来。!=:不等与not:逻辑“非”。如果x为True,则not x为Falseand:逻辑“与”。如果x为True,且y为True,则x and y为Trueor:逻辑“或”。如果x、y中至少有一个为True,则x or y为True
2017-07-21 09:57:07 208
原创 python1~5
没想到整一个博客这么难用,,,,print('string')print'string'print"string"print numprint computationprint compareinput()raw_input()
2017-07-21 09:51:43 284
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人