Python Basic Knowledge II

Source: Internet
Author: User

One: Formatted output
Existing practice needs, ask the user's name, age, work, hobbies, and then print into the following format
------------info of Alex Li------
Name : Alex Li
Age : 22
Job : Teacher
Hobbie:girl
-------------End-----------------

The first method:
Name = input ('Please enter your name:') Age= Int (Input ('Please enter your age:')) Job= Input ('Please enter your work:') Hobby= Input ('Please enter your hobby:') Info=" "------------Info of%s------Name:%sage:%djob:%shobbie:%s-------------end------------" "%(Name,name,age,job,hobby)Print(info)

The second method:

Name = input ('Please enter your name:') Age= Int (Input ('Please enter your age:')) Job= Input ('Please enter your work:') Hobby= Input ('Please enter your hobby:') Info=" "------------Info of% (name) s------Name:% (name) SAge:% (age) Djob:% (Job) Shobbie:% (Hobby) s-------------End- ----------------" "%{'name': Name,' Age': Age,'Job': Job,'Hobby': Hobby}Print(info)

Two while Else

User login (after three times choose whether to continue to try)

i = 1 whileI < 4: Username= Input ('Please enter your name:') Password= Input ('Please enter your password:')    ifUsername = ='ABC'  andPassword = ='ECD':        Print('Welcome')         Break    Else:        Print('Please re-enter') I+ = 1ifi = = 4: Answer= Input ('do you want to try it again?/y')            ifAnswer = ='Y': I= 1Else:    Print('Roll Duzi')

Three: Logical operators

+ = = equals

-Minus! = does not equal

* Multiply <> Not equal

/except > less than

Quotient < less than

% residual >= greater than or equal to

* * Power <= less than or equal to

Four: Not,or,and five: The history of the encoding Six: in, not in usage VII: Job

Python Basic Knowledge II

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.