DAY01 homework After class
1. Job Requirements
Writing the Login interface
-Enter user name password
-Show welcome message after successful authentication
-Exit three times after the error has been lost
2. Flowchart
3. Procedure
#!/usr/bin/Envpythonf= Open ("foo.txt") #打开用户密码文件 Line=f.readline () #读取用户名line1=f.readline () #读取密码f.close () #关闭文件i=1 whileI <=3: Input_name= Raw_input ("Please input your name:") input_passwd= Raw_input ("Please input your passwd:") ifInput_name = = line[:-1]: The role of #[:-1] is to remove the line break ifINPUT_PASSWD = = line1[:-1]: Print"wecome to Linux world,login successfully!" BreakElse: Print"You input the passwd is wrong" Else: Print"You input the name is wrong"I+=1Else: Print"haved try 3 times,no time to try today!!! "
Cat foo.txt Ruizhong.li passwd
4. Practice procedure in class (to be optimized)
#!/usr/bin/Envpython#_*_ coding:utf-8_*_ #添加此行后, you can lose Chinese print_num= Input ('which loop do I want it to is printed out?') Count=0 whileCount <10000000: ifCount = =Print_num:print'there you got the number:', Count Choice= Raw_input ('does want to continue the loop? (y/n)') ifChoice = ='N': BreakElse: whilePrint_num <=Count:print_num= Input ('which loop do I want it to is printed out?') ifPrint_num >Count:breakElse: Print u'It's over, sx!.' Else: Print'Loop:', Count Count+=1Else: Print'Loop:', Count
Python-day01-task