Python初识

一 、安装python2和python3,实现多版本共存(pip2和pip3均可以正常使用)
     关于pip2出现Fatal error in launcher: Unable to create process using '"'的问题。

  错误截图:

  

  解决方式:

    在Python27文件夹下,复制一份原来的python.exe,再保存成python2.exe(相当于文件夹下有python.exe,python2.exe两个文件)

  如下图:

  

  

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

1 name = input('what your name?')
2 age = int(input('How old are you?'))
3 hometown = input('where are you came from?')
4 print('My name is',name,',Age is',age,',I came from ',hometown,'.')

三、在上题的基础上做出改进,要求按照下面的格式打印
======egon info======
name:egon
age:18
address:shahe
=====================

1 name = input('what your name?')
2 age = int(input('How old are you?'))
3 hometown = input('where are you came from?')
4 
5 print('========',name,'info =======')
6 print('name',name)
7 print('Age:',age)
8 print('hometown:',hometown)
9 print('=====================')

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

1 oldboy_age = 63
2 guess_age = int(input('请输入你猜的年龄:'))
3 if guess_age ==oldboy_age:
4     print('you get it!')
5 elif guess_age > oldboy_age:
6     print('too big!')
7 elif guess_age < oldboy_age:
8     print('too small!')
原文地址:https://www.cnblogs.com/fengqing89/p/7161149.html