Functions

from:https://campus.datacamp.com/courses/intro-to-python-for-data-science/chapter-3-functions-and-packages?ex=1

  • Familiar functions
output = function_name(input)
such as
result = type(3.0)

# Create variables var1 and var2
var1 = [1, 2, 3, 4]
var2 = True

# Print out type of var1
print( type(var1) )

# Print out length of var1
print (len(var1))

# Convert var2 to an integer: out2
out2=int(var2)

  • Help!

help(max)
?max

help(complex)
Help on class complex in module builtins:

class complex(object)
| complex(real[, imag]) -> complex number
|
| Create a complex number from a real part and an optional imaginary part.
| This is equivalent to (real + imag*1j) where imag defaults to 0.

  • Multiple arguments

The square brackets around imag in the documentation showed us that the imag argument is optional. 
But Python also uses a different way to tell users about arguments being optional.
In sorted(iterable, key=None, reverse=False), key and reverse are optional.

# Create lists first and second
first = [11.25, 18.0, 20.0]
second = [10.75, 9.50]

# Paste together first and second: full
full = first + second

# Sort full in descending order: full_sorted
full_sorted = sorted(full,reverse=True)

# Print out full_sorted
print(full_sorted)

最新文章

  1. 简单的C语言文法
  2. 解决:No module named pkg_resources
  3. Oracle查看锁表
  4. We are 歪果仁带你灰
  5. 用ConfigurationManager读取和修改配置文件
  6. jQuery简单导航示例
  7. Git Bash 使用心得
  8. sql获取每门课程成绩最好的学生信息
  9. 服务器编程入门(5)Linux服务器程序规范
  10. USACO 3.4 Raucous Rockers
  11. Docker系列一之基础快速入门企业实战
  12. “海市蜃楼”般的逛街体验——VR全景智慧城市常诚
  13. Linux程序设计综合训练之简易Web服务器
  14. UEP-自定义持久化类
  15. python监控微信报警
  16. dhcp 的安装和配置文件
  17. 阿里云服务器连接邮箱SMTP服务器time out的解决
  18. Vue路由学习心得
  19. Ubuntu上部署Jenkins
  20. ERP项目应该由谁来主导?

热门文章

  1. 【CF633H】Fibonacci-ish II 莫队+线段树
  2. SOA架构商城二 框架搭建
  3. 7.18 python进程间数据共享
  4. 消息通讯之关于消息队列MQ必须了解的相关概念
  5. mysql union查询
  6. WCF的简单使用
  7. Mysql数据库操作复习,增删改查
  8. Oracle体系结构之数据文件管理
  9. iOS判断UIView是否显示在屏幕上
  10. bisecting k-means