Python-day01-task

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.