1、python的环境搭建
2、给出下载链接地址
3、if和while混合使用
age=56
count = 0
while count<3:
guess_age=int(input("请输入年龄:"))
if guess_age == age:
print("yes,you got it")
break
elif guess_age > age:
print("pls it it smaller")
else:
print("pls make it bigger")
count +=1
if count >= 3:
confrimex = input("do you want to try again..?")
if confrimex != 'n':
count = 0
4、for使用
for i in range (2,100,3):
print("loop %d",i)
5、用户的交互
id=int(input("id:"))
print(type(id))
name = input("name:")
age = input("age:")
sallary=input("sallary:")
msg='''
#拼接字符串---------------------index of '''+name+'''
id:'''+str(id)+'''
name:'''+name+'''
age:'''+str(age)+'''
salary:'''+sallary
print(msg)
print("--------------------------------------------------------------")
msg='''
#格式化输出-----------------------index of----------------%s
id=%d
name=%s
age=%s
salary=%s
''' % (name,id,name,age,sallary)
print(msg)
print("--------------------------------------------------------------")
msg='''
#变量占位符-----------------------index of----------------{_name}
id={_id}
name={_name}
age={_age}
salary={_salary}
'''.format(_name=name,_id=id,_age=age,_salary=sallary)
print(msg)
print("--------------------------------------------------------------")
msg='''
#数字占位符-----------------------index of----------------{0}
id={1}
name={0}
age={2}
salary={3}
'''.format(name,id,age,sallary)
print(msg)
-------------------------------------------------------------------------
最有代表性的代码
#Author:Leo Chan age=56 count = 0 while count<3: guess_age=int(input("请输入年龄:")) if guess_age == age: print("yes,you got it") break elif guess_age > age: print("pls it it smaller") else: print("pls make it bigger") count +=1 if count >= 3: confrimex = input("do you want to try again..?") if confrimex != 'n': count = 0