>>> 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. 通过iframe引入另外一个项目中的html片段到项目中,解决样式,高度,兼容等问题的策略

     <!--尾部开始--> <iframe src="http://172.16.24.11:9000/cartoon-web/footer_new"    m ...

  2. python 2.4 的字符串转时间(日期减法取间隔时间)

    python 2.4中datetime有strftime方法,而无strptime方法.不能对字符串进行格式转换.比如不能将"2013-10-22"转化为日期. 2.4中字符串转日 ...

  3. 【一天一道LeetCode】#28. Implement strStr()

    一天一道LeetCode系列 (一)题目 Implement strStr(). Returns the index of the first occurrence of needle in hays ...

  4. 《java入门第一季》之面向对象(final关键字)

    /* final可以修饰类,方法,变量 特点: final(可以修饰类),该(类)(不能被继承).一旦修饰了一个类,这个类就不能被继承了! final以修饰方法,该方法可以被继承但是不能被重写.(覆盖 ...

  5. Android编译系统中的Kconfig,Makefile,.config编译系统浅析

    在对Android进行编译时,用的就是Linux下的Makefile和Kconfig编译系统,对整个系统进行编译.当然还包括很多配置命令,比如make defconfig, make oldconfi ...

  6. Demonstration of DB Query Analyzer 6.03 Installation and Running on Microsoft Windows 8

    Demonstration of DB Query Analyzer 6.03 Installation and Running on Microsoft Windows 8 Ma Genfeng ( ...

  7. Leetcode_263_Ugly Number

    本文是在学习中的总结,欢迎转载但请注明出处:http://blog.csdn.net/pistolove/article/details/49431329 Write a program to che ...

  8. Android源代码目录组成介绍-android学习之旅(97)

    android的主要源代码组成如下: Kernel:Android Linux 内核2.6 bionic:Android 标准C运行支持库 bootloader:内核加载器参考 build:Andro ...

  9. Linux内核中断和异常分析(上)

    中断,通常被定义为一个事件.打个比方,你烧热水,水沸腾了,这时候你要去关掉烧热水的电磁炉,然后再去办之前手中停不下来的事情.那么热水沸腾就是打断你正常工作的一个信号机制.当然,还有其它的情况,我们以后 ...

  10. Demo3

    <!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF-8&quo ...