>>> 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. 《java入门第一季》之类(String类常见方法小叙)

    String类下面的构造方法和一些常见的方法: /* * 字符串:就是由多个字符组成的一串数据.也可以看成是一个字符数组. * 通过查看API,可以知道 * A:字符串字面值"abc&quo ...

  2. android的Binder通信机制java层浅谈-android学习之旅(88)

    1.Service Manager的Java代理对象 在Java层中,Service Manager的代理对象类型为ServiceManagerProxy.它继承并且实现了IServiceManage ...

  3. AndroidBinder进程间通信系统-android学习之旅(86)

    目录 前言及知识准备 Service组件结构 Clinet组件结构 与Binder驱动程序交互 总结 Binder进程间通信实例 问题 本次主要介绍Android平台下Binder进程间通信库.所谓通 ...

  4. daemontools安装和使用

    daemontools安装和使用 参考: http://cr.yp.to/daemontools/install.html daemontools用于自动重启进程.当某个关键服务进程崩溃,可以利用da ...

  5. Android+Eclipse修改包路径

    在开发过程中发现之前定的包名或是路径不太合理,怎么修改呢?选中要修改的包,按F2按键,如下图: 图1 上图是我修改后的,修改前的包名是com.example.appcenter,自改为com.exam ...

  6. node.js 连接数据库

    用Nodejs连接MySQL 用Nodejs连接MySQL 从零开始nodejs系列文章 ,将介绍如何利Javascript做为服务端脚本,通过Nodejs框架web开发.Nodejs框架是基于V8的 ...

  7. 深入Lucene索引机制

    Lucene的索引里面存了些什么,如何存放的,也即Lucene的索引文件格式,是读懂Lucene源代码的一把钥匙. 当我们真正进入到Lucene源代码之中的时候,我们会发现: Lucene的索引过程, ...

  8. android离线缓存技术

    离线缓存是指在有网络的状态下将从服务器获取的网络数据,如Json 数据缓存到本地,在断网的状态下启动APP时读取本地缓存数据显示在界面上,常用的APP(网易新闻.知乎等等)都是支持离线缓存的,这样带来 ...

  9. SharePoint2010 -- ECMAScript客户端模型简单示例

    ECMAScript客户端模型,是SharePoint2010推出的三种客户端模型".NET托管"."ECMAScript"."Sliverlight ...

  10. LeetCode(36)- Implement Stack using Queues

    题目: Implement the following operations of a stack using queues. push(x) -- Push element x onto stack ...