首页 > 代码库 > PYTHON拼接显示循环和判断学习

PYTHON拼接显示循环和判断学习

拼接显示:

name = input("name:")
age = int(input("age:"))#转义成整数
job = input("job:")
salary = input("salary:")

info = ‘‘‘
----------in of   %s--------
Name:%s
age:%s
job:%s
salary:%s
‘‘‘ %(name,name,age,job,salary)
%s 字符串   %d整数

info1 = ‘‘‘
----------in of {_name}-----------
Name:{_name}
age:{_age}
job:{_job}
salary: {_salary}
‘‘‘.format(_name=name,
           _age=age,
           _job=job,
           _salary=salary)

info3 = ‘‘‘
----------in of {0}--------
Name:{0}
age:{1}
job:{2}
salary:{3}
‘‘‘ .format(name,age,job,salary)

print(info)
print(info1)
print(info3)

简单的循环,判断

guess_age_oldboy = 56
count = 0
while count <3:
    guess_age = int(input("guess age:"))
    if guess_age == guess_age_oldboy:
        print("YES,YOU GOT IT.")
        break
    elif guess_age > guess_age_oldboy:
        print("think 大了r..")
    else:
        print("think,小了")
    count +=1
    if count == 3:
        countine_confirm = input("你还想玩吗?")
        if countine_confirm !=n:
            count=0
else:
    print("你太蠢了。。。。")

 

PYTHON拼接显示循环和判断学习