python基础知识

一.安装Python2和Python3,实现多版本共存

ps:pip2 和pip3均可以正常使用

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

1 name = input("What is your name?")
2 age = input("How old are you?")
3 hometown = input("Where are you from?")
4 print("hello,",name,"you are",age,"you came from",hometown,"!")

 

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

======egon info======
name:egon
age:18
address:shahe
=====================

代码:

name = input("what is your name?")
age = input("How old are you ?")
address = input("where are you from?")
print("======name info======")
print("name:",name)
print("age:",age)
print("address:",address)
print("=====================")

四.老男孩的年纪为63,要求制作一个猜年龄的游戏,用户输入的年龄小了则提示:too small用户输入的年龄大了则提示:too big用户猜对了年龄则提示:you get it

oldboy_age = 63
age = int(input("请输入老男孩的年龄"))
if age > 63:
    print("too big")
elif age < 63:
    print("too small")
elif age == 63:
    print("you get it")

 

posted @ 2017-07-13 17:33  爱笑的大象  阅读(143)  评论(0编辑  收藏  举报