>>> 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. (NO.00001)iOS游戏SpeedBoy Lite成形记(四)

    下面我们来实现选手从起点开始移动到终点的代码. 首先在GameScene.h接口中添加matchRun方法: #import "CCNode.h" @interface GameS ...

  2. 手把手带你画一个 时尚仪表盘 Android 自定义View

    拿到美工效果图,咱们程序员就得画得一模一样. 为了不被老板喷,只能多练啊. 听说你觉得前面几篇都so easy,那今天就带你做个相对比较复杂的. 转载请注明出处:http://blog.csdn.ne ...

  3. Linux System Programming -- Appendix

    这本书附录的名字是 "GCC对C语言的扩展" ,一下的内容是对扩展的总结 类型发现 GCC 允许通过变量的引用识别类型.这种操作支持泛型编程.在 C++.Ada 和 Java™ 语 ...

  4. 移植Cocos2D到Android平台的原理

    幸运的,SpriteBuilder使得适配(安卓)多种多样的屏幕尺寸变得容易起来,因为Android Xcode插件允许你使用任何Cocos2D的特性并且可以继续使用很多iOS的框架(framewor ...

  5. Android安全机制浅谈-android学习之旅(80)

    由于Android安全机制存在,使得漏洞利用有一些困难. ASLR:即地址空间格局随机化.ASLR使得加载程序时不使用固定的基址加载,防止攻击者直接定位攻击代码位置,从而阻止溢出攻击 NX:(No e ...

  6. 大型服装集团BI决策系统的分析主题模块

    一般BI商业智能解决方案都包含财务.销售.客户等分析模块,本文分享的是某大型服装集团通过帆软FineBI建设的BI决策系统.该决策系统主要针对财务.资金.采购.生产.库存.物流.销售.渠道.产品.客户 ...

  7. LeetCode之“树”:Validate Binary Search Tree

    题目链接 题目要求: Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is ...

  8. Android Notification 版本适配方案

    Notification 介绍见:https://developer.android.com/reference/android/app/Notification.html Android api 一 ...

  9. 色彩转换——RGB & HSV

    RGB to HSV The R,G,B values are divided by 255 to change the range from 0..255 to 0..1: R' = R/255 G ...

  10. 不错的网络协议栈测试工具 — Packetdrill

    Packetdrill - A network stack testing tool developed by Google. 项目:https://code.google.com/p/packetd ...