码迷,mamicode.com
首页 > 编程语言 > 详细

python 流程判断

时间:2019-12-08 12:29:21      阅读:69      评论:0      收藏:0      [点我收藏+]

标签:while   word   use   port   continue   例子   mil   --   break   

import getpass
# print("hello word")

#
# name= ‘pangxiao‘
# mix_name=name
# print(mix_name,name)
# print(2**8)
# name= "pangxiao"
# age=26
# sex=""
# salary= 3000
#
# name=input("name:")
# age=input("age:")
# sex=input("sex:")
# salary=input("salary:")

# info = """
# ---------info of
# name: %s
# age: %s
# sex: %s
# salary: %s
#
# """ %(name,age,sex,salary)
# print(info)

# info2 = """
# ---------info2 of
# name: {_name}
# age: {_age}
# sex: {_sex}
# salary: {_salary}
#
# """ .format(_name=name,_age=age,_sex=sex,_salary=salary)
# print(info2)

# name3=input("name:")
# password3=getpass.getpass("password:")
# print(name3,password3)
# _name="pangxiao"
# _password="abc123"
# name3=input("name:")
# password3=input("password:")
# if _name == name3 and _password == password3:
# print("登录成功!{username}".format(username=name3))
# else:
# print("登录失败请重新登录!")
#自己写的小例子
dapangxiaozi = 26
count=5

while count:
guess_age = int(input("gusee_age:"))
if guess_age == dapangxiaozi:
print("猜对了")
break
elif guess_age > dapangxiaozi:
count -=1
print("猜高了,再小点!,还有{}次机会".format(count))
continue
else:
count -=1
print("猜小了,再大点!还有{}次机会".format(count))
continue

python 流程判断

标签:while   word   use   port   continue   例子   mil   --   break   

原文地址:https://www.cnblogs.com/fuyuteng/p/12005121.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!