python_code list_2
>>> import math
>>> math.sin(0.5)
0.479425538604203
>>>
>>> import random
>>> x=random.random()
>>> n=random.randint(1,100)
>>> import numpy as np
>>> a = np.array((1,2,3,4))
>>> print(a)
[1 2 3 4]
>>> from math import sin
>>> sin(3)
0.1411200080598672
>>> from math import sin as f
>>> f(3)
0.1411200080598672
>>> from math import *
>>> sin(3)
0.1411200080598672
>>> gcd(36,18)
18
>>> def main():
if __name__ == '__main__':
print('This program is run directly.')
elif __name__ == 'hello':
print('This program is used as a module.')
>>> import hello
Traceback (most recent call last):
File "<pyshell#72>", line 1, in <module>
import hello
ImportError: No module named 'hello'
>>> alist = ['a','b','mpilgrim','z','example']
>>> a_list = []
>>> a_listt = list((3,4,7,9))
>>> a_listt
[3, 4, 7, 9]
>>> list(range(1,10,2))
[1, 3, 5, 7, 9]
>>> list('hello world')
['h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd']
>>> list({3,7,5})
[3, 5, 7]
>>> list({'a':3,'b':4,'c':5})
['b', 'a', 'c']
>>> list({'a':3,'b':4,'c':5}.items())
[('b', 4), ('a', 3), ('c', 5)]
>>> x = list(range(10))
>>> x
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> x[0]
0
>>> x[1]
1
>>> x[-1]
9
>>> x[-2]
8
>>> x = [1,2,3,4,5,6]
>>> del x[0]
>>> x
[2, 3, 4, 5, 6]
>>> del x
>>> x
Traceback (most recent call last):
File "<pyshell#92>", line 1, in <module>
x
NameError: name 'x' is not defined
>>> x = {'a':3,'b':4,'c':5}
>>> del x['b']
>>> x
{'a': 3, 'c': 5}
>>> x1 = x['c']
>>> x1
5
>>>
python_code list_2的更多相关文章
- python_code list_3
>>> seq=['foo','x41','?','***']>>> def func(x): return x.isalnum() >>> li ...
- python_code list_1
>>> def is_not_empty(s): return s and len(s.strip()) > 0 >>> filter(is_not_empt ...
- python 数据类型 --- 集合
1. 注意列表和集合的区别 set 列表表现形式: list_1 = [1,3,4]; 集合表现形式:set_1= set() list_1 = [1,2,3,4,23,4,2] print(lis ...
- Basic Tutorials of Redis(6) - List
Redis's List is different from C#'s List,but similar with C#'s LinkedList.Sometimes I confuse with t ...
- python基础之函数
python 函数 函数是组织好的,可重复使用的,用来实现单一,或相关联功能的代码段. 函数能提高应用的模块性,和代码的重复利用率.你已经知道Python提供了许多内建函数,比如print().但你也 ...
- Python 数据类型及其用法
本文总结一下Python中用到的各种数据类型,以及如何使用可以使得我们的代码变得简洁. 基本结构 我们首先要看的是几乎任何语言都具有的数据类型,包括字符串.整型.浮点型以及布尔类型.这些基本数据类型组 ...
- Python-03-基础
一.集合 集合(set)是一个无序的.不重复的元素组合,它的主要作用如下: 去重:把一个列表变成集合,就会自动去重. 关系测试:测试两组数据之前的交集.差集.并集等关系. 常用操作 # 创建数值集合 ...
- Python学习Day2笔记(集合和文件操作)
1.集合的使用 列表是有序的可包含重复内容的 集合是无序的不可包含重复内容的 1) 集合关系测试 #列表去重list_1=[1,4,5,6,7,8,9,7,5,4,23,2] #有重复数据 list_ ...
- Python Day3
一.set集合 集合是一个无序的,不重复的数据组合,它的主要作用如下: 去重,把一个列表变成集合,就自动去重了 关系测试,测试两组数据之前的交集.差集.并集等关系 # 创建数值集合 list_1 = ...
随机推荐
- Rust语言之HelloWorld
Rust语言之HelloWorld 参考文档: http://doc.crates.io/guide.html 1 什么是Cargo 相当于maven/ant之于java, automake之于c, ...
- mysql 字符集更改与导入数据
mysql 字符集更改与导入数据 mysqldb经常有中文乱码的问题,解决起来很恼火.其实所有开发和数据库统一为一种编码就可以了: utf8. 1 下面修改mysql的编码 1) 永久修改. 在/et ...
- 网络小白之WAN与LAN的区别
剑指Offer--网络小白之WAN与LAN的区别 基本作用 wan接口是外网接口,是用来连接互联网或局域网等外部网络的. lan接口是内网接口,是用来连接计算机终端或其他路由器等终端设备的. 举例 w ...
- ActionScript 3.0 API 中的 Video 类
注:这个类在Flash流媒体开发中使用的很频繁,在此记录一下它的使用方法. 包 flash.media 类 public class Video 继承 Video DisplayObject Ev ...
- Spring AOP (二)
下面介绍@AspectJ语法基础 一.切点表达式函数 AspectJ的切点表达式由关键字和操作参数组成,如execution(* greetTo(..)) 的切点表达式,execution为关键字,而 ...
- FFMPEG结构体分析:AVIOContext
注:写了一系列的结构体的分析的文章,在这里列一个列表: FFMPEG结构体分析:AVFrame FFMPEG结构体分析:AVFormatContext FFMPEG结构体分析:AVCodecConte ...
- LIRe 源代码分析 3:基本接口(ImageSearcher)
===================================================== LIRe源代码分析系列文章列表: LIRe 源代码分析 1:整体结构 LIRe 源代码分析 ...
- windows下追踪路由
追踪路由 tracert 目标ip/域名 测试两个ip是否畅通 ping 目标ip 在windows查看ip情况 ipconfig linux/unix下查看ip情况的使用 ifconfig
- 嵌入式C语言位运算之清位置位
如题,在嵌入式开发中,掌握位运算是节省开发时间和提高开发效率的一种高效方式. 我们不得不去熟悉如何快速掌握位运算这种高效的技巧,接下来看看程序.. #include <stdio.h> # ...
- Junit指定测试执行顺序
原文链接: Test execution order原文日期: 2012年12月06日翻译日期: 2014年7月2日翻译人员: 铁锚说明: Junit4.11版本及以后才支持,建议升级到最新版本.按照 ...