Python 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:19:22) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> 4.5 and 4.6
4.6
>>> 3.2 and -4.5
-4.5
>>> 3.2 and(-4.5)
-4.5
>>> (-2.3 )and(-6.1)
-6.1
>>> -(2.3 )and(-6.1)
-6.1
>>> -((2.3 )and(-6.1))
6.1
>>> 4.5 &3.4
Traceback (most recent call last):
File "", line 1, in
4.5 &3.4
TypeError: unsupported operand type(s) for &: 'float' and 'float'
>>> 4.3>>2
Traceback (most recent call last):
File "", line 1, in
4.3>>2
TypeError: unsupported operand type(s) for >>: 'float' and 'int'
>>> random.random()
Traceback (most recent call last):
File "", line 1, in
random.random()
NameError: name 'random' is not defined
>>> import random
>>> random.random()
0.7720802147573392
>>> choice()
Traceback (most recent call last):
File "", line 1, in
choice()
NameError: name 'choice' is not defined
>>> random.choice()
Traceback (most recent call last):
File "", line 1, in
random.choice()
TypeError: choice() takes exactly 2 arguments (1 given)
>>> random.choice(2.3,4.5)
Traceback (most recent call last):
File "", line 1, in
random.choice(2.3,4.5)
TypeError: choice() takes exactly 2 arguments (3 given)
>>> random.choice(2,4)
Traceback (most recent call last):
File "", line 1, in
random.choice(2,4)
TypeError: choice() takes exactly 2 arguments (3 given)
>>> random.choice(5)
Traceback (most recent call last):
File "", line 1, in
random.choice(5)
File "C:\Python27\lib\random.py", line 275, in choice
return seq[int(self.random() * len(seq))] # raises IndexError if seq is empty
TypeError: object of type 'int' has no len()
>>> random.choice('hellowi')
'w'
>>> random.randint(2,9)
3
>>> random.random()
0.8852638844287753
>>> random.randint()
Traceback (most recent call last):
File "", line 1, in
random.randint()
TypeError: randint() takes exactly 3 arguments (1 given)
>>> random.randint()
Traceback (most recent call last):
File "", line 1, in
random.randint()
TypeError: randint() takes exactly 3 arguments (1 given)
>>> random.randint(9)
Traceback (most recent call last):
File "", line 1, in
random.randint(9)
TypeError: randint() takes exactly 3 arguments (2 given)
>>> random.randint(1,56)
4
>>> random.randrange(1,5)
3
>>> random.uniform(2,9)
4.73764451150299
>>> a=raw_input('shuru')
shuru200.3
>>> a
'200.3'
>>> a=int(raw_input('shuru'))
shuru200.3
Traceback (most recent call last):
File "", line 1, in
a=int(raw_input('shuru'))
ValueError: invalid literal for int() with base 10: '200.3'
>>> print eval('1+1')
2
>>> print eval('hello')
Traceback (most recent call last):
File "", line 1, in
print eval('hello')
File "", line 1, in
NameError: name 'hello' is not defined
>>> print eval('3.4')
3.4
>>> import sys
>>> sys.maxint
2147483647
>>> sys.maxlong
Traceback (most recent call last):
File "", line 1, in
sys.maxlong
AttributeError: 'module' object has no attribute 'maxlong'
>>> dir(sys)
['__displayhook__', '__doc__', '__excepthook__', '__name__', '__package__', '__stderr__', '__stdin__', '__stdout__', '_clear_type_cache', '_current_frames', '_getframe', '_mercurial', 'api_version', 'argv', 'builtin_module_names', 'byteorder', 'call_tracing', 'callstats', 'copyright', 'displayhook', 'dllhandle', 'dont_write_bytecode', 'exc_clear', 'exc_info', 'exc_traceback', 'exc_type', 'exc_value', 'excepthook', 'exec_prefix', 'executable', 'exit', 'flags', 'float_info', 'float_repr_style', 'getcheckinterval', 'getdefaultencoding', 'getfilesystemencoding', 'getprofile', 'getrecursionlimit', 'getrefcount', 'getsizeof', 'gettrace', 'getwindowsversion', 'hexversion', 'last_traceback', 'last_type', 'last_value', 'long_info', 'maxint', 'maxsize', 'maxunicode', 'meta_path', 'modules', 'path', 'path_hooks', 'path_importer_cache', 'platform', 'prefix', 'py3kwarning', 'setcheckinterval', 'setprofile', 'setrecursionlimit', 'settrace', 'stderr', 'stdin', 'stdout', 'subversion', 'version', 'version_info', 'warnoptions', 'winver']
>>> a=1
>>> while type(a) == type(1):
a*=2
maxint = a-1
File "", line 4
maxint = a-1
^
IndentationError: unindent does not match any outer indentation level
>>> a=1
>>> while type(a) == type(1):
a*=2
>>> maxint=a
>>> minint=-a
>>> maxint=a-1
>>> print maxint,minint
0 -1
>>> a=1
>>> while type(a)==int:
a*=2
maxint=a-1
File "", line 4
maxint=a-1
^
IndentationError: unindent does not match any outer indentation level
>>>
>>> a=1
>>> while type(a)==int:
a*=2
SyntaxError: invalid syntax
>>> a=1
>>> while type(a) == int:
a*=2
>>> maxint = a-1
>>> minint = -a
>>> print maxint,minint
2147483647 -2147483648
>>> 9.0/5.9
1.5254237288135593
>>> a='hello'
>>> type(a)
>>> a=u'hello'
>>> type(a)
>>> #-*- coding:utf-8 -*-
>>> type('hello')
>>> a='hello'
>>> b='world'
>>> ls=[a,b]
>>> ls
['hello', 'world']
>>> join(ls)
Traceback (most recent call last):
File "", line 1, in
join(ls)
NameError: name 'join' is not defined
>>> join(a,b)
Traceback (most recent call last):
File "", line 1, in
join(a,b)
NameError: name 'join' is not defined
>>> a='sthirnghello'
>>> a[-1:-9]
''
>>> a[-9:-1]
'irnghell'
>>> a[-1]
'o'
>>> a[-9:0]
''
>>> a[-9:-1]
'irnghell'
>>> a[-9:]
'irnghello'
>>> a[-2:]
'lo'
>>> a[]
SyntaxError: invalid syntax
>>> a[:]
'sthirnghello'
>>> 'hello world python'[-100:100]
'hello world python'
>>> a[-9:-1]
'irnghell'
>>> a[-len(a):-1]
'sthirnghell'
>>> a[:-len(a)]
''
>>> a[:-len(a)+1]
's'
>>> a[None]
Traceback (most recent call last):
File "", line 1, in
a[None]
TypeError: string indices must be integers, not NoneType
>>> a='hello python'
>>> for i in [None] + range(-1,-len(a),-1):
print a[:i]
hello python
hello pytho
hello pyth
hello pyt
hello py
hello p
hello
hello
hell
hel
he
h
>>> b=[None].extend(range(-1,-len(a),-1))
>>> b
>>> b
>>> print b
None
>>> str([1,2,'hello'])
"[1, 2, 'hello']"
>>> a=[1,2,3]
>>> list(a)
[1, 2, 3]
>>> id(a)
51009256
>>> id(list(a))
51007776
>>> a=[1,2,3]
>>> b=list(a)
>>> a is b
False
>>> id(a)
51008896
>>> id(b)
51015848
>>> a=[1,2,3]
>>> b=a
>>> a is b
True
>>> b.append(100)
>>> a
[1, 2, 3, 100]
>>> b
[1, 2, 3, 100]
>>> c=123
>>> d=123
>>> a is d
False
>>> c is d
True
>>> e=[1,2,3]
>>> b=[1,2,3]
>>> e is b
False
>>> f=e
>>> e is f
True
>>>