运算符
1.算数运算符:+, -, *, /(正常数学的除法) , //(地板除) ,%(取余), **(指数)。
2.逻辑运算符:and ,or,!
3.比较运算符:==,>,<,>=,<=,!=
优先级:短路原则————and:若左式为False,则结果为False
or:若左式为True,则结果为True
while 循环
语法:
while(条件):
#例题:猜年龄while
age_of_princal = 56
guess_age = int(input(">>:"))
while age_of_princal != guess_age:
if guess_age == age_of_princal:
print("yes,you got it..")
elif guess_age > age_of_princal:
print("you guess big")
else:
print("your guess low")
guess_age = int(input(">>:"))
print("end")
##指定长宽输出长方形:
height = int(input("hign:"))
weight = int(input("weight:"))
h=1
while h<=height:
w=1
while w<=weight:
print("#",end="")
w=w+1
print("")
h=h+1
占位符
%d: d = digit数字
%s: s = string字符串
%f: f = float 浮点型
#格式化字符串输出
------
name = input("name:")
age = input("age:")
salary = input("salary:)
msg = '''
________ info of %s ________
name:%s
age:%d
salary:%d
________ end ________
''' % (name,name,age,salary)
print(msg)