首页 > 代码库 > PYthon基础

PYthon基础

用python语言编写代码,要求输入用户信息:姓名,年纪,家庭住址,然后打印

name=input(‘what is your name?‘)
age=input(‘how old are u?‘)
addr=input(‘where are u from?‘)
print(‘hi‘,name,‘you are‘,age,‘years old,u are from‘,addr)

 

在上题的基础上做出改进,要求按照下面的格式打印

======egon info======

name:egon

age:18

address:shahe

=====================

 

name=input(‘Name:‘)

age=input(‘Age:‘)

addr=input(‘Addr:‘)

info=‘‘‘

======%s  info======

NAME=%s

AGE=%s

ADDR=%s

======END======

‘‘‘%(name,name,age,addr)

print(info)

 

 

老男孩的年纪为63,要求制作一个猜年龄的游戏

              用户输入的年龄小了则提示:too small

              用户输入的年龄大了则提示:too big

              用户猜对了年龄则提示:you get it

 

while True:
  age=int(input(‘plz input oldboy age‘))
  if age<63:
    print(‘too small‘)
  elif age>63:
    print(‘too big‘)
  else :
    print(‘you get it‘)

    break

  

 

 

PYthon基础