认真学习的Xue

导航

Python——if条件、while循环、for循环语句

(1)#if 语句 验证用户名和密码user = 'Zhaoxiaoxue'

password = '123456'
username = ''
passnumber = ''
while user != username or password != passnumber :
username = input("Please enter username: ")
passnumber = input("Please enter password: ")
if user == username and password == passnumber :
print('Welcome,%s!' % username)
break
else :
print("username or password is invalid!")

(2)#while、for循环
'''
#while 循环顺序输出0~99 验证break
count=0
while True:
print("count: ",count)
count+=1
if count==100:
break

'''

'''
#for循环 验证continue
for i in range(0,10):
if i<5 :
print('loop ',i)
elif i==5 :
print("loop :",i)
else :
continue
print("hello!")

'''
#嵌套for循环
for i in range(1,11) :
print ("*********",i)
for j in range(10) :
print (j)
if j==4 :
break

posted on 2019-07-13 17:38  认真学习的Xue  阅读(265)  评论(0编辑  收藏  举报