python学习1
1.python格式化输出
name = input ("name:")
age = int(input("age:"))
info = '''
---------- info of %s ----------
Name:%s
Age:%s
'''%(name, age)
2.if else语句
age=36
if age == int(intput("age:")):
print("yes,you got it")
else:
print("you are wrong")
---------------------------------------
------------if elif else---------------
age=36
if age == int(input("age:")):
print("yes,you got it")
elif age > int(input("age:")):
print("is smaller")
else:
print("is bigger")
--------------------------------------
--------while----------
i=1
while i < 3:
print("i:"i)
i +=i
--------------------------------------
----------------for------------------
for i in range(10):
print("i:"i)
上式等价于
for i in range(0,10,1):
print("i:")
(0,10,1)中,1的意思是步长,(0,10,2)这样会隔一个数输出,0,2,4,6,8