2019独角兽企业重金招聘Python工程师标准>>>
2017/10/29
''' #CalCircleArea radius=25 area=3.1415926* radius*radius print(area) print("{:.2f}".format (area)) ''' ''' #EchoName.py name=input("输入姓名") print("{}同学,我勒个去".format(name)) print("{}superman,hello fuck".format(name[0])) print("{}gerger,i love you".format(name[1:])) ''' ''' #CalFibonacci.py a,b=0,1 while a<10000: print(a,end=',') a,b=b,a+b ''' ''' #DrawTangentCirles.py import turtle turtle.pensize(2) turtle.circle(10) turtle.circle(40) turtle.circle(80) turtle.circle(160) ''' #PrintLocalDateTime from datetime import datetime now = datetime.now() print(now) now.strftime("%x") now.strftime("%x")
Python 3.6.2 (v3.6.2:5fd33b5, Jul 8 2017, 04:14:34) [MSC v.1900 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. >>> print("hello") hello >>> ================================================================================================================================================================================================================================================================================================================================================================================================ RESTART: F:/U/python/try2.py ================================================================================================================================================================================================================================================================================================================================================================================================ 1963.4953750000002 1963.50 >>> ================================================================================================================================================================================================================================================================================================================================================================================================ RESTART: F:/U/python/try2.py ================================================================================================================================================================================================================================================================================================================================================================================================ 输入姓名pan pan同学,我勒个去 psuperman,hello fuck angerger,i love you >>> ================================================================================================================================================================================================================================================================================================================================================================================================ RESTART: F:/U/python/try2.py ================================================================================================================================================================================================================================================================================================================================================================================================ 输入姓名潘哈哈 潘哈哈同学,我勒个去 潘superman,hello fuck 哈哈gerger,i love you >>> ================================================================================================================================================================================================================================================================================================================================================================================================ RESTART: F:/U/python/try2.py ================================================================================================================================================================================================================================================================================================================================================================================================ 0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987, >>> ================================================================================================================================================================================================================================================================================================================================================================================================ RESTART: F:/U/python/try2.py ================================================================================================================================================================================================================================================================================================================================================================================================ 0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765, >>> ================================================================================================================================================================================================================================================================================================================================================================================================ RESTART: F:/U/python/try2.py ================================================================================================================================================================================================================================================================================================================================================================================================ Traceback (most recent call last): File "F:/U/python/try2.py", line 35, in
trutle.circle(160) NameError: name 'trutle' is not defined >>> ================================================================================================================================================================================================================================================================================================================================================================================================ RESTART: F:/U/python/try2.py ================================================================================================================================================================================================================================================================================================================================================================================================ >>> ================================================================================================================================================================================================================================================================================================================================================================================================ RESTART: F:/U/python/try2.py ================================================================================================================================================================================================================================================================================================================================================================================================ 2017-10-29 19:49:49.585110 >>> now.strftime ("%x") '10/29/17' >>> now.strftime ("%x") '10/29/17' >>> -------------
11/01
Python 3.6.2 (v3.6.2:5fd33b5, Jul 8 2017, 04:14:34) [MSC v.1900 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. >>> ================================================================================================================================================================================================================================================================================================================================================================================================= RESTART: F:\U\python\1.py ================================================================================================================================================================================================================================================================================================================================================================================================= >>> ================================================================================================================================================================================================================================================================================================================================================================================================= RESTART: F:\U\python\1.py ================================================================================================================================================================================================================================================================================================================================================================================================= >>> ================================================================================================================================================================================================================================================================================================================================================================================================= RESTART: F:\U\python\1.py ================================================================================================================================================================================================================================================================================================================================================================================================= Traceback (most recent call last): File "F:\U\python\1.py", line 6, in
turtle.pencolor((233,111,45)) File " ", line 8, in pencolor File "F:\U\python\lib\turtle.py", line 2252, in pencolor color = self._colorstr(args) File "F:\U\python\lib\turtle.py", line 2696, in _colorstr return self.screen._colorstr(args) File "F:\U\python\lib\turtle.py", line 1166, in _colorstr raise TurtleGraphicsError("bad color sequence: %s" % str(color)) turtle.TurtleGraphicsError: bad color sequence: (233, 111, 45) >>> ================================================================================================================================================================================================================================================================================================================================================================================================= RESTART: F:\U\python\1.py ================================================================================================================================================================================================================================================================================================================================================================================================= Traceback (most recent call last): File "F:\U\python\1.py", line 7, in turtle.pencolor((233,111,45)) File " ", line 8, in pencolor File "F:\U\python\lib\turtle.py", line 2252, in pencolor color = self._colorstr(args) File "F:\U\python\lib\turtle.py", line 2696, in _colorstr return self.screen._colorstr(args) File "F:\U\python\lib\turtle.py", line 1166, in _colorstr raise TurtleGraphicsError("bad color sequence: %s" % str(color)) turtle.TurtleGraphicsError: bad color sequence: (233, 111, 45) >>> ================================================================================================================================================================================================================================================================================================================================================================================================= RESTART: F:\U\python\1.py ================================================================================================================================================================================================================================================================================================================================================================================================= Traceback (most recent call last): File "F:\U\python\1.py", line 7, in turtle.pencolor((23,111,45)) File " ", line 8, in pencolor File "F:\U\python\lib\turtle.py", line 2252, in pencolor color = self._colorstr(args) File "F:\U\python\lib\turtle.py", line 2696, in _colorstr return self.screen._colorstr(args) File "F:\U\python\lib\turtle.py", line 1166, in _colorstr raise TurtleGraphicsError("bad color sequence: %s" % str(color)) turtle.TurtleGraphicsError: bad color sequence: (23, 111, 45) >>> ================================================================================================================================================================================================================================================================================================================================================================================================= RESTART: F:\U\python\1.py ================================================================================================================================================================================================================================================================================================================================================================================================= Traceback (most recent call last): File "F:\U\python\1.py", line 7, in turtle.pencolor(23,111,45) File " ", line 8, in pencolor File "F:\U\python\lib\turtle.py", line 2252, in pencolor color = self._colorstr(args) File "F:\U\python\lib\turtle.py", line 2696, in _colorstr return self.screen._colorstr(args) File "F:\U\python\lib\turtle.py", line 1166, in _colorstr raise TurtleGraphicsError("bad color sequence: %s" % str(color)) turtle.TurtleGraphicsError: bad color sequence: (23, 111, 45) >>> ================================================================================================================================================================================================================================================================================================================================================================================================= RESTART: F:\U\python\1.py ================================================================================================================================================================================================================================================================================================================================================================================================= >>> ================================================================================================================================================================================================================================================================================================================================================================================================= RESTART: F:\U\python\1.py ================================================================================================================================================================================================================================================================================================================================================================================================= >>> ================================================================================================================================================================================================================================================================================================================================================================================================= RESTART: F:\U\python\1.py ================================================================================================================================================================================================================================================================================================================================================================================================= Traceback (most recent call last): File "F:\U\python\1.py", line 8, in turtle.pencolor((51,204,140)) File " ", line 8, in pencolor File "F:\U\python\lib\turtle.py", line 2252, in pencolor color = self._colorstr(args) File "F:\U\python\lib\turtle.py", line 2696, in _colorstr return self.screen._colorstr(args) File "F:\U\python\lib\turtle.py", line 1166, in _colorstr raise TurtleGraphicsError("bad color sequence: %s" % str(color)) turtle.TurtleGraphicsError: bad color sequence: (51, 204, 140) >>> ================================================================================================================================================================================================================================================================================================================================================================================================= RESTART: F:\U\python\1.py ================================================================================================================================================================================================================================================================================================================================================================================================= >>> ================================================================================================================================================================================================================================================================================================================================================================================================= RESTART: F:\U\python\1.py ================================================================================================================================================================================================================================================================================================================================================================================================= >>> pow(2,5) 32 >>> pow(2,pow(2,15)) 1415461031044954789001553027744951601348130711472388167234385748272366634240845253596025356476648415075475872961656126492389808579544737848881938296250873191743927793544913011050162651277957029846960211783242933521207545413484969856851851141288515163201482995389055097460622098635675003353929224278582935664416262572773308153277514346480313371988612629481483562438178928958867777850072198316174841251955590996672018645093640850803679630220367201383844866791449284737518262813123083439037243678440420897139923778278952770312318778329004894547065489077596835396017153603170050371302014762443872701111379554484309718662306883776010475348441493600491943479041271992920195331983064930106164727241438940877685164658948654886171641124473975626241632750150126655369981021293570066042305482486040883165635862835728637046058352403756085745691239473897891999085976345203704659967157427239535836507133656908815246080139195569461072006301590372954830738644391138016065344131131207604264053897440828904662047183234377547427287691941741535946510882990904477863185473798528388060457568927943633923928872681927502029572963130840854853739937076881035646179383055483433876051402037614424748902969018159186519811051545367967103767182819709135479019131683309330797374408197339831527239040715908112213095126770717606001288898889370710896248862361503869205214536908258196921765593065325392836332142594411134603475509366028145690306350601859295261296263331018682276317567749534571058772235567679556920240789109070521253987131031263902293034744367356932509952188828475362311316445284228640489421809263738423630931243024914587863928134719186104164660605356001591962778646378295413659770782646979236289062616442418071571039282551289348848274522893059561717860194034698241804887531275078109603637160495907579995366419636417028927573391670580796818526074226095014375189438579216071677540766085605604106123036669667434677723472675564458991671268414100801031453917736665947284956674884035306621286465183798693852599803324619865181856244422079233687294508536408521087418873908498202710597080474480249818858011490930518512713798803629101638716278578874145214429026186276602289012484526830076647356828764878327726719816428678904207944456894393185983090347045176886732326253912297649524439880403701430566761380359925558522718201954287517587367247510777678934664472548647787048306330770862370015525858005479756471499227244901142805749769564184753211967223226212964165678856604892416984915097422960534122333453876981279243565766391796311605149222628328255333061543877525846029404507128890053189442527544665141513571136187126874914601669750392486100507568442046831780631032540574077944274454228087639241736818505163759910365131990632947462993204585218122431992323864244947394390438656356424037471932484452186545692102503479070599953823165194211019696760575264426802848303031804305733532228050180286034175168918827460626042268658295140706915047189049492578996650494005882337071150004868956193406593184838633694068409823903437144417376039174235011053228846851424217955172902918651003610984108402650929359396305634313047088725113039076811940090109855578285937829164213576612822210347957745947331047482525346602542653176899809278808232796557531832150249769253600667902268029661700149632868541956266119528042486534014778779846981761033155007262730162675954520221887384710387051721829271917592295057169589539706361671082094809405871790468623234895914796464390019259167513771864832869036015645542195008456098615038348028400803005801944957156282746379539470250603755465358786281476086044567893715130635914946085361612372742732638037372287633897118303250036355897758209569010246051563429109255864938245524550200580218274314809738075022775651220374105227215906205292751918667060475328593225367793061070422108733800983855507591806413460964585595316359971179284283604731468668545484761381747591639736453419896449323486397030776397761202590467637505473390222249456724093238682557762781839530938233751281999608711356147835655195236666056355678841889862284014674059052995170220711404445012766642203314592371712594877968343265210232798135023299117318191770365123807086704381809759602260151612996896994294186084475619138121455294389585874237791634701296124550179672059485838256445846530599137662480841344376503989244633345016070887198120421435575726237189312161818021548006389501182393441712142044953072264016676799011624620312246468554654371544717355227740157629086739710675845209992133342035144038961065892653392182875622932670067798433934891709519877850794219491447988160171932331006495620280094149464379450153085406225081471879585894087916092141623752345112751067703166403681162331920291740847388957632311053342426152947324011627922225878539935022974616062774839110489080094174972841068102006645677499293769091362853719300958775222088670909723895414866464400756314470281962034276531512544009726174649399937581739718117982417360985958259468485436586733686659771030677664677905401522360041892481951454135360540917411098412286723830672712910603386748136348878056545746112142111116659985782398275627122449414307140749404884060753863706024281031485538666133332835597817514616331728118982180628823657668668099621799842011158020767772792912298768785614574416019320546196793486018677884550715870608004988829978148966980770136884353226949853654541655837029498017031085943660440466076019479435181045436897845351048788440102268677798257134774081674357195358847761226603653040273985441982221318087815835107317571211841215825606453348521097936413520295998260751040778703740366309871999114717441069182825782996299411623087415008910941303284182131584799816210728034255555687956785287887098941927737599159824398527573423117728252839768919145018117995597946282264946523741691180858441194373387098969530126834014923656627849129062189145572870212225909464530919531634090206371146321663797279805760028495288084848179380053931435604182517516600823936737919915974103591167638898871754018470172589234989397051893028574365288890303780239194622538215532212735555299397542845350629361560347195459286729561168235383428930828378887678197590624110372267338756668414899526138480866747114831414687579691636020586013635675559033488649721062244142787960404056961306176022981242840984825421797150393909713884990708008654327558025619074213270714252431515171638994505720144347502185848528129000055629703422695425047209518177577128511315492059613722366724615343968357332924191178041956753132941596322101250417068813977303498033940613791099720174786773844696734034010269139553878212387108508158622839733593634918975616613368243882808391509244806809337882965338701545504691589517650472239580754189547649790038026506707709763098148746524031013800531890876858227360501676161874661946431647929572555992967298553471152693471452480119897608173336753260124452510815333416409357029633265172614203663326409976153102467083379129588112837280711111346490898947808402062401228963194162711657422998429263579276515414000979053740662733816632981508535128518440258006782392288860903823207436820793041881907093791874917635829854808150640894907127600430185202301457398493533111918994100853753771956293430162566011361163168953462188010231819000213669780447856871248564377584509085888797883747538309181810700615032225563091016689474780253412571338625581817921061549352557588323659562675650563535186144754433556539747098322643609542486120512917463706713059064230762924353617972053492527119192658171851345957700772571841998176036269399889012480745075924980479390349332734102774400008120073461540540571051506971003904623484344762005126345905465893817895377928139596549936720100490013375956605889200767596688065961076003472005585890222594655010430123127351665316862663484785966446263740624564875351640780923703006868107440790271682936043304873579648989978571754898840789184480129570446991029504758616393106487523321312507454036808667210073602144290050619610614738139543285649346986393213102456863793665512533655931941790537619020604730601443181250662019687491711547360597117856977240817110039737153355212454745907787131179578656470567535050192702347739653312290522505871612897990429961857550031033665725647987982751868407294730437319505335782425290324427994308374960806684435416445907817107168298342945182985594111281499472495749501642418042734681158560450241309279063816746067016274795461832774699007774423895748677615395848493765672271957278664546343161609126810028254214659633625223934508931691728584028342356669332635458079957147833789501696835781748234884919093574276330354577841975249603899105407104895787598263630679206627796433754045597409176502438867600537016879169914474754840024311922169647388379952802523847080102439285112565751677726373201688403254466789070713575214256192452449029110040537994627424532403620179880056518721219108771374073638118719073211367295514376708596537294204544099903590754371656178656960170217675832153268164591674004500239073743502648099105624548587493544825479270589742494495181223722329693345468639306990523118995640567042531369577131113159027381808071346991604513906450398219426300899204662435492578485666553974492723173859777485412927016068341515517437115137050372750279278548332799193799400154166442801427310076537020119936073495221974791939759846168942055397357348278178050441024490005893818256958665388971201322931680573846084525016332224646866617490832496084991690171583029352609836490908113464668343829985351590552945284372573978295485097950893072423518605982085487154470155025269025854044646496572448495225343096261896378931482883286657508859228868487844184479087538453974144187004884366561256723404772190847586008543961349071131191708943295337664384184532774661503245910257451923515607711559705478132556040197663414911885143697985464807309297002910250505302287769412337441199360424519160716552890882816796378296881641827981453035207233752063518782778493743827708109913493162932182427627261046280168269958077541122668104633712377856 >>> pow(2,15) 32768 >>> pow(2,10) 1024 >>> 3e12 3000000000000.0 >>> 3e-12 3e-12 >>> 3e-1 0.3 >>> 2.12344389584585873054375907454 2.123443895845859 >>> 333+34j (333+34j) >>> a=33452+456j >>> a.real 33452.0 >>> a.imag 456.0 >>> 2**2 4 >>> 2**15 32768 >>> help(abs) Help on built-in function abs in module builtins: abs(x, /) Return the absolute value of the argument. >>> abs("dkjf") Traceback (most recent call last): File " ", line 1, in abs("dkjf") TypeError: bad operand type for abs(): 'str' >>> abs(-123) 123 >>> divmod(12,2) (6, 0) >>> help(divmod) Help on built-in function divmod in module builtins: divmod(x, y, /) Return the tuple (x//y, x%y). Invariant: div*y + mod == x. >>> help(pow) Help on built-in function pow in module builtins: pow(x, y, z=None, /) Equivalent to x**y (with two arguments) or x**y % z (with three arguments) Some types, such as ints, are able to use a more efficient algorithm when invoked using the three argument form. >>> help(round) Help on built-in function round in module builtins: round(...) round(number[, ndigits]) -> number Round a number to a given precision in decimal digits (default 0 digits). This returns an int when called with one argument, otherwise the same type as the number. ndigits may be negative. >>> round(2.3435342,5) 2.34353 >>> help(max) Help on built-in function max in module builtins: max(...) max(iterable, *[, default=obj, key=func]) -> value max(arg1, arg2, *args, *[, key=func]) -> value With a single iterable argument, return its biggest item. The default keyword-only argument specifies an object to return if the provided iterable is empty. With two or more arguments, return the largest argument. >>> import sys >>> help(sys) Help on built-in module sys: NAME sys MODULE REFERENCE https://docs.python.org/3.6/library/sys The following documentation is automatically generated from the Python source files. It may be incomplete, incorrect or include features that are considered implementation detail and may vary between Python implementations. When in doubt, consult the module reference at the location listed above. DESCRIPTION This module provides access to some objects used or maintained by the interpreter and to functions that interact strongly with the interpreter. Dynamic objects: argv -- command line arguments; argv[0] is the script pathname if known path -- module search path; path[0] is the script directory, else '' modules -- dictionary of loaded modules displayhook -- called to show results in an interactive session excepthook -- called to handle any uncaught exception other than SystemExit To customize printing in an interactive session or to install a custom top-level exception handler, assign other functions to replace these. stdin -- standard input file object; used by input() stdout -- standard output file object; used by print() stderr -- standard error object; used for error messages By assigning other file objects (or objects that behave like files) to these, it is possible to redirect all of the interpreter's I/O. last_type -- type of last uncaught exception last_value -- value of last uncaught exception last_traceback -- traceback of last uncaught exception These three are only available in an interactive session after a traceback has been printed. Static objects: builtin_module_names -- tuple of module names built into this interpreter copyright -- copyright notice pertaining to this interpreter exec_prefix -- prefix used to find the machine-specific Python library executable -- absolute path of the executable binary of the Python interpreter float_info -- a struct sequence with information about the float implementation. float_repr_style -- string indicating the style of repr() output for floats hash_info -- a struct sequence with information about the hash algorithm. hexversion -- version information encoded as a single integer implementation -- Python implementation information. int_info -- a struct sequence with information about the int implementation. maxsize -- the largest supported length of containers. maxunicode -- the value of the largest Unicode code point platform -- platform identifier prefix -- prefix used to find the Python library thread_info -- a struct sequence with information about the thread implementation. version -- the version of this interpreter as a string version_info -- version information as a named tuple dllhandle -- [Windows only] integer handle of the Python DLL winver -- [Windows only] version number of the Python DLL _enablelegacywindowsfsencoding -- [Windows only] __stdin__ -- the original stdin; don't touch! __stdout__ -- the original stdout; don't touch! __stderr__ -- the original stderr; don't touch! __displayhook__ -- the original displayhook; don't touch! __excepthook__ -- the original excepthook; don't touch! Functions: displayhook() -- print an object to the screen, and save it in builtins._ excepthook() -- print an exception and its traceback to sys.stderr exc_info() -- return thread-safe information about the current exception exit() -- exit the interpreter by raising SystemExit getdlopenflags() -- returns flags to be used for dlopen() calls getprofile() -- get the global profiling function getrefcount() -- return the reference count for an object (plus one :-) getrecursionlimit() -- return the max recursion depth for the interpreter getsizeof() -- return the size of an object in bytes gettrace() -- get the global debug tracing function setcheckinterval() -- control how often the interpreter checks for events setdlopenflags() -- set the flags to be used for dlopen() calls setprofile() -- set the global profiling function setrecursionlimit() -- set the max recursion depth for the interpreter settrace() -- set the global debug tracing function FUNCTIONS __displayhook__ = displayhook(...) displayhook(object) -> None Print an object to sys.stdout and also save it in builtins._ __excepthook__ = excepthook(...) excepthook(exctype, value, traceback) -> None Handle an exception by displaying it with a traceback on sys.stderr. call_tracing(...) call_tracing(func, args) -> object Call func(*args), while tracing is enabled. The tracing state is saved, and restored afterwards. This is intended to be called from a debugger from a checkpoint, to recursively debug some other code. callstats(...) callstats() -> tuple of integers Return a tuple of function call statistics, if CALL_PROFILE was defined when Python was built. Otherwise, return None. When enabled, this function returns detailed, implementation-specific details about the number of function calls executed. The return value is a 11-tuple where the entries in the tuple are counts of: 0. all function calls 1. calls to PyFunction_Type objects 2. PyFunction calls that do not create an argument tuple 3. PyFunction calls that do not create an argument tuple and bypass PyEval_EvalCodeEx() 4. PyMethod calls 5. PyMethod calls on bound methods 6. PyType calls 7. PyCFunction calls 8. generator calls 9. All other calls 10. Number of stack pops performed by call_function() exc_info(...) exc_info() -> (type, value, traceback) Return information about the most recent exception caught by an except clause in the current stack frame or in an older stack frame. excepthook(...) excepthook(exctype, value, traceback) -> None Handle an exception by displaying it with a traceback on sys.stderr. exit(...) exit([status]) Exit the interpreter by raising SystemExit(status). If the status is omitted or None, it defaults to zero (i.e., success). If the status is an integer, it will be used as the system exit status. If it is another kind of object, it will be printed and the system exit status will be one (i.e., failure). get_asyncgen_hooks(...) get_asyncgen_hooks() Return a namedtuple of installed asynchronous generators hooks (firstiter, finalizer). get_coroutine_wrapper(...) get_coroutine_wrapper() Return the wrapper for coroutine objects set by sys.set_coroutine_wrapper. getallocatedblocks(...) getallocatedblocks() -> integer Return the number of memory blocks currently allocated, regardless of their size. getcheckinterval(...) getcheckinterval() -> current check interval; see setcheckinterval(). getdefaultencoding(...) getdefaultencoding() -> string Return the current default string encoding used by the Unicode implementation. getfilesystemencodeerrors(...) getfilesystemencodeerrors() -> string Return the error mode used to convert Unicode filenames in operating system filenames. getfilesystemencoding(...) getfilesystemencoding() -> string Return the encoding used to convert Unicode filenames in operating system filenames. getprofile(...) getprofile() Return the profiling function set with sys.setprofile. See the profiler chapter in the library manual. getrecursionlimit(...) getrecursionlimit() Return the current value of the recursion limit, the maximum depth of the Python interpreter stack. This limit prevents infinite recursion from causing an overflow of the C stack and crashing Python. getrefcount(...) getrefcount(object) -> integer Return the reference count of object. The count returned is generally one higher than you might expect, because it includes the (temporary) reference as an argument to getrefcount(). getsizeof(...) getsizeof(object, default) -> int Return the size of object in bytes. getswitchinterval(...) getswitchinterval() -> current thread switch interval; see setswitchinterval(). gettrace(...) gettrace() Return the global debug tracing function set with sys.settrace. See the debugger chapter in the library manual. getwindowsversion(...) getwindowsversion() Return information about the running version of Windows as a named tuple. The members are named: major, minor, build, platform, service_pack, service_pack_major, service_pack_minor, suite_mask, and product_type. For backward compatibility, only the first 5 items are available by indexing. All elements are numbers, except service_pack and platform_type which are strings, and platform_version which is a 3-tuple. Platform is always 2. Product_type may be 1 for a workstation, 2 for a domain controller, 3 for a server. Platform_version is a 3-tuple containing a version number that is intended for identifying the OS rather than feature detection. intern(...) intern(string) -> string ``Intern'' the given string. This enters the string in the (global) table of interned strings whose purpose is to speed up dictionary lookups. Return the string itself or the previously interned string object with the same value. is_finalizing(...) is_finalizing() Return True if Python is exiting. set_asyncgen_hooks(...) set_asyncgen_hooks(*, firstiter=None, finalizer=None) Set a finalizer for async generators objects. set_coroutine_wrapper(...) set_coroutine_wrapper(wrapper) Set a wrapper for coroutine objects. setcheckinterval(...) setcheckinterval(n) Tell the Python interpreter to check for asynchronous events every n instructions. This also affects how often thread switches occur. setprofile(...) setprofile(function) Set the profiling function. It will be called on each function call and return. See the profiler chapter in the library manual. setrecursionlimit(...) setrecursionlimit(n) Set the maximum depth of the Python interpreter stack to n. This limit prevents infinite recursion from causing an overflow of the C stack and crashing Python. The highest possible limit is platform- dependent. setswitchinterval(...) setswitchinterval(n) Set the ideal thread switching delay inside the Python interpreter The actual frequency of switching threads can be lower if the interpreter executes long sequences of uninterruptible code (this is implementation-specific and workload-dependent). The parameter must represent the desired switching delay in seconds A typical value is 0.005 (5 milliseconds). settrace(...) settrace(function) Set the global debug tracing function. It will be called on each function call. See the debugger chapter in the library manual. DATA __stderr__ = None __stdin__ = None __stdout__ = None api_version = 1013 argv = [r'F:\U\python\1.py'] base_exec_prefix = r'F:\U\python' base_prefix = r'F:\U\python' builtin_module_names = ('_ast', '_bisect', '_blake2', '_codecs', '_cod... byteorder = 'little' copyright = 'Copyright (c) 2001-2017 Python Software Foundati...ematis... dllhandle = 1398276096 dont_write_bytecode = False exec_prefix = r'F:\U\python' executable = r'F:\U\python\pythonw.exe' flags = sys.flags(debug=0, inspect=0, interactive=0, opt...ing=0, quie... float_info = sys.float_info(max=1.7976931348623157e+308, max_...epsilo... float_repr_style = 'short' hash_info = sys.hash_info(width=32, modulus=2147483647, inf=...iphash2... hexversion = 50725616 implementation = namespace(cache_tag='cpython-36', hexversion=507...in... int_info = sys.int_info(bits_per_digit=15, sizeof_digit=2) last_value = TypeError("bad operand type for abs(): 'str'",) maxsize = 2147483647 maxunicode = 1114111 meta_path = [ , , '_ast': , stdin = stdout = thread_info = sys.thread_info(name='nt', lock=None, version=None) version = '3.6.2 (v3.6.2:5fd33b5, Jul 8 2017, 04:14:34) [MSC v.1900 3... version_info = sys.version_info(major=3, minor=6, micro=2, releaseleve... warnoptions = [] winver = '3.6-32' FILE (built-in) >>> sys.float_info sys.float_info(max=1.7976931348623157e+308, max_exp=1024, max_10_exp=308, min=2.2250738585072014e-308, min_exp=-1021, min_10_exp=-307, dig=15, mant_dig=53, epsilon=2.220446049250313e-16, radix=2, rounds=1) >>> help(max) Help on built-in function max in module builtins: max(...) max(iterable, *[, default=obj, key=func]) -> value max(arg1, arg2, *args, *[, key=func]) -> value With a single iterable argument, return its biggest item. The default keyword-only argument specifies an object to return if the provided iterable is empty. With two or more arguments, return the largest argument. >>> max(34,345,456,34545,45,) 34545 >>> -------------
11/02
Python 3.6.2 (v3.6.2:5fd33b5, Jul 8 2017, 04:14:34) [MSC v.1900 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. >>> import math >>> math.pi 3.141592653589793 >>> math.e 2.718281828459045 >>> math.inf inf >>> -math.inf -inf >>> math.nan nan >>> help(help) Help on _Helper in module _sitebuiltins object: class _Helper(builtins.object) | Define the builtin 'help'. | | This is a wrapper around pydoc.help that provides a helpful message | when 'help' is typed at the Python interactive prompt. | | Calling help() at the Python prompt starts an interactive help session. | Calling help(thing) prints help for the python object 'thing'. | | Methods defined here: | | __call__(self, *args, **kwds) | Call self as a function. | | __repr__(self) | Return repr(self). | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) >>> help(math) Help on built-in module math: NAME math DESCRIPTION This module is always available. It provides access to the mathematical functions defined by the C standard. FUNCTIONS acos(...) acos(x) Return the arc cosine (measured in radians) of x. acosh(...) acosh(x) Return the inverse hyperbolic cosine of x. asin(...) asin(x) Return the arc sine (measured in radians) of x. asinh(...) asinh(x) Return the inverse hyperbolic sine of x. atan(...) atan(x) Return the arc tangent (measured in radians) of x. atan2(...) atan2(y, x) Return the arc tangent (measured in radians) of y/x. Unlike atan(y/x), the signs of both x and y are considered. atanh(...) atanh(x) Return the inverse hyperbolic tangent of x. ceil(...) ceil(x) Return the ceiling of x as an Integral. This is the smallest integer >= x. copysign(...) copysign(x, y) Return a float with the magnitude (absolute value) of x but the sign of y. On platforms that support signed zeros, copysign(1.0, -0.0) returns -1.0. cos(...) cos(x) Return the cosine of x (measured in radians). cosh(...) cosh(x) Return the hyperbolic cosine of x. degrees(...) degrees(x) Convert angle x from radians to degrees. erf(...) erf(x) Error function at x. erfc(...) erfc(x) Complementary error function at x. exp(...) exp(x) Return e raised to the power of x. expm1(...) expm1(x) Return exp(x)-1. This function avoids the loss of precision involved in the direct evaluation of exp(x)-1 for small x. fabs(...) fabs(x) Return the absolute value of the float x. factorial(...) factorial(x) -> Integral Find x!. Raise a ValueError if x is negative or non-integral. floor(...) floor(x) Return the floor of x as an Integral. This is the largest integer <= x. fmod(...) fmod(x, y) Return fmod(x, y), according to platform C. x % y may differ. frexp(...) frexp(x) Return the mantissa and exponent of x, as pair (m, e). m is a float and e is an int, such that x = m * 2.**e. If x is 0, m and e are both 0. Else 0.5 <= abs(m) < 1.0. fsum(...) fsum(iterable) Return an accurate floating point sum of values in the iterable. Assumes IEEE-754 floating point arithmetic. gamma(...) gamma(x) Gamma function at x. gcd(...) gcd(x, y) -> int greatest common divisor of x and y hypot(...) hypot(x, y) Return the Euclidean distance, sqrt(x*x + y*y). isclose(...) isclose(a, b, *, rel_tol=1e-09, abs_tol=0.0) -> bool Determine whether two floating point numbers are close in value. rel_tol maximum difference for being considered "close", relative to the magnitude of the input values abs_tol maximum difference for being considered "close", regardless of the magnitude of the input values Return True if a is close in value to b, and False otherwise. For the values to be considered close, the difference between them must be smaller than at least one of the tolerances. -inf, inf and NaN behave similarly to the IEEE 754 Standard. That is, NaN is not close to anything, even itself. inf and -inf are only close to themselves. isfinite(...) isfinite(x) -> bool Return True if x is neither an infinity nor a NaN, and False otherwise. isinf(...) isinf(x) -> bool Return True if x is a positive or negative infinity, and False otherwise. isnan(...) isnan(x) -> bool Return True if x is a NaN (not a number), and False otherwise. ldexp(...) ldexp(x, i) Return x * (2**i). lgamma(...) lgamma(x) Natural logarithm of absolute value of Gamma function at x. log(...) log(x[, base]) Return the logarithm of x to the given base. If the base not specified, returns the natural logarithm (base e) of x. log10(...) log10(x) Return the base 10 logarithm of x. log1p(...) log1p(x) Return the natural logarithm of 1+x (base e). The result is computed in a way which is accurate for x near zero. log2(...) log2(x) Return the base 2 logarithm of x. modf(...) modf(x) Return the fractional and integer parts of x. Both results carry the sign of x and are floats. pow(...) pow(x, y) Return x**y (x to the power of y). radians(...) radians(x) Convert angle x from degrees to radians. sin(...) sin(x) Return the sine of x (measured in radians). sinh(...) sinh(x) Return the hyperbolic sine of x. sqrt(...) sqrt(x) Return the square root of x. tan(...) tan(x) Return the tangent of x (measured in radians). tanh(...) tanh(x) Return the hyperbolic tangent of x. trunc(...) trunc(x:Real) -> Integral Truncates x to the nearest Integral toward 0. Uses the __trunc__ magic method. DATA e = 2.718281828459045 inf = inf nan = nan pi = 3.141592653589793 tau = 6.283185307179586 FILE (built-in) >>> help(math.e) Help on float object: class float(object) | float(x) -> floating point number | | Convert a string or number to a floating point number, if possible. | | Methods defined here: | | __abs__(self, /) | abs(self) | | __add__(self, value, /) | Return self+value. | | __bool__(self, /) | self != 0 | | __divmod__(self, value, /) | Return divmod(self, value). | | __eq__(self, value, /) | Return self==value. | | __float__(self, /) | float(self) | | __floordiv__(self, value, /) | Return self//value. | | __format__(...) | float.__format__(format_spec) -> string | | Formats the float according to format_spec. | | __ge__(self, value, /) | Return self>=value. | | __getattribute__(self, name, /) | Return getattr(self, name). | | __getformat__(...) from builtins.type | float.__getformat__(typestr) -> string | | You probably don't want to use this function. It exists mainly to be | used in Python's test suite. | | typestr must be 'double' or 'float'. This function returns whichever of | 'unknown', 'IEEE, big-endian' or 'IEEE, little-endian' best describes the | format of floating point numbers used by the C type named by typestr. | | __getnewargs__(...) | | __gt__(self, value, /) | Return self>value. | | __hash__(self, /) | Return hash(self). | | __int__(self, /) | int(self) | | __le__(self, value, /) | Return self<=value. | | __lt__(self, value, /) | Return self
None | | You probably don't want to use this function. It exists mainly to be | used in Python's test suite. | | typestr must be 'double' or 'float'. fmt must be one of 'unknown', | 'IEEE, big-endian' or 'IEEE, little-endian', and in addition can only be | one of the latter two if it appears to match the underlying C reality. | | Override the automatic determination of C-level floating point type. | This affects how floats are converted to and from binary strings. | | __str__(self, /) | Return str(self). | | __sub__(self, value, /) | Return self-value. | | __truediv__(self, value, /) | Return self/value. | | __trunc__(...) | Return the Integral closest to x between 0 and x. | | as_integer_ratio(...) | float.as_integer_ratio() -> (int, int) | | Return a pair of integers, whose ratio is exactly equal to the original | float and with a positive denominator. | Raise OverflowError on infinities and a ValueError on NaNs. | | >>> (10.0).as_integer_ratio() | (10, 1) | >>> (0.0).as_integer_ratio() | (0, 1) | >>> (-.25).as_integer_ratio() | (-1, 4) | | conjugate(...) | Return self, the complex conjugate of any float. | | fromhex(...) from builtins.type | float.fromhex(string) -> float | | Create a floating-point number from a hexadecimal string. | >>> float.fromhex('0x1.ffffp10') | 2047.984375 | >>> float.fromhex('-0x1p-1074') | -5e-324 | | hex(...) | float.hex() -> string | | Return a hexadecimal representation of a floating-point number. | >>> (-0.1).hex() | '-0x1.999999999999ap-4' | >>> 3.14159.hex() | '0x1.921f9f01b866ep+1' | | is_integer(...) | Return True if the float is an integer. | | ---------------------------------------------------------------------- | Data descriptors defined here: | | imag | the imaginary part of a complex number | | real | the real part of a complex number >>> math.fabs(-234) 234.0 >>> math.ceil (23.4) 24 >>> math.floor(23.4) 23 >>> math.factorial(-2) Traceback (most recent call last): File " ", line 1, in math.factorial(-2) ValueError: factorial() not defined for negative values >>> math.factorial(66) 544344939077443064003729240247842752644293064388798874532860126869671081148416000000000000000 >>> help(math.gcd()) Traceback (most recent call last): File " ", line 1, in help(math.gcd()) TypeError: gcd() takes exactly 2 arguments (0 given) >>> help(math.gcd) Help on built-in function gcd in module math: gcd(...) gcd(x, y) -> int greatest common divisor of x and y >>> help(gcd) Traceback (most recent call last): File " ", line 1, in help(gcd) NameError: name 'gcd' is not defined >>> help(math.ceil) Help on built-in function ceil in module math: ceil(...) ceil(x) Return the ceiling of x as an Integral. This is the smallest integer >= x. >>> help(frexp(x)) Traceback (most recent call last): File " ", line 1, in help(frexp(x)) NameError: name 'frexp' is not defined >>> help(math.frexp()) Traceback (most recent call last): File " ", line 1, in help(math.frexp()) TypeError: frexp() takes exactly one argument (0 given) >>> help(math.frexp) Help on built-in function frexp in module math: frexp(...) frexp(x) Return the mantissa and exponent of x, as pair (m, e). m is a float and e is an int, such that x = m * 2.**e. If x is 0, m and e are both 0. Else 0.5 <= abs(m) < 1.0. >>> help(abs) Help on built-in function abs in module builtins: abs(x, /) Return the absolute value of the argument. >>> help(math.fabs) Help on built-in function fabs in module math: fabs(...) fabs(x) Return the absolute value of the float x. >>> help(math.isnan) Help on built-in function isnan in module math: isnan(...) isnan(x) -> bool Return True if x is a NaN (not a number), and False otherwise. >>> math.isnan(void) Traceback (most recent call last): File " ", line 1, in math.isnan(void) NameError: name 'void' is not defined >>> math.isnan(EOF) Traceback (most recent call last): File " ", line 1, in math.isnan(EOF) NameError: name 'EOF' is not defined >>> math.nan(3) Traceback (most recent call last): File " ", line 1, in math.nan(3) TypeError: 'float' object is not callable >>> math.isnan(3) False >>> math.fsum(0.34,0.33234) Traceback (most recent call last): File " ", line 1, in math.fsum(0.34,0.33234) TypeError: fsum() takes exactly one argument (2 given) >>> Python 3.6.2 (v3.6.2:5fd33b5, Jul 8 2017, 04:14:34) [MSC v.1900 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import math
>>> math.pi
3.141592653589793
>>> math.e
2.718281828459045
>>> math.inf
inf
>>> -math.inf
-inf
>>> math.nan
nan
>>> help(help)
Help on _Helper in module _sitebuiltins object:class _Helper(builtins.object)
| Define the builtin 'help'.
|
| This is a wrapper around pydoc.help that provides a helpful message
| when 'help' is typed at the Python interactive prompt.
|
| Calling help() at the Python prompt starts an interactive help session.
| Calling help(thing) prints help for the python object 'thing'.
|
| Methods defined here:
|
| __call__(self, *args, **kwds)
| Call self as a function.
|
| __repr__(self)
| Return repr(self).
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables (if defined)
|
| __weakref__
| list of weak references to the object (if defined)>>> help(math)
Help on built-in module math:NAME
mathDESCRIPTION
This module is always available. It provides access to the
mathematical functions defined by the C standard.FUNCTIONS
acos(...)
acos(x)
Return the arc cosine (measured in radians) of x.
acosh(...)
acosh(x)
Return the inverse hyperbolic cosine of x.
asin(...)
asin(x)
Return the arc sine (measured in radians) of x.
asinh(...)
asinh(x)
Return the inverse hyperbolic sine of x.
atan(...)
atan(x)
Return the arc tangent (measured in radians) of x.
atan2(...)
atan2(y, x)
Return the arc tangent (measured in radians) of y/x.
Unlike atan(y/x), the signs of both x and y are considered.
atanh(...)
atanh(x)
Return the inverse hyperbolic tangent of x.
ceil(...)
ceil(x)
Return the ceiling of x as an Integral.
This is the smallest integer >= x.
copysign(...)
copysign(x, y)
Return a float with the magnitude (absolute value) of x but the sign
of y. On platforms that support signed zeros, copysign(1.0, -0.0)
returns -1.0.
cos(...)
cos(x)
Return the cosine of x (measured in radians).
cosh(...)
cosh(x)
Return the hyperbolic cosine of x.
degrees(...)
degrees(x)
Convert angle x from radians to degrees.
erf(...)
erf(x)
Error function at x.
erfc(...)
erfc(x)
Complementary error function at x.
exp(...)
exp(x)
Return e raised to the power of x.
expm1(...)
expm1(x)
Return exp(x)-1.
This function avoids the loss of precision involved in the direct evaluation of exp(x)-1 for small x.
fabs(...)
fabs(x)
Return the absolute value of the float x.
factorial(...)
factorial(x) -> Integral
Find x!. Raise a ValueError if x is negative or non-integral.
floor(...)
floor(x)
Return the floor of x as an Integral.
This is the largest integer <= x.
fmod(...)
fmod(x, y)
Return fmod(x, y), according to platform C. x % y may differ.
frexp(...)
frexp(x)
Return the mantissa and exponent of x, as pair (m, e).
m is a float and e is an int, such that x = m * 2.**e.
If x is 0, m and e are both 0. Else 0.5 <= abs(m) < 1.0.
fsum(...)
fsum(iterable)
Return an accurate floating point sum of values in the iterable.
Assumes IEEE-754 floating point arithmetic.
gamma(...)
gamma(x)
Gamma function at x.
gcd(...)
gcd(x, y) -> int
greatest common divisor of x and y
hypot(...)
hypot(x, y)
Return the Euclidean distance, sqrt(x*x + y*y).
isclose(...)
isclose(a, b, *, rel_tol=1e-09, abs_tol=0.0) -> bool
Determine whether two floating point numbers are close in value.
rel_tol
maximum difference for being considered "close", relative to the
magnitude of the input values
abs_tol
maximum difference for being considered "close", regardless of the
magnitude of the input values
Return True if a is close in value to b, and False otherwise.
For the values to be considered close, the difference between them
must be smaller than at least one of the tolerances.
-inf, inf and NaN behave similarly to the IEEE 754 Standard. That
is, NaN is not close to anything, even itself. inf and -inf are
only close to themselves.
isfinite(...)
isfinite(x) -> bool
Return True if x is neither an infinity nor a NaN, and False otherwise.
isinf(...)
isinf(x) -> bool
Return True if x is a positive or negative infinity, and False otherwise.
isnan(...)
isnan(x) -> bool
Return True if x is a NaN (not a number), and False otherwise.
ldexp(...)
ldexp(x, i)
Return x * (2**i).
lgamma(...)
lgamma(x)
Natural logarithm of absolute value of Gamma function at x.
log(...)
log(x[, base])
Return the logarithm of x to the given base.
If the base not specified, returns the natural logarithm (base e) of x.
log10(...)
log10(x)
Return the base 10 logarithm of x.
log1p(...)
log1p(x)
Return the natural logarithm of 1+x (base e).
The result is computed in a way which is accurate for x near zero.
log2(...)
log2(x)
Return the base 2 logarithm of x.
modf(...)
modf(x)
Return the fractional and integer parts of x. Both results carry the sign
of x and are floats.
pow(...)
pow(x, y)
Return x**y (x to the power of y).
radians(...)
radians(x)
Convert angle x from degrees to radians.
sin(...)
sin(x)
Return the sine of x (measured in radians).
sinh(...)
sinh(x)
Return the hyperbolic sine of x.
sqrt(...)
sqrt(x)
Return the square root of x.
tan(...)
tan(x)
Return the tangent of x (measured in radians).
tanh(...)
tanh(x)
Return the hyperbolic tangent of x.
trunc(...)
trunc(x:Real) -> Integral
Truncates x to the nearest Integral toward 0. Uses the __trunc__ magic method.DATA
e = 2.718281828459045
inf = inf
nan = nan
pi = 3.141592653589793
tau = 6.283185307179586FILE
(built-in)
>>> help(math.e)
Help on float object:class float(object)
| float(x) -> floating point number
|
| Convert a string or number to a floating point number, if possible.
|
| Methods defined here:
|
| __abs__(self, /)
| abs(self)
|
| __add__(self, value, /)
| Return self+value.
|
| __bool__(self, /)
| self != 0
|
| __divmod__(self, value, /)
| Return divmod(self, value).
|
| __eq__(self, value, /)
| Return self==value.
|
| __float__(self, /)
| float(self)
|
| __floordiv__(self, value, /)
| Return self//value.
|
| __format__(...)
| float.__format__(format_spec) -> string
|
| Formats the float according to format_spec.
|
| __ge__(self, value, /)
| Return self>=value.
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __getformat__(...) from builtins.type
| float.__getformat__(typestr) -> string
|
| You probably don't want to use this function. It exists mainly to be
| used in Python's test suite.
|
| typestr must be 'double' or 'float'. This function returns whichever of
| 'unknown', 'IEEE, big-endian' or 'IEEE, little-endian' best describes the
| format of floating point numbers used by the C type named by typestr.
|
| __getnewargs__(...)
|
| __gt__(self, value, /)
| Return self>value.
|
| __hash__(self, /)
| Return hash(self).
|
| __int__(self, /)
| int(self)
|
| __le__(self, value, /)
| Return self<=value.
|
| __lt__(self, value, /)
| Return self|
| __mod__(self, value, /)
| Return self%value.
|
| __mul__(self, value, /)
| Return self*value.
|
| __ne__(self, value, /)
| Return self!=value.
|
| __neg__(self, /)
| -self
|
| __new__(*args, **kwargs) from builtins.type
| Create and return a new object. See help(type) for accurate signature.
|
| __pos__(self, /)
| +self
|
| __pow__(self, value, mod=None, /)
| Return pow(self, value, mod).
|
| __radd__(self, value, /)
| Return value+self.
|
| __rdivmod__(self, value, /)
| Return divmod(value, self).
|
| __repr__(self, /)
| Return repr(self).
|
| __rfloordiv__(self, value, /)
| Return value//self.
|
| __rmod__(self, value, /)
| Return value%self.
|
| __rmul__(self, value, /)
| Return value*self.
|
| __round__(...)
| Return the Integral closest to x, rounding half toward even.
| When an argument is passed, work like built-in round(x, ndigits).
|
| __rpow__(self, value, mod=None, /)
| Return pow(value, self, mod).
|
| __rsub__(self, value, /)
| Return value-self.
|
| __rtruediv__(self, value, /)
| Return value/self.
|
| __setformat__(...) from builtins.type
| float.__setformat__(typestr, fmt) -> None
|
| You probably don't want to use this function. It exists mainly to be
| used in Python's test suite.
|
| typestr must be 'double' or 'float'. fmt must be one of 'unknown',
| 'IEEE, big-endian' or 'IEEE, little-endian', and in addition can only be
| one of the latter two if it appears to match the underlying C reality.
|
| Override the automatic determination of C-level floating point type.
| This affects how floats are converted to and from binary strings.
|
| __str__(self, /)
| Return str(self).
|
| __sub__(self, value, /)
| Return self-value.
|
| __truediv__(self, value, /)
| Return self/value.
|
| __trunc__(...)
| Return the Integral closest to x between 0 and x.
|
| as_integer_ratio(...)
| float.as_integer_ratio() -> (int, int)
|
| Return a pair of integers, whose ratio is exactly equal to the original
| float and with a positive denominator.
| Raise OverflowError on infinities and a ValueError on NaNs.
|
| >>> (10.0).as_integer_ratio()
| (10, 1)
| >>> (0.0).as_integer_ratio()
| (0, 1)
| >>> (-.25).as_integer_ratio()
| (-1, 4)
|
| conjugate(...)
| Return self, the complex conjugate of any float.
|
| fromhex(...) from builtins.type
| float.fromhex(string) -> float
|
| Create a floating-point number from a hexadecimal string.
| >>> float.fromhex('0x1.ffffp10')
| 2047.984375
| >>> float.fromhex('-0x1p-1074')
| -5e-324
|
| hex(...)
| float.hex() -> string
|
| Return a hexadecimal representation of a floating-point number.
| >>> (-0.1).hex()
| '-0x1.999999999999ap-4'
| >>> 3.14159.hex()
| '0x1.921f9f01b866ep+1'
|
| is_integer(...)
| Return True if the float is an integer.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| imag
| the imaginary part of a complex number
|
| real
| the real part of a complex number>>> math.fabs(-234)
234.0
>>> math.ceil (23.4)
24
>>> math.floor(23.4)
23
>>> math.factorial(-2)
Traceback (most recent call last):
File "", line 1, in
math.factorial(-2)
ValueError: factorial() not defined for negative values
>>> math.factorial(66)
544344939077443064003729240247842752644293064388798874532860126869671081148416000000000000000
>>> help(math.gcd())
Traceback (most recent call last):
File "", line 1, in
help(math.gcd())
TypeError: gcd() takes exactly 2 arguments (0 given)
>>> help(math.gcd)
Help on built-in function gcd in module math:gcd(...)
gcd(x, y) -> int
greatest common divisor of x and y>>> help(gcd)
Traceback (most recent call last):
File "", line 1, in
help(gcd)
NameError: name 'gcd' is not defined
>>> help(math.ceil)
Help on built-in function ceil in module math:ceil(...)
ceil(x)
Return the ceiling of x as an Integral.
This is the smallest integer >= x.>>> help(frexp(x))
Traceback (most recent call last):
File "", line 1, in
help(frexp(x))
NameError: name 'frexp' is not defined
>>> help(math.frexp())
Traceback (most recent call last):
File "", line 1, in
help(math.frexp())
TypeError: frexp() takes exactly one argument (0 given)
>>> help(math.frexp)
Help on built-in function frexp in module math:frexp(...)
frexp(x)
Return the mantissa and exponent of x, as pair (m, e).
m is a float and e is an int, such that x = m * 2.**e.
If x is 0, m and e are both 0. Else 0.5 <= abs(m) < 1.0.>>> help(abs)
Help on built-in function abs in module builtins:abs(x, /)
Return the absolute value of the argument.>>> help(math.fabs)
Help on built-in function fabs in module math:fabs(...)
fabs(x)
Return the absolute value of the float x.>>> help(math.isnan)
Help on built-in function isnan in module math:isnan(...)
isnan(x) -> bool
Return True if x is a NaN (not a number), and False otherwise.>>> math.isnan(void)
Traceback (most recent call last):
File "", line 1, in
math.isnan(void)
NameError: name 'void' is not defined
>>> math.isnan(EOF)
Traceback (most recent call last):
File "", line 1, in
math.isnan(EOF)
NameError: name 'EOF' is not defined
>>> math.nan(3)
Traceback (most recent call last):
File "", line 1, in
math.nan(3)
TypeError: 'float' object is not callable
>>> math.isnan(3)
False
>>> math.fsum(0.34,0.33234)
Traceback (most recent call last):
File "", line 1, in
math.fsum(0.34,0.33234)
TypeError: fsum() takes exactly one argument (2 given)
>>>----------------
Python 3.6.2 (v3.6.2:5fd33b5, Jul 8 2017, 04:14:34) [MSC v.1900 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import math
>>> math.pow(3,3)
27.0
>>> help(math.pow)
Help on built-in function pow in module math:pow(...)
pow(x, y)
Return x**y (x to the power of y).>>> help(pow)
Help on built-in function pow in module builtins:pow(x, y, z=None, /)
Equivalent to x**y (with two arguments) or x**y % z (with three arguments)
Some types, such as ints, are able to use a more efficient algorithm when
invoked using the three argument form.>>> print('''dhfjhfjdsh"kjddhjfh'jdff'kf"''')
dhfjhfjdsh"kjddhjfh'jdff'kf"
>>> print("\n")
>>> print("sjfkj")
sjfkj
>>> print("dkfhhf
SyntaxError: EOL while scanning string literal
>>> name="dkjfj"
>>> print(name)
dkjfj
>>> name="dhkihello,hey"
>>> print(name)
dhkihello,hey
>>> name[0]
'd'
>>> name[9]
','
>>> name[-1]
'y'
>>> name[1:-7]
'hkihe'
>>> name[1,4]
Traceback (most recent call last):
File "", line 1, in
name[1,4]
TypeError: string indices must be integers
>>> input("shu,qu\n ok")
shu,qu
okk
'k'
>>> name[:]
'dhkihello,hey'
>>> name[:-2]
'dhkihello,h'
>>> name[:-1]
'dhkihello,he'
>>> "dkhffjfkf"
'dkhffjfkf'
>>> "djfhfd\a"
'djfhfd\x07'
>>> "kdjflkjfkjsdjfjfd\bdkj\t"
'kdjflkjfkjsdjfjfd\x08dkj\t'
>>>Python 3.6.2 (v3.6.2:5fd33b5, Jul 8 2017, 04:14:34) [MSC v.1900 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. >>> import math >>> math.pow(3,3) 27.0 >>> help(math.pow) Help on built-in function pow in module math: pow(...) pow(x, y) Return x**y (x to the power of y). >>> help(pow) Help on built-in function pow in module builtins: pow(x, y, z=None, /) Equivalent to x**y (with two arguments) or x**y % z (with three arguments) Some types, such as ints, are able to use a more efficient algorithm when invoked using the three argument form. >>> print('''dhfjhfjdsh"kjddhjfh'jdff'kf"''') dhfjhfjdsh"kjddhjfh'jdff'kf" >>> print("\n") >>> print("sjfkj") sjfkj >>> print("dkfhhf SyntaxError: EOL while scanning string literal >>> name="dkjfj" >>> print(name) dkjfj >>> name="dhkihello,hey" >>> print(name) dhkihello,hey >>> name[0] 'd' >>> name[9] ',' >>> name[-1] 'y' >>> name[1:-7] 'hkihe' >>> name[1,4] Traceback (most recent call last): File "
", line 1, in name[1,4] TypeError: string indices must be integers >>> input("shu,qu\n ok") shu,qu okk 'k' >>> name[:] 'dhkihello,hey' >>> name[:-2] 'dhkihello,h' >>> name[:-1] 'dhkihello,he' >>> "dkhffjfkf" 'dkhffjfkf' >>> "djfhfd\a" 'djfhfd\x07' >>> "kdjflkjfkjsdjfjfd\bdkj\t" 'kdjflkjfkjsdjfjfd\x08dkj\t' >>> -----------------------
11/03
Python 3.6.2 (v3.6.2:5fd33b5, Jul 8 2017, 04:14:34) [MSC v.1900 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. >>> python Traceback (most recent call last): File "
", line 1, in python NameError: name 'python' is not defined >>> help(format) Help on built-in function format in module builtins: format(value, format_spec='', /) Return value.__format__(format_spec) format_spec defaults to the empty string >>> s="hey i'm ok" >>> "{0:30}".format(s) "hey i'm ok " >>> s "hey i'm ok" >>> "{0:>30}".format(s) " hey i'm ok" >>> "{0:*^30}".format(s) "**********hey i'm ok**********" >>> "{0:?^34}".format(37858634723784) '??????????37858634723784??????????' >>> "{0:?^34,}".format(37858634723784) '????????37,858,634,723,784????????' >>> "{0:.4}".format(s) 'hey ' >>> import time >>> help(time) Help on built-in module time: NAME time - This module provides various functions to manipulate time values. DESCRIPTION There are two standard representations of time. One is the number of seconds since the Epoch, in UTC (a.k.a. GMT). It may be an integer or a floating point number (to represent fractions of seconds). The Epoch is system-defined; on Unix, it is generally January 1st, 1970. The actual value can be retrieved by calling gmtime(0). The other representation is a tuple of 9 integers giving local time. The tuple items are: year (including century, e.g. 1998) month (1-12) day (1-31) hours (0-23) minutes (0-59) seconds (0-59) weekday (0-6, Monday is 0) Julian day (day in the year, 1-366) DST (Daylight Savings Time) flag (-1, 0 or 1) If the DST flag is 0, the time is given in the regular time zone; if it is 1, the time is given in the DST time zone; if it is -1, mktime() should guess based on the date and time. Variables: timezone -- difference in seconds between UTC and local standard time altzone -- difference in seconds between UTC and local DST time daylight -- whether local time should reflect DST tzname -- tuple of (standard time zone name, DST time zone name) Functions: time() -- return current time in seconds since the Epoch as a float clock() -- return CPU time since process start as a float sleep() -- delay for a number of seconds given as a float gmtime() -- convert seconds since Epoch to UTC tuple localtime() -- convert seconds since Epoch to local time tuple asctime() -- convert time tuple to string ctime() -- convert time in seconds to string mktime() -- convert local time tuple to seconds since Epoch strftime() -- convert time tuple to string according to format specification strptime() -- parse string to time tuple according to format specification tzset() -- change the local timezone CLASSES builtins.tuple(builtins.object) struct_time class struct_time(builtins.tuple) | The time value as returned by gmtime(), localtime(), and strptime(), and | accepted by asctime(), mktime() and strftime(). May be considered as a | sequence of 9 integers. | | Note that several fields' values are not the same as those defined by | the C language standard for struct tm. For example, the value of the | field tm_year is the actual year, not year - 1900. See individual | fields' descriptions for details. | | Method resolution order: | struct_time | builtins.tuple | builtins.object | | Methods defined here: | | __new__(*args, **kwargs) from builtins.type | Create and return a new object. See help(type) for accurate signature. | | __reduce__(...) | helper for pickle | | __repr__(self, /) | Return repr(self). | | ---------------------------------------------------------------------- | Data descriptors defined here: | | tm_gmtoff | offset from UTC in seconds | | tm_hour | hours, range [0, 23] | | tm_isdst | 1 if summer time is in effect, 0 if not, and -1 if unknown | | tm_mday | day of month, range [1, 31] | | tm_min | minutes, range [0, 59] | | tm_mon | month of year, range [1, 12] | | tm_sec | seconds, range [0, 61]) | | tm_wday | day of week, range [0, 6], Monday is 0 | | tm_yday | day of year, range [1, 366] | | tm_year | year, for example, 1993 | | tm_zone | abbreviation of timezone name | | ---------------------------------------------------------------------- | Data and other attributes defined here: | | n_fields = 11 | | n_sequence_fields = 9 | | n_unnamed_fields = 0 | | ---------------------------------------------------------------------- | Methods inherited from builtins.tuple: | | __add__(self, value, /) | Return self+value. | | __contains__(self, key, /) | Return key in self. | | __eq__(self, value, /) | Return self==value. | | __ge__(self, value, /) | Return self>=value. | | __getattribute__(self, name, /) | Return getattr(self, name). | | __getitem__(self, key, /) | Return self[key]. | | __getnewargs__(...) | | __gt__(self, value, /) | Return self>value. | | __hash__(self, /) | Return hash(self). | | __iter__(self, /) | Implement iter(self). | | __le__(self, value, /) | Return self<=value. | | __len__(self, /) | Return len(self). | | __lt__(self, value, /) | Return self integer -- return number of occurrences of value | | index(...) | T.index(value, [start, [stop]]) -> integer -- return first index of value. | Raises ValueError if the value is not present. FUNCTIONS asctime(...) asctime([tuple]) -> string Convert a time tuple to a string, e.g. 'Sat Jun 06 16:26:11 1998'. When the time tuple is not present, current time as returned by localtime() is used. clock(...) clock() -> floating point number Return the CPU time or real time since the start of the process or since the first call to clock(). This has as much precision as the system records. ctime(...) ctime(seconds) -> string Convert a time in seconds since the Epoch to a string in local time. This is equivalent to asctime(localtime(seconds)). When the time tuple is not present, current time as returned by localtime() is used. get_clock_info(...) get_clock_info(name: str) -> dict Get information of the specified clock. gmtime(...) gmtime([seconds]) -> (tm_year, tm_mon, tm_mday, tm_hour, tm_min, tm_sec, tm_wday, tm_yday, tm_isdst) Convert seconds since the Epoch to a time tuple expressing UTC (a.k.a. GMT). When 'seconds' is not passed in, convert the current time instead. If the platform supports the tm_gmtoff and tm_zone, they are available as attributes only. localtime(...) localtime([seconds]) -> (tm_year,tm_mon,tm_mday,tm_hour,tm_min, tm_sec,tm_wday,tm_yday,tm_isdst) Convert seconds since the Epoch to a time tuple expressing local time. When 'seconds' is not passed in, convert the current time instead. mktime(...) mktime(tuple) -> floating point number Convert a time tuple in local time to seconds since the Epoch. Note that mktime(gmtime(0)) will not generally return zero for most time zones; instead the returned value will either be equal to that of the timezone or altzone attributes on the time module. monotonic(...) monotonic() -> float Monotonic clock, cannot go backward. perf_counter(...) perf_counter() -> float Performance counter for benchmarking. process_time(...) process_time() -> float Process time for profiling: sum of the kernel and user-space CPU time. sleep(...) sleep(seconds) Delay execution for a given number of seconds. The argument may be a floating point number for subsecond precision. strftime(...) strftime(format[, tuple]) -> string Convert a time tuple to a string according to a format specification. See the library reference manual for formatting codes. When the time tuple is not present, current time as returned by localtime() is used. Commonly used format codes: %Y Year with century as a decimal number. %m Month as a decimal number [01,12]. %d Day of the month as a decimal number [01,31]. %H Hour (24-hour clock) as a decimal number [00,23]. %M Minute as a decimal number [00,59]. %S Second as a decimal number [00,61]. %z Time zone offset from UTC. %a Locale's abbreviated weekday name. %A Locale's full weekday name. %b Locale's abbreviated month name. %B Locale's full month name. %c Locale's appropriate date and time representation. %I Hour (12-hour clock) as a decimal number [01,12]. %p Locale's equivalent of either AM or PM. Other codes may be available on your platform. See documentation for the C library strftime function. strptime(...) strptime(string, format) -> struct_time Parse a string to a time tuple according to a format specification. See the library reference manual for formatting codes (same as strftime()). Commonly used format codes: %Y Year with century as a decimal number. %m Month as a decimal number [01,12]. %d Day of the month as a decimal number [01,31]. %H Hour (24-hour clock) as a decimal number [00,23]. %M Minute as a decimal number [00,59]. %S Second as a decimal number [00,61]. %z Time zone offset from UTC. %a Locale's abbreviated weekday name. %A Locale's full weekday name. %b Locale's abbreviated month name. %B Locale's full month name. %c Locale's appropriate date and time representation. %I Hour (12-hour clock) as a decimal number [01,12]. %p Locale's equivalent of either AM or PM. Other codes may be available on your platform. See documentation for the C library strftime function. time(...) time() -> floating point number Return the current time in seconds since the Epoch. Fractions of a second may be present if the system clock provides them. DATA altzone = -32400 daylight = 0 timezone = -28800 tzname = ('China Standard Time', 'China Standard Time') FILE (built-in) >>> help(sleep) Traceback (most recent call last): File " ", line 1, in help(sleep) NameError: name 'sleep' is not defined >>> help(time.sleep) Help on built-in function sleep in module time: sleep(...) sleep(seconds) Delay execution for a given number of seconds. The argument may be a floating point number for subsecond precision. >>> help(scale) Traceback (most recent call last): File " ", line 1, in help(scale) NameError: name 'scale' is not defined >>> help(time.scale) Traceback (most recent call last): File " ", line 1, in help(time.scale) AttributeError: module 'time' has no attribute 'scale' >>> help(scale) Traceback (most recent call last): File " ", line 1, in help(scale) NameError: name 'scale' is not defined >>> ================================================================================================================================================================================================================================================================================================================================================================================================ RESTART: F:/U/python/tiem.py ================================================================================================================================================================================================================================================================================================================================================================================================ --------begin execute------ % 0.000000 [->....................] % 10.000000 [**->..................] % 20.000000 [****->................] % 30.000000 [******->..............] % 40.000000 [********->............] % 50.000000 [**********->..........] % 60.000000 [************->........] % 70.000000 [**************->......] % 80.000000 [****************->....] % 90.000000 [******************->..] % 100.000000 [********************->] -----it's over----- >>> ================================================================================================================================================================================================================================================================================================================================================================================================ RESTART: F:/U/python/tiem.py ================================================================================================================================================================================================================================================================================================================================================================================================ --------begin execute------ % 0 [->....................] %10 [**->..................] %20 [****->................] %30 [******->..............] %40 [********->............] %50 [**********->..........] %60 [************->........] %70 [**************->......] %80 [****************->....] %90 [******************->..] %100[********************->] -----it's over----- >>> ================================================================================================================================================================================================================================================================================================================================================================================================ RESTART: F:/U/python/tiem.py ================================================================================================================================================================================================================================================================================================================================================================================================ --------begin execute------ % 0 [->....................] %10 [**->..................] %20 [****->................] %30 [******->..............] %40 [********->............] %50 [**********->..........] %60 [************->........] %70 [**************->......] %80 [****************->....] %90 [******************->..] %100[********************->] -----it's over----- >>> help(eval) Help on built-in function eval in module builtins: eval(source, globals=None, locals=None, /) Evaluate the given source in the context of globals and locals. The source may be a string representing a Python expression or a code object as returned by compile(). The globals must be a dictionary and locals can be any mapping, defaulting to the current globals and locals. If only globals is given, locals defaults to it. >>> ================================================================================================================================================================================================================================================================================================================================================================================================ RESTART: F:/U/python/tiem.py ================================================================================================================================================================================================================================================================================================================================================================================================ enter a number34 now the air is wonderful enter split on ','23,456 23 456 >>> >>> >>> ================================================================================================================================================================================================================================================================================================================================================================================================ RESTART: F:/U/python/tiem.py ================================================================================================================================================================================================================================================================================================================================================================================================ y u e d h g u 条件已结束 >>> ================================================================================================================================================================================================================================================================================================================================================================================================ RESTART: F:/U/python/tiem.py ================================================================================================================================================================================================================================================================================================================================================================================================ y u e d h >>> import random >>> help(random) Help on module random: NAME random - Random variable generators. DESCRIPTION integers -------- uniform within range sequences --------- pick random element pick random sample pick weighted random sample generate random permutation distributions on the real line: ------------------------------ uniform triangular normal (Gaussian) lognormal negative exponential gamma beta pareto Weibull distributions on the circle (angles 0 to 2pi) --------------------------------------------- circular uniform von Mises General notes on the underlying Mersenne Twister core generator: * The period is 2**19937-1. * It is one of the most extensively tested generators in existence. * The random() method is implemented in C, executes in a single Python step, and is, therefore, threadsafe. CLASSES _random.Random(builtins.object) Random SystemRandom class Random(_random.Random) | Random number generator base class used by bound module functions. | | Used to instantiate instances of Random to get generators that don't | share state. | | Class Random can also be subclassed if you want to use a different basic | generator of your own devising: in that case, override the following | methods: random(), seed(), getstate(), and setstate(). | Optionally, implement a getrandbits() method so that randrange() | can cover arbitrarily large ranges. | | Method resolution order: | Random | _random.Random | builtins.object | | Methods defined here: | | __getstate__(self) | # Issue 17489: Since __reduce__ was defined to fix #759889 this is no | # longer called; we leave it here because it has been here since random was | # rewritten back in 2001 and why risk breaking something. | | __init__(self, x=None) | Initialize an instance. | | Optional argument x controls seeding, as for Random.seed(). | | __reduce__(self) | helper for pickle | | __setstate__(self, state) | | betavariate(self, alpha, beta) | Beta distribution. | | Conditions on the parameters are alpha > 0 and beta > 0. | Returned values range between 0 and 1. | | choice(self, seq) | Choose a random element from a non-empty sequence. | | choices(self, population, weights=None, *, cum_weights=None, k=1) | Return a k sized list of population elements chosen with replacement. | | If the relative weights or cumulative weights are not specified, | the selections are made with equal probability. | | expovariate(self, lambd) | Exponential distribution. | | lambd is 1.0 divided by the desired mean. It should be | nonzero. (The parameter would be called "lambda", but that is | a reserved word in Python.) Returned values range from 0 to | positive infinity if lambd is positive, and from negative | infinity to 0 if lambd is negative. | | gammavariate(self, alpha, beta) | Gamma distribution. Not the gamma function! | | Conditions on the parameters are alpha > 0 and beta > 0. | | The probability distribution function is: | | x ** (alpha - 1) * math.exp(-x / beta) | pdf(x) = -------------------------------------- | math.gamma(alpha) * beta ** alpha | | gauss(self, mu, sigma) | Gaussian distribution. | | mu is the mean, and sigma is the standard deviation. This is | slightly faster than the normalvariate() function. | | Not thread-safe without a lock around calls. | | getstate(self) | Return internal state; can be passed to setstate() later. | | lognormvariate(self, mu, sigma) | Log normal distribution. | | If you take the natural logarithm of this distribution, you'll get a | normal distribution with mean mu and standard deviation sigma. | mu can have any value, and sigma must be greater than zero. | | normalvariate(self, mu, sigma) | Normal distribution. | | mu is the mean, and sigma is the standard deviation. | | paretovariate(self, alpha) | Pareto distribution. alpha is the shape parameter. | | randint(self, a, b) | Return random integer in range [a, b], including both end points. | | randrange(self, start, stop=None, step=1, _int= ) | Choose a random item from range(start, stop[, step]). | | This fixes the problem with randint() which includes the | endpoint; in Python this is usually not what you want. | | sample(self, population, k) | Chooses k unique random elements from a population sequence or set. | | Returns a new list containing elements from the population while | leaving the original population unchanged. The resulting list is | in selection order so that all sub-slices will also be valid random | samples. This allows raffle winners (the sample) to be partitioned | into grand prize and second place winners (the subslices). | | Members of the population need not be hashable or unique. If the | population contains repeats, then each occurrence is a possible | selection in the sample. | | To choose a sample in a range of integers, use range as an argument. | This is especially fast and space efficient for sampling from a | large population: sample(range(10000000), 60) | | seed(self, a=None, version=2) | Initialize internal state from hashable object. | | None or no argument seeds from current time or from an operating | system specific randomness source if available. | | If *a* is an int, all bits are used. | | For version 2 (the default), all of the bits are used if *a* is a str, | bytes, or bytearray. For version 1 (provided for reproducing random | sequences from older versions of Python), the algorithm for str and | bytes generates a narrower range of seeds. | | setstate(self, state) | Restore internal state from object returned by getstate(). | | shuffle(self, x, random=None) | Shuffle list x in place, and return None. | | Optional argument random is a 0-argument function returning a | random float in [0.0, 1.0); if it is the default None, the | standard random.random will be used. | | triangular(self, low=0.0, high=1.0, mode=None) | Triangular distribution. | | Continuous distribution bounded by given lower and upper limits, | and having a given mode value in-between. | | http://en.wikipedia.org/wiki/Triangular_distribution | | uniform(self, a, b) | Get a random number in the range [a, b) or [a, b] depending on rounding. | | vonmisesvariate(self, mu, kappa) | Circular data distribution. | | mu is the mean angle, expressed in radians between 0 and 2*pi, and | kappa is the concentration parameter, which must be greater than or | equal to zero. If kappa is equal to zero, this distribution reduces | to a uniform random angle over the range 0 to 2*pi. | | weibullvariate(self, alpha, beta) | Weibull distribution. | | alpha is the scale parameter and beta is the shape parameter. | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) | | ---------------------------------------------------------------------- | Data and other attributes defined here: | | VERSION = 3 | | ---------------------------------------------------------------------- | Methods inherited from _random.Random: | | __getattribute__(self, name, /) | Return getattr(self, name). | | __new__(*args, **kwargs) from builtins.type | Create and return a new object. See help(type) for accurate signature. | | getrandbits(...) | getrandbits(k) -> x. Generates an int with k random bits. | | random(...) | random() -> x in the interval [0, 1). class SystemRandom(Random) | Alternate random number generator using sources provided | by the operating system (such as /dev/urandom on Unix or | CryptGenRandom on Windows). | | Not available on all systems (see os.urandom() for details). | | Method resolution order: | SystemRandom | Random | _random.Random | builtins.object | | Methods defined here: | | getrandbits(self, k) | getrandbits(k) -> x. Generates an int with k random bits. | | getstate = _notimplemented(self, *args, **kwds) | | random(self) | Get the next random number in the range [0.0, 1.0). | | seed(self, *args, **kwds) | Stub method. Not used for a system random number generator. | | setstate = _notimplemented(self, *args, **kwds) | | ---------------------------------------------------------------------- | Methods inherited from Random: | | __getstate__(self) | # Issue 17489: Since __reduce__ was defined to fix #759889 this is no | # longer called; we leave it here because it has been here since random was | # rewritten back in 2001 and why risk breaking something. | | __init__(self, x=None) | Initialize an instance. | | Optional argument x controls seeding, as for Random.seed(). | | __reduce__(self) | helper for pickle | | __setstate__(self, state) | | betavariate(self, alpha, beta) | Beta distribution. | | Conditions on the parameters are alpha > 0 and beta > 0. | Returned values range between 0 and 1. | | choice(self, seq) | Choose a random element from a non-empty sequence. | | choices(self, population, weights=None, *, cum_weights=None, k=1) | Return a k sized list of population elements chosen with replacement. | | If the relative weights or cumulative weights are not specified, | the selections are made with equal probability. | | expovariate(self, lambd) | Exponential distribution. | | lambd is 1.0 divided by the desired mean. It should be | nonzero. (The parameter would be called "lambda", but that is | a reserved word in Python.) Returned values range from 0 to | positive infinity if lambd is positive, and from negative | infinity to 0 if lambd is negative. | | gammavariate(self, alpha, beta) | Gamma distribution. Not the gamma function! | | Conditions on the parameters are alpha > 0 and beta > 0. | | The probability distribution function is: | | x ** (alpha - 1) * math.exp(-x / beta) | pdf(x) = -------------------------------------- | math.gamma(alpha) * beta ** alpha | | gauss(self, mu, sigma) | Gaussian distribution. | | mu is the mean, and sigma is the standard deviation. This is | slightly faster than the normalvariate() function. | | Not thread-safe without a lock around calls. | | lognormvariate(self, mu, sigma) | Log normal distribution. | | If you take the natural logarithm of this distribution, you'll get a | normal distribution with mean mu and standard deviation sigma. | mu can have any value, and sigma must be greater than zero. | | normalvariate(self, mu, sigma) | Normal distribution. | | mu is the mean, and sigma is the standard deviation. | | paretovariate(self, alpha) | Pareto distribution. alpha is the shape parameter. | | randint(self, a, b) | Return random integer in range [a, b], including both end points. | | randrange(self, start, stop=None, step=1, _int= ) | Choose a random item from range(start, stop[, step]). | | This fixes the problem with randint() which includes the | endpoint; in Python this is usually not what you want. | | sample(self, population, k) | Chooses k unique random elements from a population sequence or set. | | Returns a new list containing elements from the population while | leaving the original population unchanged. The resulting list is | in selection order so that all sub-slices will also be valid random | samples. This allows raffle winners (the sample) to be partitioned | into grand prize and second place winners (the subslices). | | Members of the population need not be hashable or unique. If the | population contains repeats, then each occurrence is a possible | selection in the sample. | | To choose a sample in a range of integers, use range as an argument. | This is especially fast and space efficient for sampling from a | large population: sample(range(10000000), 60) | | shuffle(self, x, random=None) | Shuffle list x in place, and return None. | | Optional argument random is a 0-argument function returning a | random float in [0.0, 1.0); if it is the default None, the | standard random.random will be used. | | triangular(self, low=0.0, high=1.0, mode=None) | Triangular distribution. | | Continuous distribution bounded by given lower and upper limits, | and having a given mode value in-between. | | http://en.wikipedia.org/wiki/Triangular_distribution | | uniform(self, a, b) | Get a random number in the range [a, b) or [a, b] depending on rounding. | | vonmisesvariate(self, mu, kappa) | Circular data distribution. | | mu is the mean angle, expressed in radians between 0 and 2*pi, and | kappa is the concentration parameter, which must be greater than or | equal to zero. If kappa is equal to zero, this distribution reduces | to a uniform random angle over the range 0 to 2*pi. | | weibullvariate(self, alpha, beta) | Weibull distribution. | | alpha is the scale parameter and beta is the shape parameter. | | ---------------------------------------------------------------------- | Data descriptors inherited from Random: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) | | ---------------------------------------------------------------------- | Data and other attributes inherited from Random: | | VERSION = 3 | | ---------------------------------------------------------------------- | Methods inherited from _random.Random: | | __getattribute__(self, name, /) | Return getattr(self, name). | | __new__(*args, **kwargs) from builtins.type | Create and return a new object. See help(type) for accurate signature. FUNCTIONS betavariate(alpha, beta) method of Random instance Beta distribution. Conditions on the parameters are alpha > 0 and beta > 0. Returned values range between 0 and 1. choice(seq) method of Random instance Choose a random element from a non-empty sequence. choices(population, weights=None, *, cum_weights=None, k=1) method of Random instance Return a k sized list of population elements chosen with replacement. If the relative weights or cumulative weights are not specified, the selections are made with equal probability. expovariate(lambd) method of Random instance Exponential distribution. lambd is 1.0 divided by the desired mean. It should be nonzero. (The parameter would be called "lambda", but that is a reserved word in Python.) Returned values range from 0 to positive infinity if lambd is positive, and from negative infinity to 0 if lambd is negative. gammavariate(alpha, beta) method of Random instance Gamma distribution. Not the gamma function! Conditions on the parameters are alpha > 0 and beta > 0. The probability distribution function is: x ** (alpha - 1) * math.exp(-x / beta) pdf(x) = -------------------------------------- math.gamma(alpha) * beta ** alpha gauss(mu, sigma) method of Random instance Gaussian distribution. mu is the mean, and sigma is the standard deviation. This is slightly faster than the normalvariate() function. Not thread-safe without a lock around calls. getrandbits(...) method of Random instance getrandbits(k) -> x. Generates an int with k random bits. getstate() method of Random instance Return internal state; can be passed to setstate() later. lognormvariate(mu, sigma) method of Random instance Log normal distribution. If you take the natural logarithm of this distribution, you'll get a normal distribution with mean mu and standard deviation sigma. mu can have any value, and sigma must be greater than zero. normalvariate(mu, sigma) method of Random instance Normal distribution. mu is the mean, and sigma is the standard deviation. paretovariate(alpha) method of Random instance Pareto distribution. alpha is the shape parameter. randint(a, b) method of Random instance Return random integer in range [a, b], including both end points. random(...) method of Random instance random() -> x in the interval [0, 1). randrange(start, stop=None, step=1, _int= ) method of Random instance Choose a random item from range(start, stop[, step]). This fixes the problem with randint() which includes the endpoint; in Python this is usually not what you want. sample(population, k) method of Random instance Chooses k unique random elements from a population sequence or set. Returns a new list containing elements from the population while leaving the original population unchanged. The resulting list is in selection order so that all sub-slices will also be valid random samples. This allows raffle winners (the sample) to be partitioned into grand prize and second place winners (the subslices). Members of the population need not be hashable or unique. If the population contains repeats, then each occurrence is a possible selection in the sample. To choose a sample in a range of integers, use range as an argument. This is especially fast and space efficient for sampling from a large population: sample(range(10000000), 60) seed(a=None, version=2) method of Random instance Initialize internal state from hashable object. None or no argument seeds from current time or from an operating system specific randomness source if available. If *a* is an int, all bits are used. For version 2 (the default), all of the bits are used if *a* is a str, bytes, or bytearray. For version 1 (provided for reproducing random sequences from older versions of Python), the algorithm for str and bytes generates a narrower range of seeds. setstate(state) method of Random instance Restore internal state from object returned by getstate(). shuffle(x, random=None) method of Random instance Shuffle list x in place, and return None. Optional argument random is a 0-argument function returning a random float in [0.0, 1.0); if it is the default None, the standard random.random will be used. triangular(low=0.0, high=1.0, mode=None) method of Random instance Triangular distribution. Continuous distribution bounded by given lower and upper limits, and having a given mode value in-between. http://en.wikipedia.org/wiki/Triangular_distribution uniform(a, b) method of Random instance Get a random number in the range [a, b) or [a, b] depending on rounding. vonmisesvariate(mu, kappa) method of Random instance Circular data distribution. mu is the mean angle, expressed in radians between 0 and 2*pi, and kappa is the concentration parameter, which must be greater than or equal to zero. If kappa is equal to zero, this distribution reduces to a uniform random angle over the range 0 to 2*pi. weibullvariate(alpha, beta) method of Random instance Weibull distribution. alpha is the scale parameter and beta is the shape parameter. DATA __all__ = ['Random', 'seed', 'random', 'uniform', 'randint', 'choice',... FILE f:\u\python\lib\random.py >>> random() Traceback (most recent call last): File " ", line 1, in random() TypeError: 'module' object is not callable >>> import random >>> random() Traceback (most recent call last): File " ", line 1, in random() TypeError: 'module' object is not callable >>> Python 3.6.2 (v3.6.2:5fd33b5, Jul 8 2017, 04:14:34) [MSC v.1900 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> python
Traceback (most recent call last):
File "", line 1, in
python
NameError: name 'python' is not defined
>>> help(format)
Help on built-in function format in module builtins:format(value, format_spec='', /)
Return value.__format__(format_spec)
format_spec defaults to the empty string>>> s="hey i'm ok"
>>> "{0:30}".format(s)
"hey i'm ok "
>>> s
"hey i'm ok"
>>> "{0:>30}".format(s)
" hey i'm ok"
>>> "{0:*^30}".format(s)
"**********hey i'm ok**********"
>>> "{0:?^34}".format(37858634723784)
'??????????37858634723784??????????'
>>> "{0:?^34,}".format(37858634723784)
'????????37,858,634,723,784????????'
>>> "{0:.4}".format(s)
'hey '
>>> import time
>>> help(time)
Help on built-in module time:NAME
time - This module provides various functions to manipulate time values.DESCRIPTION
There are two standard representations of time. One is the number
of seconds since the Epoch, in UTC (a.k.a. GMT). It may be an integer
or a floating point number (to represent fractions of seconds).
The Epoch is system-defined; on Unix, it is generally January 1st, 1970.
The actual value can be retrieved by calling gmtime(0).
The other representation is a tuple of 9 integers giving local time.
The tuple items are:
year (including century, e.g. 1998)
month (1-12)
day (1-31)
hours (0-23)
minutes (0-59)
seconds (0-59)
weekday (0-6, Monday is 0)
Julian day (day in the year, 1-366)
DST (Daylight Savings Time) flag (-1, 0 or 1)
If the DST flag is 0, the time is given in the regular time zone;
if it is 1, the time is given in the DST time zone;
if it is -1, mktime() should guess based on the date and time.
Variables:
timezone -- difference in seconds between UTC and local standard time
altzone -- difference in seconds between UTC and local DST time
daylight -- whether local time should reflect DST
tzname -- tuple of (standard time zone name, DST time zone name)
Functions:
time() -- return current time in seconds since the Epoch as a float
clock() -- return CPU time since process start as a float
sleep() -- delay for a number of seconds given as a float
gmtime() -- convert seconds since Epoch to UTC tuple
localtime() -- convert seconds since Epoch to local time tuple
asctime() -- convert time tuple to string
ctime() -- convert time in seconds to string
mktime() -- convert local time tuple to seconds since Epoch
strftime() -- convert time tuple to string according to format specification
strptime() -- parse string to time tuple according to format specification
tzset() -- change the local timezoneCLASSES
builtins.tuple(builtins.object)
struct_time
class struct_time(builtins.tuple)
| The time value as returned by gmtime(), localtime(), and strptime(), and
| accepted by asctime(), mktime() and strftime(). May be considered as a
| sequence of 9 integers.
|
| Note that several fields' values are not the same as those defined by
| the C language standard for struct tm. For example, the value of the
| field tm_year is the actual year, not year - 1900. See individual
| fields' descriptions for details.
|
| Method resolution order:
| struct_time
| builtins.tuple
| builtins.object
|
| Methods defined here:
|
| __new__(*args, **kwargs) from builtins.type
| Create and return a new object. See help(type) for accurate signature.
|
| __reduce__(...)
| helper for pickle
|
| __repr__(self, /)
| Return repr(self).
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| tm_gmtoff
| offset from UTC in seconds
|
| tm_hour
| hours, range [0, 23]
|
| tm_isdst
| 1 if summer time is in effect, 0 if not, and -1 if unknown
|
| tm_mday
| day of month, range [1, 31]
|
| tm_min
| minutes, range [0, 59]
|
| tm_mon
| month of year, range [1, 12]
|
| tm_sec
| seconds, range [0, 61])
|
| tm_wday
| day of week, range [0, 6], Monday is 0
|
| tm_yday
| day of year, range [1, 366]
|
| tm_year
| year, for example, 1993
|
| tm_zone
| abbreviation of timezone name
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| n_fields = 11
|
| n_sequence_fields = 9
|
| n_unnamed_fields = 0
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.tuple:
|
| __add__(self, value, /)
| Return self+value.
|
| __contains__(self, key, /)
| Return key in self.
|
| __eq__(self, value, /)
| Return self==value.
|
| __ge__(self, value, /)
| Return self>=value.
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __getitem__(self, key, /)
| Return self[key].
|
| __getnewargs__(...)
|
| __gt__(self, value, /)
| Return self>value.
|
| __hash__(self, /)
| Return hash(self).
|
| __iter__(self, /)
| Implement iter(self).
|
| __le__(self, value, /)
| Return self<=value.
|
| __len__(self, /)
| Return len(self).
|
| __lt__(self, value, /)
| Return self|
| __mul__(self, value, /)
| Return self*value.n
|
| __ne__(self, value, /)
| Return self!=value.
|
| __rmul__(self, value, /)
| Return self*value.
|
| count(...)
| T.count(value) -> integer -- return number of occurrences of value
|
| index(...)
| T.index(value, [start, [stop]]) -> integer -- return first index of value.
| Raises ValueError if the value is not present.FUNCTIONS
asctime(...)
asctime([tuple]) -> string
Convert a time tuple to a string, e.g. 'Sat Jun 06 16:26:11 1998'.
When the time tuple is not present, current time as returned by localtime()
is used.
clock(...)
clock() -> floating point number
Return the CPU time or real time since the start of the process or since
the first call to clock(). This has as much precision as the system
records.
ctime(...)
ctime(seconds) -> string
Convert a time in seconds since the Epoch to a string in local time.
This is equivalent to asctime(localtime(seconds)). When the time tuple is
not present, current time as returned by localtime() is used.
get_clock_info(...)
get_clock_info(name: str) -> dict
Get information of the specified clock.
gmtime(...)
gmtime([seconds]) -> (tm_year, tm_mon, tm_mday, tm_hour, tm_min,
tm_sec, tm_wday, tm_yday, tm_isdst)
Convert seconds since the Epoch to a time tuple expressing UTC (a.k.a.
GMT). When 'seconds' is not passed in, convert the current time instead.
If the platform supports the tm_gmtoff and tm_zone, they are available as
attributes only.
localtime(...)
localtime([seconds]) -> (tm_year,tm_mon,tm_mday,tm_hour,tm_min,
tm_sec,tm_wday,tm_yday,tm_isdst)
Convert seconds since the Epoch to a time tuple expressing local time.
When 'seconds' is not passed in, convert the current time instead.
mktime(...)
mktime(tuple) -> floating point number
Convert a time tuple in local time to seconds since the Epoch.
Note that mktime(gmtime(0)) will not generally return zero for most
time zones; instead the returned value will either be equal to that
of the timezone or altzone attributes on the time module.
monotonic(...)
monotonic() -> float
Monotonic clock, cannot go backward.
perf_counter(...)
perf_counter() -> float
Performance counter for benchmarking.
process_time(...)
process_time() -> float
Process time for profiling: sum of the kernel and user-space CPU time.
sleep(...)
sleep(seconds)
Delay execution for a given number of seconds. The argument may be
a floating point number for subsecond precision.
strftime(...)
strftime(format[, tuple]) -> string
Convert a time tuple to a string according to a format specification.
See the library reference manual for formatting codes. When the time tuple
is not present, current time as returned by localtime() is used.
Commonly used format codes:
%Y Year with century as a decimal number.
%m Month as a decimal number [01,12].
%d Day of the month as a decimal number [01,31].
%H Hour (24-hour clock) as a decimal number [00,23].
%M Minute as a decimal number [00,59].
%S Second as a decimal number [00,61].
%z Time zone offset from UTC.
%a Locale's abbreviated weekday name.
%A Locale's full weekday name.
%b Locale's abbreviated month name.
%B Locale's full month name.
%c Locale's appropriate date and time representation.
%I Hour (12-hour clock) as a decimal number [01,12].
%p Locale's equivalent of either AM or PM.
Other codes may be available on your platform. See documentation for
the C library strftime function.
strptime(...)
strptime(string, format) -> struct_time
Parse a string to a time tuple according to a format specification.
See the library reference manual for formatting codes (same as
strftime()).
Commonly used format codes:
%Y Year with century as a decimal number.
%m Month as a decimal number [01,12].
%d Day of the month as a decimal number [01,31].
%H Hour (24-hour clock) as a decimal number [00,23].
%M Minute as a decimal number [00,59].
%S Second as a decimal number [00,61].
%z Time zone offset from UTC.
%a Locale's abbreviated weekday name.
%A Locale's full weekday name.
%b Locale's abbreviated month name.
%B Locale's full month name.
%c Locale's appropriate date and time representation.
%I Hour (12-hour clock) as a decimal number [01,12].
%p Locale's equivalent of either AM or PM.
Other codes may be available on your platform. See documentation for
the C library strftime function.
time(...)
time() -> floating point number
Return the current time in seconds since the Epoch.
Fractions of a second may be present if the system clock provides them.DATA
altzone = -32400
daylight = 0
timezone = -28800
tzname = ('China Standard Time', 'China Standard Time')FILE
(built-in)
>>> help(sleep)
Traceback (most recent call last):
File "", line 1, in
help(sleep)
NameError: name 'sleep' is not defined
>>> help(time.sleep)
Help on built-in function sleep in module time:sleep(...)
sleep(seconds)
Delay execution for a given number of seconds. The argument may be
a floating point number for subsecond precision.>>> help(scale)
Traceback (most recent call last):
File "", line 1, in
help(scale)
NameError: name 'scale' is not defined
>>> help(time.scale)
Traceback (most recent call last):
File "", line 1, in
help(time.scale)
AttributeError: module 'time' has no attribute 'scale'
>>> help(scale)
Traceback (most recent call last):
File "", line 1, in
help(scale)
NameError: name 'scale' is not defined
>>>
================================================================================================================================================================================================================================================================================================================================================================================================ RESTART: F:/U/python/tiem.py ================================================================================================================================================================================================================================================================================================================================================================================================
--------begin execute------
% 0.000000 [->....................]
% 10.000000 [**->..................]
% 20.000000 [****->................]
% 30.000000 [******->..............]
% 40.000000 [********->............]
% 50.000000 [**********->..........]
% 60.000000 [************->........]
% 70.000000 [**************->......]
% 80.000000 [****************->....]
% 90.000000 [******************->..]
% 100.000000 [********************->]
-----it's over-----
>>>
================================================================================================================================================================================================================================================================================================================================================================================================ RESTART: F:/U/python/tiem.py ================================================================================================================================================================================================================================================================================================================================================================================================
--------begin execute------
% 0 [->....................]
%10 [**->..................]
%20 [****->................]
%30 [******->..............]
%40 [********->............]
%50 [**********->..........]
%60 [************->........]
%70 [**************->......]
%80 [****************->....]
%90 [******************->..]
%100[********************->]
-----it's over-----
>>>
================================================================================================================================================================================================================================================================================================================================================================================================ RESTART: F:/U/python/tiem.py ================================================================================================================================================================================================================================================================================================================================================================================================
--------begin execute------
% 0 [->....................]
%10 [**->..................]
%20 [****->................]
%30 [******->..............]
%40 [********->............]
%50 [**********->..........]
%60 [************->........]
%70 [**************->......]
%80 [****************->....]
%90 [******************->..]
%100[********************->]
-----it's over-----
>>> help(eval)
Help on built-in function eval in module builtins:eval(source, globals=None, locals=None, /)
Evaluate the given source in the context of globals and locals.
The source may be a string representing a Python expression
or a code object as returned by compile().
The globals must be a dictionary and locals can be any mapping,
defaulting to the current globals and locals.
If only globals is given, locals defaults to it.>>>
================================================================================================================================================================================================================================================================================================================================================================================================ RESTART: F:/U/python/tiem.py ================================================================================================================================================================================================================================================================================================================================================================================================
enter a number34
now the air is wonderful
enter split on ','23,456
23 456
>>>
>>>
>>>
================================================================================================================================================================================================================================================================================================================================================================================================ RESTART: F:/U/python/tiem.py ================================================================================================================================================================================================================================================================================================================================================================================================
y
u
e
d
h
g
u
条件已结束
>>>
================================================================================================================================================================================================================================================================================================================================================================================================ RESTART: F:/U/python/tiem.py ================================================================================================================================================================================================================================================================================================================================================================================================
y
u
e
d
h
>>> import random
>>> help(random)
Help on module random:NAME
random - Random variable generators.DESCRIPTION
integers
--------
uniform within range
sequences
---------
pick random element
pick random sample
pick weighted random sample
generate random permutation
distributions on the real line:
------------------------------
uniform
triangular
normal (Gaussian)
lognormal
negative exponential
gamma
beta
pareto
Weibull
distributions on the circle (angles 0 to 2pi)
---------------------------------------------
circular uniform
von Mises
General notes on the underlying Mersenne Twister core generator:
* The period is 2**19937-1.
* It is one of the most extensively tested generators in existence.
* The random() method is implemented in C, executes in a single Python step,
and is, therefore, threadsafe.CLASSES
_random.Random(builtins.object)
Random
SystemRandom
class Random(_random.Random)
| Random number generator base class used by bound module functions.
|
| Used to instantiate instances of Random to get generators that don't
| share state.
|
| Class Random can also be subclassed if you want to use a different basic
| generator of your own devising: in that case, override the following
| methods: random(), seed(), getstate(), and setstate().
| Optionally, implement a getrandbits() method so that randrange()
| can cover arbitrarily large ranges.
|
| Method resolution order:
| Random
| _random.Random
| builtins.object
|
| Methods defined here:
|
| __getstate__(self)
| # Issue 17489: Since __reduce__ was defined to fix #759889 this is no
| # longer called; we leave it here because it has been here since random was
| # rewritten back in 2001 and why risk breaking something.
|
| __init__(self, x=None)
| Initialize an instance.
|
| Optional argument x controls seeding, as for Random.seed().
|
| __reduce__(self)
| helper for pickle
|
| __setstate__(self, state)
|
| betavariate(self, alpha, beta)
| Beta distribution.
|
| Conditions on the parameters are alpha > 0 and beta > 0.
| Returned values range between 0 and 1.
|
| choice(self, seq)
| Choose a random element from a non-empty sequence.
|
| choices(self, population, weights=None, *, cum_weights=None, k=1)
| Return a k sized list of population elements chosen with replacement.
|
| If the relative weights or cumulative weights are not specified,
| the selections are made with equal probability.
|
| expovariate(self, lambd)
| Exponential distribution.
|
| lambd is 1.0 divided by the desired mean. It should be
| nonzero. (The parameter would be called "lambda", but that is
| a reserved word in Python.) Returned values range from 0 to
| positive infinity if lambd is positive, and from negative
| infinity to 0 if lambd is negative.
|
| gammavariate(self, alpha, beta)
| Gamma distribution. Not the gamma function!
|
| Conditions on the parameters are alpha > 0 and beta > 0.
|
| The probability distribution function is:
|
| x ** (alpha - 1) * math.exp(-x / beta)
| pdf(x) = --------------------------------------
| math.gamma(alpha) * beta ** alpha
|
| gauss(self, mu, sigma)
| Gaussian distribution.
|
| mu is the mean, and sigma is the standard deviation. This is
| slightly faster than the normalvariate() function.
|
| Not thread-safe without a lock around calls.
|
| getstate(self)
| Return internal state; can be passed to setstate() later.
|
| lognormvariate(self, mu, sigma)
| Log normal distribution.
|
| If you take the natural logarithm of this distribution, you'll get a
| normal distribution with mean mu and standard deviation sigma.
| mu can have any value, and sigma must be greater than zero.
|
| normalvariate(self, mu, sigma)
| Normal distribution.
|
| mu is the mean, and sigma is the standard deviation.
|
| paretovariate(self, alpha)
| Pareto distribution. alpha is the shape parameter.
|
| randint(self, a, b)
| Return random integer in range [a, b], including both end points.
|
| randrange(self, start, stop=None, step=1, _int=)
| Choose a random item from range(start, stop[, step]).
|
| This fixes the problem with randint() which includes the
| endpoint; in Python this is usually not what you want.
|
| sample(self, population, k)
| Chooses k unique random elements from a population sequence or set.
|
| Returns a new list containing elements from the population while
| leaving the original population unchanged. The resulting list is
| in selection order so that all sub-slices will also be valid random
| samples. This allows raffle winners (the sample) to be partitioned
| into grand prize and second place winners (the subslices).
|
| Members of the population need not be hashable or unique. If the
| population contains repeats, then each occurrence is a possible
| selection in the sample.
|
| To choose a sample in a range of integers, use range as an argument.
| This is especially fast and space efficient for sampling from a
| large population: sample(range(10000000), 60)
|
| seed(self, a=None, version=2)
| Initialize internal state from hashable object.
|
| None or no argument seeds from current time or from an operating
| system specific randomness source if available.
|
| If *a* is an int, all bits are used.
|
| For version 2 (the default), all of the bits are used if *a* is a str,
| bytes, or bytearray. For version 1 (provided for reproducing random
| sequences from older versions of Python), the algorithm for str and
| bytes generates a narrower range of seeds.
|
| setstate(self, state)
| Restore internal state from object returned by getstate().
|
| shuffle(self, x, random=None)
| Shuffle list x in place, and return None.
|
| Optional argument random is a 0-argument function returning a
| random float in [0.0, 1.0); if it is the default None, the
| standard random.random will be used.
|
| triangular(self, low=0.0, high=1.0, mode=None)
| Triangular distribution.
|
| Continuous distribution bounded by given lower and upper limits,
| and having a given mode value in-between.
|
| http://en.wikipedia.org/wiki/Triangular_distribution
|
| uniform(self, a, b)
| Get a random number in the range [a, b) or [a, b] depending on rounding.
|
| vonmisesvariate(self, mu, kappa)
| Circular data distribution.
|
| mu is the mean angle, expressed in radians between 0 and 2*pi, and
| kappa is the concentration parameter, which must be greater than or
| equal to zero. If kappa is equal to zero, this distribution reduces
| to a uniform random angle over the range 0 to 2*pi.
|
| weibullvariate(self, alpha, beta)
| Weibull distribution.
|
| alpha is the scale parameter and beta is the shape parameter.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables (if defined)
|
| __weakref__
| list of weak references to the object (if defined)
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| VERSION = 3
|
| ----------------------------------------------------------------------
| Methods inherited from _random.Random:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __new__(*args, **kwargs) from builtins.type
| Create and return a new object. See help(type) for accurate signature.
|
| getrandbits(...)
| getrandbits(k) -> x. Generates an int with k random bits.
|
| random(...)
| random() -> x in the interval [0, 1).
class SystemRandom(Random)
| Alternate random number generator using sources provided
| by the operating system (such as /dev/urandom on Unix or
| CryptGenRandom on Windows).
|
| Not available on all systems (see os.urandom() for details).
|
| Method resolution order:
| SystemRandom
| Random
| _random.Random
| builtins.object
|
| Methods defined here:
|
| getrandbits(self, k)
| getrandbits(k) -> x. Generates an int with k random bits.
|
| getstate = _notimplemented(self, *args, **kwds)
|
| random(self)
| Get the next random number in the range [0.0, 1.0).
|
| seed(self, *args, **kwds)
| Stub method. Not used for a system random number generator.
|
| setstate = _notimplemented(self, *args, **kwds)
|
| ----------------------------------------------------------------------
| Methods inherited from Random:
|
| __getstate__(self)
| # Issue 17489: Since __reduce__ was defined to fix #759889 this is no
| # longer called; we leave it here because it has been here since random was
| # rewritten back in 2001 and why risk breaking something.
|
| __init__(self, x=None)
| Initialize an instance.
|
| Optional argument x controls seeding, as for Random.seed().
|
| __reduce__(self)
| helper for pickle
|
| __setstate__(self, state)
|
| betavariate(self, alpha, beta)
| Beta distribution.
|
| Conditions on the parameters are alpha > 0 and beta > 0.
| Returned values range between 0 and 1.
|
| choice(self, seq)
| Choose a random element from a non-empty sequence.
|
| choices(self, population, weights=None, *, cum_weights=None, k=1)
| Return a k sized list of population elements chosen with replacement.
|
| If the relative weights or cumulative weights are not specified,
| the selections are made with equal probability.
|
| expovariate(self, lambd)
| Exponential distribution.
|
| lambd is 1.0 divided by the desired mean. It should be
| nonzero. (The parameter would be called "lambda", but that is
| a reserved word in Python.) Returned values range from 0 to
| positive infinity if lambd is positive, and from negative
| infinity to 0 if lambd is negative.
|
| gammavariate(self, alpha, beta)
| Gamma distribution. Not the gamma function!
|
| Conditions on the parameters are alpha > 0 and beta > 0.
|
| The probability distribution function is:
|
| x ** (alpha - 1) * math.exp(-x / beta)
| pdf(x) = --------------------------------------
| math.gamma(alpha) * beta ** alpha
|
| gauss(self, mu, sigma)
| Gaussian distribution.
|
| mu is the mean, and sigma is the standard deviation. This is
| slightly faster than the normalvariate() function.
|
| Not thread-safe without a lock around calls.
|
| lognormvariate(self, mu, sigma)
| Log normal distribution.
|
| If you take the natural logarithm of this distribution, you'll get a
| normal distribution with mean mu and standard deviation sigma.
| mu can have any value, and sigma must be greater than zero.
|
| normalvariate(self, mu, sigma)
| Normal distribution.
|
| mu is the mean, and sigma is the standard deviation.
|
| paretovariate(self, alpha)
| Pareto distribution. alpha is the shape parameter.
|
| randint(self, a, b)
| Return random integer in range [a, b], including both end points.
|
| randrange(self, start, stop=None, step=1, _int=)
| Choose a random item from range(start, stop[, step]).
|
| This fixes the problem with randint() which includes the
| endpoint; in Python this is usually not what you want.
|
| sample(self, population, k)
| Chooses k unique random elements from a population sequence or set.
|
| Returns a new list containing elements from the population while
| leaving the original population unchanged. The resulting list is
| in selection order so that all sub-slices will also be valid random
| samples. This allows raffle winners (the sample) to be partitioned
| into grand prize and second place winners (the subslices).
|
| Members of the population need not be hashable or unique. If the
| population contains repeats, then each occurrence is a possible
| selection in the sample.
|
| To choose a sample in a range of integers, use range as an argument.
| This is especially fast and space efficient for sampling from a
| large population: sample(range(10000000), 60)
|
| shuffle(self, x, random=None)
| Shuffle list x in place, and return None.
|
| Optional argument random is a 0-argument function returning a
| random float in [0.0, 1.0); if it is the default None, the
| standard random.random will be used.
|
| triangular(self, low=0.0, high=1.0, mode=None)
| Triangular distribution.
|
| Continuous distribution bounded by given lower and upper limits,
| and having a given mode value in-between.
|
| http://en.wikipedia.org/wiki/Triangular_distribution
|
| uniform(self, a, b)
| Get a random number in the range [a, b) or [a, b] depending on rounding.
|
| vonmisesvariate(self, mu, kappa)
| Circular data distribution.
|
| mu is the mean angle, expressed in radians between 0 and 2*pi, and
| kappa is the concentration parameter, which must be greater than or
| equal to zero. If kappa is equal to zero, this distribution reduces
| to a uniform random angle over the range 0 to 2*pi.
|
| weibullvariate(self, alpha, beta)
| Weibull distribution.
|
| alpha is the scale parameter and beta is the shape parameter.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from Random:
|
| __dict__
| dictionary for instance variables (if defined)
|
| __weakref__
| list of weak references to the object (if defined)
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from Random:
|
| VERSION = 3
|
| ----------------------------------------------------------------------
| Methods inherited from _random.Random:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __new__(*args, **kwargs) from builtins.type
| Create and return a new object. See help(type) for accurate signature.FUNCTIONS
betavariate(alpha, beta) method of Random instance
Beta distribution.
Conditions on the parameters are alpha > 0 and beta > 0.
Returned values range between 0 and 1.
choice(seq) method of Random instance
Choose a random element from a non-empty sequence.
choices(population, weights=None, *, cum_weights=None, k=1) method of Random instance
Return a k sized list of population elements chosen with replacement.
If the relative weights or cumulative weights are not specified,
the selections are made with equal probability.
expovariate(lambd) method of Random instance
Exponential distribution.
lambd is 1.0 divided by the desired mean. It should be
nonzero. (The parameter would be called "lambda", but that is
a reserved word in Python.) Returned values range from 0 to
positive infinity if lambd is positive, and from negative
infinity to 0 if lambd is negative.
gammavariate(alpha, beta) method of Random instance
Gamma distribution. Not the gamma function!
Conditions on the parameters are alpha > 0 and beta > 0.
The probability distribution function is:
x ** (alpha - 1) * math.exp(-x / beta)
pdf(x) = --------------------------------------
math.gamma(alpha) * beta ** alpha
gauss(mu, sigma) method of Random instance
Gaussian distribution.
mu is the mean, and sigma is the standard deviation. This is
slightly faster than the normalvariate() function.
Not thread-safe without a lock around calls.
getrandbits(...) method of Random instance
getrandbits(k) -> x. Generates an int with k random bits.
getstate() method of Random instance
Return internal state; can be passed to setstate() later.
lognormvariate(mu, sigma) method of Random instance
Log normal distribution.
If you take the natural logarithm of this distribution, you'll get a
normal distribution with mean mu and standard deviation sigma.
mu can have any value, and sigma must be greater than zero.
normalvariate(mu, sigma) method of Random instance
Normal distribution.
mu is the mean, and sigma is the standard deviation.
paretovariate(alpha) method of Random instance
Pareto distribution. alpha is the shape parameter.
randint(a, b) method of Random instance
Return random integer in range [a, b], including both end points.
random(...) method of Random instance
random() -> x in the interval [0, 1).
randrange(start, stop=None, step=1, _int=) method of Random instance
Choose a random item from range(start, stop[, step]).
This fixes the problem with randint() which includes the
endpoint; in Python this is usually not what you want.
sample(population, k) method of Random instance
Chooses k unique random elements from a population sequence or set.
Returns a new list containing elements from the population while
leaving the original population unchanged. The resulting list is
in selection order so that all sub-slices will also be valid random
samples. This allows raffle winners (the sample) to be partitioned
into grand prize and second place winners (the subslices).
Members of the population need not be hashable or unique. If the
population contains repeats, then each occurrence is a possible
selection in the sample.
To choose a sample in a range of integers, use range as an argument.
This is especially fast and space efficient for sampling from a
large population: sample(range(10000000), 60)
seed(a=None, version=2) method of Random instance
Initialize internal state from hashable object.
None or no argument seeds from current time or from an operating
system specific randomness source if available.
If *a* is an int, all bits are used.
For version 2 (the default), all of the bits are used if *a* is a str,
bytes, or bytearray. For version 1 (provided for reproducing random
sequences from older versions of Python), the algorithm for str and
bytes generates a narrower range of seeds.
setstate(state) method of Random instance
Restore internal state from object returned by getstate().
shuffle(x, random=None) method of Random instance
Shuffle list x in place, and return None.
Optional argument random is a 0-argument function returning a
random float in [0.0, 1.0); if it is the default None, the
standard random.random will be used.
triangular(low=0.0, high=1.0, mode=None) method of Random instance
Triangular distribution.
Continuous distribution bounded by given lower and upper limits,
and having a given mode value in-between.
http://en.wikipedia.org/wiki/Triangular_distribution
uniform(a, b) method of Random instance
Get a random number in the range [a, b) or [a, b] depending on rounding.
vonmisesvariate(mu, kappa) method of Random instance
Circular data distribution.
mu is the mean angle, expressed in radians between 0 and 2*pi, and
kappa is the concentration parameter, which must be greater than or
equal to zero. If kappa is equal to zero, this distribution reduces
to a uniform random angle over the range 0 to 2*pi.
weibullvariate(alpha, beta) method of Random instance
Weibull distribution.
alpha is the scale parameter and beta is the shape parameter.DATA
__all__ = ['Random', 'seed', 'random', 'uniform', 'randint', 'choice',...FILE
f:\u\python\lib\random.py
>>> random()
Traceback (most recent call last):
File "", line 1, in
random()
TypeError: 'module' object is not callable
>>> import random
>>> random()
Traceback (most recent call last):
File "", line 1, in
random()
TypeError: 'module' object is not callable
>>>-----
Python 3.6.2 (v3.6.2:5fd33b5, Jul 8 2017, 04:14:34) [MSC v.1900 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. >>> =============================================================================================================================================================================================================================================================================================================================================================================================== RESTART: F:/U/python/time1.py =============================================================================================================================================================================================================================================================================================================================================================================================== the time Traceback (most recent call last): File "F:/U/python/time1.py", line 6, in
print(clock()) NameError: name 'clock' is not defined >>> =============================================================================================================================================================================================================================================================================================================================================================================================== RESTART: F:/U/python/time1.py =============================================================================================================================================================================================================================================================================================================================================================================================== the time 0.061255405124137734 >>> =============================================================================================================================================================================================================================================================================================================================================================================================== RESTART: F:/U/python/time1.py =============================================================================================================================================================================================================================================================================================================================================================================================== PI is 3.1236. the run time is :0.07293s >>> =============================================================================================================================================================================================================================================================================================================================================================================================== RESTART: F:/U/python/time1.py =============================================================================================================================================================================================================================================================================================================================================================================================== PI is 3.14364. the run time is :0.17939s >>> =============================================================================================================================================================================================================================================================================================================================================================================================== RESTART: F:/U/python/time1.py =============================================================================================================================================================================================================================================================================================================================================================================================== PI is 3.141924. the run time is :1.366s >>> =============================================================================================================================================================================================================================================================================================================================================================================================== RESTART: F:/U/python/time1.py =============================================================================================================================================================================================================================================================================================================================================================================================== PI is 3.1411776. the run time is :13.368s >>> =============================================================================================================================================================================================================================================================================================================================================================================================== RESTART: F:/U/python/time1.py =============================================================================================================================================================================================================================================================================================================================================================================================== PI is 3.1414334. the run time is :132.54s >>> help(except) SyntaxError: invalid syntax >>> =============================================================================================================================================================================================================================================================================================================================================================================================== RESTART: F:/U/python/time1.py =============================================================================================================================================================================================================================================================================================================================================================================================== >>> from datetime import datetime >>> datetime.now() datetime.datetime(2017, 11, 4, 15, 29, 48, 923735) >>> datetime.date() Traceback (most recent call last): File " ", line 1, in datetime.date() TypeError: descriptor 'date' of 'datetime.datetime' object needs an argument >>> datetime.date >>> datetime.utcnow() datetime.datetime(2017, 11, 4, 7, 33, 37, 982379) >>> now Traceback (most recent call last): File " ", line 1, in now NameError: name 'now' is not defined >>> now() Traceback (most recent call last): File " ", line 1, in now() NameError: name 'now' is not defined >>> datetime.min datetime.datetime(1, 1, 1, 0, 0) >>> datetime.max datetime.datetime(9999, 12, 31, 23, 59, 59, 999999) >>> datetime.year >>> datetime.month >>> datetime.isoformat() Traceback (most recent call last): File " ", line 1, in datetime.isoformat() TypeError: descriptor 'isoformat' of 'datetime.datetime' object needs an argument >>> datetime.now() datetime.datetime(2017, 11, 4, 15, 36, 7, 155623) >>> a=datetime.now() >>> a datetime.datetime(2017, 11, 4, 15, 36, 29, 682597) >>> a.min datetime.datetime(1, 1, 1, 0, 0) >>> a.year 2017 >>> a.month 11 >>> a.isoformat() '2017-11-04T15:36:29.682597' >>> a.isoweekday() 6 >>> help(isoweekday) Traceback (most recent call last): File " ", line 1, in help(isoweekday) NameError: name 'isoweekday' is not defined >>> help(a.isoweekday) Help on built-in function isoweekday: isoweekday(...) method of datetime.datetime instance Return the day of the week represented by the date. Monday == 1 ... Sunday == 7 >>> help(.isoweekday) SyntaxError: invalid syntax >>> help(str.isoweekday) Traceback (most recent call last): File " ", line 1, in help(str.isoweekday) AttributeError: type object 'str' has no attribute 'isoweekday' >>> help(a.strftime ) Help on built-in function strftime: strftime(...) method of datetime.datetime instance format -> strftime() style string. >>> a datetime.datetime(2017, 11, 4, 15, 36, 29, 682597) >>> a.strftime ("%$") Traceback (most recent call last): File " ", line 1, in a.strftime ("%$") ValueError: Invalid format string >>> a.strftime("%Y-%m-%d-%B-%b-%A-%a-%H-%I-%p-%M-%S") '2017-11-04-November-Nov-Saturday-Sat-15-03-PM-36-29' >>> ============================================================================================================================================================================================================================================================================================================================================================================================== RESTART: F:/U/python/drawdigt.py ============================================================================================================================================================================================================================================================================================================================================================================================== Traceback (most recent call last): File "F:/U/python/drawdigt.py", line 30, in main() File "F:/U/python/drawdigt.py", line 28, in main drawDate(datetime.datetime.now().strftime('%Y%m%d')) File "F:/U/python/drawdigt.py", line 22, in drawDate drawDigt(eval(i)) NameError: name 'drawDigt' is not defined >>> ============================================================================================================================================================================================================================================================================================================================================================================================== RESTART: F:/U/python/drawdigt.py ============================================================================================================================================================================================================================================================================================================================================================================================== Traceback (most recent call last): File "F:/U/python/drawdigt.py", line 30, in main() File "F:/U/python/drawdigt.py", line 28, in main drawDate(datetime.datetime.now().strftime('%Y%m%d')) File "F:/U/python/drawdigt.py", line 22, in drawDate drawDigit(eval(i)) File "F:/U/python/drawdigt.py", line 13, in drawDigit tutle.left(90) NameError: name 'tutle' is not defined >>> ============================================================================================================================================================================================================================================================================================================================================================================================== RESTART: F:/U/python/drawdigt.py ============================================================================================================================================================================================================================================================================================================================================================================================== >>> ============================================================================================================================================================================================================================================================================================================================================================================================== RESTART: F:/U/python/drawdigt.py ============================================================================================================================================================================================================================================================================================================================================================================================== >>> ============================================================================================================================================================================================================================================================================================================================================================================================== RESTART: F:/U/python/drawdigt.py ============================================================================================================================================================================================================================================================================================================================================================================================== >>> ------------------------------------------------------------------------------------
#darw seven seg display1.2 import turtle, datetime def drawGap(): turtle.penup() turtle.fd(5) def drawLine(draw): drawGap() turtle.pendown() if draw else turtle.penup() turtle.fd(40) drawGap() turtle.right(90) def drawDigit(d): drawLine(True) if d in [2,3,4,5,6,8,9] else drawLine(False) drawLine(True) if d in [0,1,3,4,5,6,7,8,9] else drawLine(False) drawLine(True) if d in [0,2,3,5,6,8,9] else drawLine(False) drawLine(True) if d in [0,2,6,8] else drawLine(False) turtle.left(90) drawLine(True) if d in [0,4,5,6,8,9] else drawLine(False) drawLine(True) if d in [0,2,3,5,6,7,8,9] else drawLine(False) drawLine(True) if d in [0,1,2,3,4,7,8,9] else drawLine(False) turtle.left(180) turtle.penup() turtle.fd(20) def drawDate(date): turtle.pencolor("red") for i in date: if i =='-': turtle.write('年',font =("Arial",18,"normal")) turtle.pencolor('green') turtle.fd(40) elif i =='=': turtle.write('月',font=("Arial",18,"normal")) turtle.pencolor("blue") turtle.fd(40) elif i=='+': turtle.write('日',font=("Arial",18,"normal")) else: drawDigit(eval(i)) def main(): turtle.setup(800,350,200,200) turtle.penup() turtle.fd(-300) turtle.pensize(5) drawDate(datetime.datetime.now().strftime('%Y-%m=%d+')) turtle.hideturtle() main()
---------------------