>>> 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的更多相关文章

  1. python_code list_3

    >>> seq=['foo','x41','?','***']>>> def func(x): return x.isalnum() >>> li ...

  2. python_code list_1

    >>> def is_not_empty(s): return s and len(s.strip()) > 0 >>> filter(is_not_empt ...

  3. python 数据类型 --- 集合

    1. 注意列表和集合的区别 set 列表表现形式: list_1 = [1,3,4];  集合表现形式:set_1= set() list_1 = [1,2,3,4,23,4,2] print(lis ...

  4. 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 ...

  5. python基础之函数

    python 函数 函数是组织好的,可重复使用的,用来实现单一,或相关联功能的代码段. 函数能提高应用的模块性,和代码的重复利用率.你已经知道Python提供了许多内建函数,比如print().但你也 ...

  6. Python 数据类型及其用法

    本文总结一下Python中用到的各种数据类型,以及如何使用可以使得我们的代码变得简洁. 基本结构 我们首先要看的是几乎任何语言都具有的数据类型,包括字符串.整型.浮点型以及布尔类型.这些基本数据类型组 ...

  7. Python-03-基础

    一.集合 集合(set)是一个无序的.不重复的元素组合,它的主要作用如下: 去重:把一个列表变成集合,就会自动去重. 关系测试:测试两组数据之前的交集.差集.并集等关系. 常用操作 # 创建数值集合 ...

  8. Python学习Day2笔记(集合和文件操作)

    1.集合的使用 列表是有序的可包含重复内容的 集合是无序的不可包含重复内容的 1) 集合关系测试 #列表去重list_1=[1,4,5,6,7,8,9,7,5,4,23,2] #有重复数据 list_ ...

  9. Python Day3

    一.set集合 集合是一个无序的,不重复的数据组合,它的主要作用如下: 去重,把一个列表变成集合,就自动去重了 关系测试,测试两组数据之前的交集.差集.并集等关系 # 创建数值集合 list_1 = ...

随机推荐

  1. Android 上滑上拉菜单SlidingDrawer 不全屏显示的方法

    这里来说一个已经被废弃的SlidingDrawer.. 他可以实现上拉,下拉的菜单. 但是有个问题就是上拉以后,是全屏显示的. 首先 写一个布局: <RelativeLayout xmlns:a ...

  2. 《java入门第一季》之类面试题

    面试题一: String,StringBuffer,StringBuilder的区别?  * A:String是内容不可变的,而StringBuffer,StringBuilder都是内容可变的.   ...

  3. 使用SVM对多类多维数据进行分类

    最近,本人要做个小东西,使用SVM对8类三维数据进行分类,搜索网上,发现大伙讨论的都是二维数据的二分类问题,遂决定自己研究一番.本人首先参考了opencv的tutorial,这也是二维数据的二分类问题 ...

  4. 新版MATERIAL DESIGN 官方动效指南(一)

    Google 刚发布了新版Material Design 官方动效指南,全文包括三个部分:为什么说动效很重要?如何制作优秀的Material Design动效及转场动画,动效的意义.新鲜热辣收好不谢! ...

  5. 初涉IPC,了解AIDL的工作原理及使用方法

    初涉IPC,了解AIDL的工作原理及使用方法 今天来讲讲AIDL,这个神秘的AIDL,也是最近在学习的,看了某课大神的讲解写下的blog,希望结合自己的看法给各位同价通俗易懂的讲解 官方文档:http ...

  6. Leetcode_190_Reverse Bits

    ), return 964176192 (represented in binary as00111001011110000010100101000000). 思路: (1)题意为给定无符号32位整数 ...

  7. CentOS 6.5安装MongoDB 2.6(多yum数据源)

    下面我们在CentOS 6.5 x64系统上安装最新的MongoDB 2.6.5版. 在MongoDB v2.6.5版的软件仓库一共有五个包: 1)mongodb-org此包是元数据包,它可以实现自动 ...

  8. HBase BlockCache

    1. Cache 读写  调用逻辑:  hmaster.handleCreateTable->HRegion.createHRegion-> HRegion. initialize-> ...

  9. 面试之路(28)-反转链表(reverse ListNode)

    反转链表: java类 public class ListNode{ int key; ListNode next; } 思路分析: 需要三个指针,current,prev和next. current ...

  10. Leetcode(59)-Count Primes

    题目: Description: Count the number of prime numbers less than a non-negative number, n. 思路: 题意:求小于给定非 ...