| Download
Jupyter notebook 2017-04-16-205437.ipynb
Project: My project
Path: 2017-04-16-205437.ipynb
Views: 97Kernel: Python 2 (SageMath)
In [ ]:
In [2]:
5.551115123125783e-17
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
Глава 7 recycling your code with functions and modules
In [ ]:
In [ ]:
In [7]:
hello Tom Richerd
In [6]:
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-6-aacd33165676> in <module>()
2 firstname="Nina"
3 lastname="Tana"
----> 4 testfunc(firstname, lastname)
NameError: name 'testfunc' is not defined
In [5]:
15
In [3]:
200
In [4]:
In [ ]:
In [44]:
Mon Jan 8 13:39:37 2018
In [43]:
Year 1 is 0.66
Year 2 is 4.95
In [52]:
In [ ]:
How old are you?
In [ ]:
как пользоваться кассами и объектами
In [3]:
In [48]:
move
eat_food
breathe
eat_food
feed_young_with_milk
move
move
move
move
In [51]:
100
150
In [ ]:
In [11]:
-3
In [10]:
-3
In [13]:
False
True
True
True
In [16]:
False
True
In [11]:
''
In [12]:
MIME type unknown not supported
In [19]:
['__abs__',
'__add__',
'__and__',
'__class__',
'__cmp__',
'__coerce__',
'__delattr__',
'__div__',
'__divmod__',
'__doc__',
'__float__',
'__floordiv__',
'__format__',
'__getattribute__',
'__getnewargs__',
'__hash__',
'__hex__',
'__index__',
'__init__',
'__int__',
'__invert__',
'__long__',
'__lshift__',
'__mod__',
'__mul__',
'__neg__',
'__new__',
'__nonzero__',
'__oct__',
'__or__',
'__pos__',
'__pow__',
'__radd__',
'__rand__',
'__rdiv__',
'__rdivmod__',
'__reduce__',
'__reduce_ex__',
'__repr__',
'__rfloordiv__',
'__rlshift__',
'__rmod__',
'__rmul__',
'__ror__',
'__rpow__',
'__rrshift__',
'__rshift__',
'__rsub__',
'__rtruediv__',
'__rxor__',
'__setattr__',
'__sizeof__',
'__str__',
'__sub__',
'__subclasshook__',
'__truediv__',
'__trunc__',
'__xor__',
'bit_length',
'conjugate',
'denominator',
'imag',
'numerator',
'real']
In [20]:
['__add__',
'__class__',
'__contains__',
'__delattr__',
'__doc__',
'__eq__',
'__format__',
'__ge__',
'__getattribute__',
'__getitem__',
'__getnewargs__',
'__getslice__',
'__gt__',
'__hash__',
'__init__',
'__le__',
'__len__',
'__lt__',
'__mod__',
'__mul__',
'__ne__',
'__new__',
'__reduce__',
'__reduce_ex__',
'__repr__',
'__rmod__',
'__rmul__',
'__setattr__',
'__sizeof__',
'__str__',
'__subclasshook__',
'_formatter_field_name_split',
'_formatter_parser',
'capitalize',
'center',
'count',
'decode',
'encode',
'endswith',
'expandtabs',
'find',
'format',
'index',
'isalnum',
'isalpha',
'isdigit',
'islower',
'isspace',
'istitle',
'isupper',
'join',
'ljust',
'lower',
'lstrip',
'partition',
'replace',
'rfind',
'rindex',
'rjust',
'rpartition',
'rsplit',
'rstrip',
'split',
'splitlines',
'startswith',
'strip',
'swapcase',
'title',
'translate',
'upper',
'zfill']
In [33]:
'KJGH'
In [ ]:
-3
In [13]:
False
True
True
True
In [16]:
False
True
In [ ]:
In [ ]:
In [22]:
File "<ipython-input-22-29d0b8591a2d>", line 3
popcorn."upper"
^
SyntaxError: invalid syntax
In [34]:
'BNFBC'
In [26]:
50
In [40]:
16
In [45]:
---------------------------------------------------------------------------
KeyboardInterrupt Traceback (most recent call last)
<ipython-input-45-159418dd1e41> in <module>()
----> 1 your_calculation = input("Введите выражение:")
2 eval(your_calculation)
/ext/sage/sage-8.1/local/lib/python2.7/site-packages/ipykernel/ipkernel.pyc in <lambda>(prompt)
162 self._sys_eval_input = builtin_mod.input
163 builtin_mod.raw_input = self.raw_input
--> 164 builtin_mod.input = lambda prompt='': eval(self.raw_input(prompt))
165 self._save_getpass = getpass.getpass
166 getpass.getpass = self.getpass
/ext/sage/sage-8.1/local/lib/python2.7/site-packages/ipykernel/kernelbase.pyc in raw_input(self, prompt)
703 self._parent_ident,
704 self._parent_header,
--> 705 password=False,
706 )
707
/ext/sage/sage-8.1/local/lib/python2.7/site-packages/ipykernel/kernelbase.pyc in _input_request(self, prompt, ident, parent, password)
733 except KeyboardInterrupt:
734 # re-raise KeyboardInterrupt, to truncate traceback
--> 735 raise KeyboardInterrupt
736 else:
737 break
KeyboardInterrupt:
In [46]:
rreted
fsas
In [47]:
12.0
In [48]:
123.123
In [50]:
---------------------------------------------------------------------------
KeyboardInterrupt Traceback (most recent call last)
<ipython-input-50-befd8ffc0985> in <module>()
----> 1 your_age = input("ввудите ваш возрат:")
2 age = float(your_age)
3 if age > 13:
4 print("вы на %s лет старше, чем положено" % (age - 13))
/ext/sage/sage-8.1/local/lib/python2.7/site-packages/ipykernel/ipkernel.pyc in <lambda>(prompt)
162 self._sys_eval_input = builtin_mod.input
163 builtin_mod.raw_input = self.raw_input
--> 164 builtin_mod.input = lambda prompt='': eval(self.raw_input(prompt))
165 self._save_getpass = getpass.getpass
166 getpass.getpass = self.getpass
/ext/sage/sage-8.1/local/lib/python2.7/site-packages/ipykernel/kernelbase.pyc in raw_input(self, prompt)
703 self._parent_ident,
704 self._parent_header,
--> 705 password=False,
706 )
707
/ext/sage/sage-8.1/local/lib/python2.7/site-packages/ipykernel/kernelbase.pyc in _input_request(self, prompt, ident, parent, password)
733 except KeyboardInterrupt:
734 # re-raise KeyboardInterrupt, to truncate traceback
--> 735 raise KeyboardInterrupt
736 else:
737 break
KeyboardInterrupt:
In [53]:
123
In [56]:
36
In [57]:
2
In [59]:
фрукт с индексом 0: яблоко
фрукт с индексом 1: банан
фрукт с индексом 2: киви
In [61]:
56
In [ ]:
In [65]:
победил
In [1]:
0
1
2
3
4
In [2]:
[0, 1, 2, 3, 4]
In [6]:
[40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12]
In [28]:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-28-61d517082598> in <module>()
1 #стр 122
----> 2 my_list_of_numers =list(range(0, 500, 50))
3 print(my_list_of_numers)
4 print(sun(my_list_of_numers))
TypeError: 'tuple' object is not callable
In [20]:
[0, 1, 2, 3, 4]
In [ ]:
In [ ]:
In [31]:
In [32]:
['__add__', '__class__', '__contains__', '__delattr__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__getslice__', '__gt__', '__hash__', '__init__', '__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '_formatter_field_name_split', '_formatter_parser', 'capitalize', 'center', 'count', 'decode', 'encode', 'endswith', 'expandtabs', 'find', 'format', 'index', 'isalnum', 'isalpha', 'isdigit', 'islower', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'partition', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']
In [33]:
Help on built-in function split:
split(...)
S.split([sep [,maxsplit]]) -> list of strings
Return a list of the words in the string S, using sep as the
delimiter string. If maxsplit is given, at most maxsplit
splits are done. If sep is not specified or is None, any
whitespace string is a separator and empty strings are removed
from the result.
In [47]:
['this',
'if',
'is',
'you',
'not',
'are',
'a',
'reading',
'very',
'this',
'good',
'then',
'way',
'you',
'to',
'have',
'hide',
'done',
'a',
'it',
'message',
'wrong']
In [57]:
this
is
not
a
very
good
way
to
hide
a
message
In [2]:
In [7]:
гиппогриф
гиппогриф
In [8]:
гиппогриф
химера
In [6]:
вомпир
вомпир
In [9]:
4
3
In [10]:
дракон
гиппогриф
In [11]:
True
False
['and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'exec', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'not', 'or', 'pass', 'print', 'raise', 'return', 'try', 'while', 'with', 'yield']
In [12]:
30
335
2491
In [24]:
угадай число от 1 до 100
55
загаданное число больше
угадай число от 1 до 100
66
загаданное число больше
угадай число от 1 до 100
777
загаданное число меньше
угадай число от 1 до 100
88
загаданное число больше
угадай число от 1 до 100
99
загаданное число меньше
угадай число от 1 до 100
93
загаданное число меньше
угадай число от 1 до 100
91
правильно!
In [25]:
кекс
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [8]:
File "<ipython-input-8-7471ce9ef990>", line 4
save_file = open("save.dat", "wd")
^
SyntaxError: invalid syntax
In [9]:
---------------------------------------------------------------------------
IOError Traceback (most recent call last)
<ipython-input-9-e4b37dc0c994> in <module>()
1 #стр 141
----> 2 load_file = open("save.dat", "rd")
3 loaded_game_date = pickle.load(load_file)
4 load_file.close()
5 print(loaded_game_data)
IOError: [Errno 2] No such file or directory: 'save.dat'
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [2]:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-2-72d1560d6360> in <module>()
----> 1 from thinter import *
2 import random
3 tk = TK()
4 cavas = Canvas(tk, width=400, height=400)
5 canvas.pack()
ImportError: No module named thinter
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [1]:
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-1-4bae1a225005> in <module>()
----> 1 number = random.randint(1, 20)
NameError: name 'random' is not defined
In [ ]:
In [ ]:
In [ ]:
In [ ]: