Python基础之走进Python

该系列为南京大学课程《用Python玩转数据》学习笔记,主要以思维导图的记录

1.1 Python简介

1.1

1.2 第一个Python程序

1.2

1.3 Python语法基础

1.3

1.4 Python数据类型

1.4

1.5 Python基本运算

1.5

1.6 Python的函数、模块和包

1.6

测试

题目:简单的输入输出:

1
2
3
4
5
surname = input('input your surname:')
lastname = input('input your lastname:)
print('your surname is:', surname)
pirnt('your lastname is:', lastname)
print('your full name is:', lastname, surname)

讨论

关于round函数:

在python2.x中:0.5会近似到距离0远的一端,比如 :

1
2
round(0.5) = 1
round(-0.5) = -1

Values are rounded to the closest multiple of 10 to the power minus ndigits; if two multiples are equally close, rounding is done away from 0.

在python3.x中:0.5会近似到偶数那边,比如:

1
2
round(2.5) = 2
round(3.5) = 4

values are rounded to the closest multiple of 10 to the power minus ndigits; if two multiples are equally close, rounding is done toward the even choice.