print('abs():输出绝对值,是absolute的缩写--------------') print(abs(-1)) print('all()与any()---------------------------') #all都为真时才为真,但是空的为真,any()有一个为真时就是真的 jo1_list=[1,2,3,4,5,6,7] jo2_list=['',2,3,4,5,7] jo4_list=[0,2,3,4,5,6,7] jo5_list=[False,2,3,4,5,6,7] j…
Python的内置方法 abs(X):返回一个数的绝对值,X可以是一个整数,长整型,或者浮点数,如果X是一个复数,此方法返回此复数的绝对值(此复数与它的共轭复数的乘积的平方根) >>> abs(3+2j) 3.605551275463989 >>> abs(3-2j) 3.605551275463989 all(iterable):如果迭代器的所有元素都是true,或者空迭代器,则此方法返回true. any(iterable):迭代器只要有一个元素为false,或者空…
#the real experiment for simon effect #load the library which is our need import pygame import sys import random from pygame.locals import * #creat the subject information function def sub_info(): sub_ID = input("please input your number: ") sub…
## #the real experiment for simon effect #load the library which is our need import pygame import sys,random from pygame.locals import * pygame.init() win = pygame.display.set_mode((800,600),DOUBLEBUF|HWSURFACE) left = (200,300) right = (600,300) red…
一.下载安装 1.1Python下载 Python官网:https://www.python.org/ 1.2Python安装 1.2.1 Linux 平台安装 以下为在Unix & Linux 平台上安装 Python 的简单步骤: 打开WEB浏览器访问https://www.python.org/downloads/source/ 选择适用于Unix/Linux的源码压缩包. 下载及解压压缩包. 如果你需要自定义一些选项修改Modules/Setup 执行 ./configure 脚本 ma…
全局变量与局部变量 1.什么是全局变量 在globals中的变量,都是全局变量,全局变量的作用域就是整个程序 NAME = 'alex' def global_test(): name = 'alex' def local_test(): name = 'jack' global_test() print(globals()) print("__name__:", __name__) print('__doc__:', __doc__) print('__cached__', __ca…
#1 Tab键: 1)控制缩进 2)IDLE智能补全 #2 =等号: 1)=:表示赋值 2)==:表示判断 #3 流程图: print('..........小甲鱼_1..........') temp=input('猜测小甲鱼心里想的是哪个数字:') guess=int(temp) if guess==8:    print('中了')    print('哼,中了也没有奖励') else:    print('猜错啦,小甲鱼想的是8!') print('游戏结束,不玩了.') 改进: 1)条…
6. Modules If you quit from the Python interpreter and enter it again, the definitions you have made (functions and variables) are lost. Therefore, if you want to write a somewhat longer program, you are better off using a text editor to prepare the…
一.函数对象 函数(Function)作为程序语言中不可或缺的一部分,但函数作为第一类对象(First-Class Object)却是 Python 函数的一大特性. 那到底什么是第一类对象(First-Class Object)呢? 在 Python 中万物皆为对象,函数也不例外,函数作为对象可以赋值给一个变量.可以作为元素添加到集合对象中.可作为参数值传递给其它函数,还可以当做函数的返回值,这些特性就是第一类对象所特有的. 1.函数身为一个对象,拥有对象模型的三个通用属性:id.类型.和值.…
Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 07:18:10) [MSC v.1900 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. >>> dir(__builtins__) ['ArithmeticError', 'AssertionErro…