Intro to Python for Data Science Learning 3 - functions
2024-08-28 02:45:26
Functions
- 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 aroundimag
in the documentation showed us that theimag
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)
最新文章
- 简单的C语言文法
- 解决:No module named pkg_resources
- Oracle查看锁表
- We are 歪果仁带你灰
- 用ConfigurationManager读取和修改配置文件
- jQuery简单导航示例
- Git Bash 使用心得
- sql获取每门课程成绩最好的学生信息
- 服务器编程入门(5)Linux服务器程序规范
- USACO 3.4 Raucous Rockers
- Docker系列一之基础快速入门企业实战
- “海市蜃楼”般的逛街体验——VR全景智慧城市常诚
- Linux程序设计综合训练之简易Web服务器
- UEP-自定义持久化类
- python监控微信报警
- dhcp 的安装和配置文件
- 阿里云服务器连接邮箱SMTP服务器time out的解决
- Vue路由学习心得
- Ubuntu上部署Jenkins
- ERP项目应该由谁来主导?