Python Learning: 02
OK, let's continue.
- Conditional Judgments and Loop
- if
- if-else
- if-elif-else
- while
- for
- break
- continue
- multiple loop
- Differences between Dict and Set
- Dict: A kind of structure in the type of "Key-Value"
- described in "{}"
- formed by "key: value"
- function "len()" to calculate the length
- judge empty:① if 'key' in dict ②dict.get('key') ->if empty, return None automatically
- the key in dict is unchangeable
- Set: A kind of struture in the type of Non-repeating elements collection
- described in "set([,,,,])"
- add() to add elements
- remove() to delete elements
- Dict: A kind of structure in the type of "Key-Value"
- Functions
- where to searching functions:
http://docs.python.org/2/library/functions.html#abs
- some common functions: abs(), cmp(), int(), str(), sum()
- the Return Value of Functions
A function can return single value, as well as return more value. But in essence it returns one, a tuple. The function treats the values as a tuple.
>>> r = move(100, 100, 60, math.pi / 6)
>>> print r
(151.96152422706632, 70.0)
- recursive functions: take care of overflowing
- default parameter: set default parameter in the function line in the blankets, and the default parameter must be set at the right side
- variable parameter: use '*' to mark variable parameter , and they are regarded as a tuple
Python Learning: 02的更多相关文章
- Python学习02 列表 List
Python学习02 列表 List Python列表 List Python中的列表(List)用逗号分隔,方括号包围(comma-separated values (items) between ...
- Python网络02 Python服务器进化
原文:Python网络02 Python服务器进化 作者:Vamei 出处:http://www.cnblogs.com/vamei 欢迎转载,也请保留这段声明.谢谢! **注意,在Python 3. ...
- python learning Exception & Debug.py
''' 在程序运行的过程中,如果发生了错误,可以事先约定返回一个错误代码,这样,就可以知道是否有错,以及出错的原因.在操作系统提供的调用中,返回错误码非常常见.比如打开文件的函数open(),成功时返 ...
- python进阶02 特殊方法与特殊属性
python进阶02 特殊方法与特殊属性 一.初始化.析构 1.初始化 # python中有很多双下划线开头且以下划线结尾的固定方法,它们会在特定的时机被触发执行,这便是特殊方法 # 在实例化的时候就 ...
- Python模块02/序列化/os模块/sys模块/haslib加密/collections
Python模块02/序列化/os模块/sys模块/haslib加密/collections 内容大纲 1.序列化 2.os模块 3.sys模块 4.haslib加密 5.collections 1. ...
- Python函数02/函数的动态参数/函数的注释/名称空间/函数的嵌套/global以及nolocal的用法
Python函数02/函数的动态参数/函数的注释/名称空间/函数的嵌套/global以及nolocal的用法 目录 Python函数02/函数的动态参数/函数的注释/名称空间/函数的嵌套/global ...
- Python面向对象02/类的空间问题、类与对象之间的关系、类与类之间的关系
Python面向对象02/类的空间问题.类与对象之间的关系.类与类之间的关系 目录 Python面向对象02/类的空间问题.类与对象之间的关系.类与类之间的关系 1. 类的空间问题 2. 类与对象之间 ...
- Python Learning Paths
Python Learning Paths Python Expert Python in Action Syntax Python objects Scalar types Operators St ...
- (python函数02)列表生成式
(python函数02)列表生成式 示例代码 num = [i for i in range(1, 10)] print(num) num = [i for i in range(1, 10) ...
随机推荐
- Oracle数据库知识要点
一.卸载安装(来自百度经验) 完全卸载: 1. 停止相关服务 2. 运行Universal Installer,卸载产品 3. 清理注册表 4. 重启电脑,删除目录(Oracle文件夹和app文件夹) ...
- 上帝的归上帝,凯撒的归凯撒—— CODING 权限管理更新
上帝的归上帝,凯撒的归凯撒 <马太福音>22 章 15-22 节,耶稣用这句话,说明了神权与政权之间的正确关系,奠定了神权与政权的基础,也划清了二者的界限.其实这两个问题如今也依旧出现在公 ...
- HNOI2019 苟命记
Day0 瞎看了看博客,然后看了看wf题,看了一下午柯南剧场版... 后来发现,复习根本没用,因为我根本没学过. Day1 首先随便看了看三道题,觉得 \(T1\) 挺可做的,\(T2\) 看起来是什 ...
- LOJ #6050. 「雅礼集训 2017 Day11」TRI
完全不会的数学神题,正解留着以后填坑 将一个口胡的部分分做法,我们考虑计算格点多边形(包括三角形)面积的皮克公式: \[S=a+\frac{1}{2}b-1\text({a为图形内部节点个数,b为边界 ...
- 【重磅】微软开源自动机器学习工具 - NNI
[重磅]微软开源自动机器学习工具 - NNI 在机器学习建模时,除了准备数据,最耗时耗力的就是尝试各种超参组合,找到模型最佳效果的过程了.即使是对于有经验的算法工程师和数据科学家,有时候也很难把握其中 ...
- Use Wait & Notify to Implement Two Threads Run Alternatively
public class ThreadCommunication { public static void main(String[] args) { Business business = new ...
- “Validation failed for one or more entities”异常的解决办法
日志中出现Entity Framework修改数据库时的错误: Validation failed for one or more entities. See 'EntityValidationErr ...
- Spring Cloud Eureka 注册中心集群搭建,Greenwich 最新版!
Spring Cloud 的注册中心可以由 Eureka.Consul.Zookeeper.ETCD 等来实现,这里推荐使用 Spring Cloud Eureka 来实现注册中心,它基于 Netfl ...
- VS Code实用技能1 - 代码折叠、面包屑
VS Code实用技能 VS Code实用技能1 - 代码折叠.面包屑 一.代码折叠 ubuntu ctrl + shift + { ctrl + shift + } ctrl + k , ctrl ...
- java基础(十八)----- java动态代理原理源码解析
关于Java中的动态代理,我们首先需要了解的是一种常用的设计模式--代理模式,而对于代理,根据创建代理类的时间点,又可以分为静态代理和动态代理. 静态代理 1.静态代理 静态代理:由程序员创建或特定工 ...