Getting Started with Python (the next day)

Formatted output

An existing practice needs to ask the user's name, age, job, hobbies, and then printed in the following format

------------ info of Taibaijinxing ----------- 
the Name: Taibaijinxing 
Age: 22 is 
Job: Teacher 
Hobbie: Girl
 ---------- --- end -----------------

So how to achieve it? According to our previous knowledge, this effect can not be achieved, so let's learn about the new posture it
just make you want to print format ready first, due to some inside information that require user input, you can not preset know, so you can place the first placeholder, then the string in the placeholder and external variables to be a mapping between Jiuhaola

INPUT = name ( " the Name: " ) 
Age = INPUT ( " Age: " ) 
Job = INPUT ( " the Job: " ) 
Hobbie = INPUT ( " Hobbie: " ) 

info = '' ' 
--------- --- info of% s ----------- #% s herein each is a placeholder for the back of the extension number of the Bank's name 
the name:% s # Representative name 
Age: % s # on behalf of Age   
the Job:% s # on behalf of the Job 
Hobbie:% s # represents the Hobbie 
------------- ----------------- End 
'' ' % (name, name, Age, Job,Hobbie) # % is the line number associated with the extension number of the back of the string variable up front 

Print (info)

% s placeholder character string, can place any content, including digital. In addition, there is a number placeholders% d, if the back of the age above replaced% d, on behalf of your friends must only enter numbers
there if you just want to output%, it can be %% similar in linux in the escape character \
If the string with a placeholder, then the back of all% are occupying, we need to escape

Basic operators

Operators
have a computer operation that can be performed are many, can not only simple addition, subtraction, operations can be divided according to the type of arithmetic operations, more budget, logical operators, assignment operators, members of the operation, etc.
arithmetic:
the following assumptions variables: a = 10, b = 20 comparison operation following assumptions variables: a = 10, b = 20 assignment operator following assumptions variables: a = 10, b = 20 logical operation PS: 1, a logic operation not in the absence () of high priority in and, and a higher priority than or, i.e. priority ()> not> and> or , from left to right at the same priority calculated column title: Analyzing the following logic statements True, False











1,3>4 or 4<3 and 1==1
2,1 < 2 and 3 < 4 or 1>2 
3,2 > 1 and 3 < 4 or 4 > 5 and 2 < 1
4,1 > 2 and 3 < 4 or 4 > 5 and 2 > 1 or 9 < 8
5,1 > 1 and 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6
6,not 2 > 1 and 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6

2、x or y,x为真,值就是x,x为假,值是y
x or y 如果x==0,那么就是y,否则是x

x and y,x为真,值是y,x为假,值是x。
x and y 如果x==0,那么就是x,否则是y
列题:求出下列逻辑语句的值


Guess you like

Origin www.cnblogs.com/xujun1270/p/11220580.html