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