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

Python循环

时间:2016-10-14 07:27:59      阅读:155      评论:0      收藏:0      [点我收藏+]

标签:

密码密文 passwd.py

 

import getpass

_username=‘sunny‘

password=‘000000‘

username=input("username:")

password=getpass.getpass("password:")

 

if  _username == username and _password == password :

  print("Welcome to {name} login...".format(name=username))

else :

  print("Invalid username or password")

 

guess.py

 

age = 56

count = 0

while count<4:

 

  guess_age = int(input("guess age:"))

  if guess_age == age:

    print("Congratulations !")

    break

  elif guess_age>age:

    print("ops ...")

  else:

    print("devops...")

  count +=1

  if count == 3:

    continue_flag =input("do you want to keep...")

    if continue_flag != ‘n‘

      count = 0

else:

  print("......")

 

while.py

 

count = 0

while True:

  print("count:",count)

  count +=1

 

exce1.py

for i in range(10):

/* range(0,10,2)

0~10,步长为2

*/

  print("loop:",i)

  for j in range(10):

    print(j)  

    if j>5:

      break

 

Python循环

标签:

原文地址:http://www.cnblogs.com/isunny/p/5958839.html

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