Shared2017-04-16-205437.ipynbOpen in CoCalc
Jupyter notebook 2017-04-16-205437.ipynb
second_per_hour = 60*60
print(second_per_hour)
0.1 * 3 - 0.3
5.551115123125783e-17
second_per_day = second_per_hour *24
print (second_per_day)
color = '''red and green
blue'''

print (color)
a = 99.0
type(a)
78%4

second_per_day = 86400
second_per_hour = 3600
second_per_day / second_per_hour
import random

number = random.randint(1, 20)
number
second_per_day = 86400
second_per_hour = 3600
second_per_day // second_per_hour
int(False)
print('Hello!')
print('What is your name?')
name = input()
# 'nice to meet you!'
print('Nice to meet you, ' + name + '.I am thinking of a number between 1 and 20.')

guessesTaken = 0

import random
number = random.randint(1, 20)

for guessesTaken in range(6):
    print('Take a guess.') 
    guess = input()
    guess = int(guess)
    
    if guess < number:
        print('Your guess is too low.') 

    if guess > number:
         print('Your guess is too high.')

    if guess == number:
           break
            
if guess == number:
    guessesTaken = str(guessesTaken + 1)
    print('Good job, ' + name + '! You guessed my number in ' + guessesTaken + ' guesses!')      
        
if guess != number:
    number = str(number)
    print('Nope. The number I was thinking of was ' + number + '.')


    

import random
random.randint(1, 4)
print('Hello!')
print ('Where are you going on Tuesday?')
place = input()
print('I want to go '+ place + ' with you')
wizard_list = [6,4,2,1]
print(wizard_list)
print(wizard_list)
number_STRINGS = ['hdgyj', 5, 'wgfs', 9]
print(number_STRINGS[2])
wizard_list[1] = 'I LOVE'
print(wizard_list[0:2])
print(wizard_list[0])
number=[4, 5, 7, 9]
STRINGS=['hdgyj', 'wgfs']
mylist=[number, STRINGS]
print(mylist)
mylist[0][1]
wizard_list.append('Kristina')
print(wizard_list)
list1 = [1, 2, 3, 4]
list2 = ['I', 'ate', 'chocolate', 'and', 'I', 'want', 'more']
list3 = list1 + list2
print(list3)
del wizard_list[3]
print(wizard_list)
list1 = [1, 2]
print(list1 * 5)
favorite_sports = {'Ralph Williams' : 'Football',
'Michael Tippett' : 'Basketball',
'Edward Elgar' : 'Baseball',
'Rebecca Clarke' : 'Netball',
'Ethel Smyth' : 'Badminton',
'Frank Bridge' : 'Rugby'}
print(favorite_sports['Frank Bridge'])
del favorite_sports['Rebecca Clarke']
print(favorite_sports)
favorite_sports['Ethel Smyth'] = 'swim'
print(favorite_sports)


games=['swim','run']
foods=['apple','cake']
favorites=foods+games
print(favorites)
ninjas_per_roof=25
root=3
samurai_per_tunnels=40
tunnels=2
print(ninjas_per_roof*root+samurai_per_tunnels*tunnels)
first_name= 'kristina'
last_name= 'nikoiaeva'
print('Hello,' +first_name + ' ' +last_name)

age =10
if age == 14:
    print('you are too old!')
    print("BGHFCGDF")
myval=None
print(myval)
None

age = "10"
if age == 10:
    print('you are too old!')
    print("BGHFCGDF")
age = 10
converted_age = str(age)

if converted_age == "10":
    print('you are too old!')
    print("BGHFCGDF")
age = "10.6"
converted_age = int(age)
age = "10.6"
converted_age = float(age)
print(converted_age)
money=2000
if money>1000:
      print("jdkjdfi")
else: r6f5n;/'[]'
      print("hfebsbn") 
twinkies = 550
if twinkies<100 or twinkies >500:
     print ("too many or too few")
money= 700
if (money >=100 and money <=500) or (money >=1000 and money <=5000): njbhh
ninjas = 5
if ninjas <10:
    print ("i can fight those ninjas")
elif ninjas <30:
    print ("it is be a strugge but i can teke em")
elif ninjas <50:
    print ("that is many ")
    
for i in range(0,5):
    print (i, "hello")
wizard_list= ["spider legs"," toe of frog", "snail tongue"]
for i in wizard_list:
    print (i)
wizard_list= ["spider legs","toe of frog", "snail tongue"]
print(wizard_list[0])
print(wizard_list[1])
print(wizard_list[2]) 
hugehairypants = ['huge', 'hairy', 'pants']
#k=1
for i in hugehairypants:
    print(i)
    #k=k+1
    for j in hugehairypants:
             print('2 '+j)
found_coins=20
magic_coins=70
stolen_coins=3
coins = found_coins
for week in range(1,8):
    coins= coins + magic_coins - stolen_coins
    print("Week %s = %s" % (week, coins))
tired = Trueadweather = Falsenstep=0
while step <10:
    print(step)
    if tired == True:
        break
    elif badweather==True:
        break
    else:
        step= step+1
x=45
y=80
while x<50 and y<100:
    x=x+1
    y=y+1
    print(x,y)
# Номер 2:
# способ 1
age=[1,3,5,7,9,11,13]
for odd in age:
    print(odd)
# Номер 2:
# способ 2
for x in range(1, 14, 2):
    print(x)
#номер 3
count=0

ingredients = ['snails', 'leeches', 'gorilla belly-button lint', 'caterpillar eyebrows', 'centipede toes']
for i in ingredients:
    count = count+1
    print '%s %s' % (count, i)
#номер 4
kilo=30

for i in range(1, 16):
    weight_On_moon=kilo*0.165
    print 'Year %s is %s' % (i, round(weight_On_moon, 2))
    kilo=kilo+1

Глава 7 recycling your code with functions and modules

# стр. 82
list(range(0,5))
# стр. 83
def testfunc(myname):
    print("hello %s" % myname)

testfunc("Kristina")
#стр.83
def testfunc(Tom, Richerd):
    print("hello %s %s" % (Tom, Richerd))

testfunc("Tom","Richerd")
hello Tom Richerd
#стр.83
firstname="Nina"
lastname="Tana"
testfunc(firstname, lastname)
--------------------------------------------------------------------------- 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
#стр.84
def savings(m,d,c):
    return m+d-c

print(savings(10,10,5))
15
#стр.84
def variable_test():
    first_variable=10
    second_variable=20
    return first_variable * second_variable

print(variable_test())
200
# стр86
def spaceip_buding(cans):
    total_cans=0
    for week in range(1, 53):
        total_cans= total_cans+cans  
        print("Week %s=%s cans" %(week,total_cans))
# стр 85
spaceip_buding(2)
#стр 87
import time
print (time.asctime())
Mon Jan 8 13:39:37 2018
# номер 1 и 2
def moon_weight(kilo, increase, years):
    for year in range(1, years+1):
        moon_weight= kilo*0.165 
        print 'Year %s is %s' % (year, round(moon_weight, 4))
        kilo=kilo+increase
        
moon_weight(4, 26, 2)
Year 1 is 0.66 Year 2 is 4.95
import sys
print(sys.stdin.readline())
# стр 89
def silly_age_joke():
    print("How old are you?")
    #age = int(sys.stdin.readline())
    age = int(input())
    if age >= 10 and age <= 13:
        print("what is 13+49+84+155+97? A headache!")
    else:
        print("huh?")
        
silly_age_joke()
How old are you?
def moon_weight (kilo, increase, years):
    print("How old are you?")
    #age = int(sys.stdin.readline())
     age = int(input())
          print("what is 13+49+84+155+97? A headache!")
    else:
        print("huh?")
        
moon_weight()  

как пользоваться кассами и объектами

#стр96
class Things:
    pass
#стр 97
class Inanimate(Things):
    pass

class Animals(Animate):
    def breathe(self):
        print("breathe")
    def move(self):
        print("move")
    def eat_food(self):
        print("eat_food")
    
class Mammals(Animals):
    def feed_young_with_milk(self):
        print("feed_young_with_milk")

class Giraffes(Mammals):
    def eat_leaves_from_trees(self):
        print("eat_leaves_from_trees")
    def find_food(self):
        self.move()
        print("find_food")
        self.eat_food()
    def eat_leaves_from_trees(self):
        self.eat_food()
    def dance_a_jig(self):
        self.move()
        self.move()
        self.move()
        self.move()
                
reginald=Giraffes()
harold=Giraffes()
reginald.move()
harold.eat_leaves_from_trees()
reginald.breathe()
reginald.eat_food()
reginald.feed_young_with_milk()
reginald.dance_a_jig()
move eat_food breathe eat_food feed_young_with_milk move move move move
# стр 108
class Giraffes_new:
    def __init__(self, spots): 
        self.giraffe_spots = spots
        
ozwald = Giraffes_new(spots=100)
gertrude = Giraffes_new(spots=150)
print(ozwald.giraffe_spots)
print(gertrude.giraffe_spots)             
100 150
# встроенные функции python ГЛАВА 9
#стр 111
steps = -3
if abs(steps) > 0:
    print(steps)
-3
#стр 111
year = 'a'
steps = -3
if steps < 0 or steps > 0 :
    print(steps)
-3
#стр 112
print(bool(0))
print(bool(1))
print(bool(1123.23))
print(bool(-500))
False True True True
#стр 112
my_sill_list=[]
print(bool(my_sill_list))
my_sill_list=['a','d']
print(bool(my_sill_list))
False True
#
fgg = '   '
fgg.rstrip()  
''
#стр113
dir(["hj", "hkl"])
Unsupported message: {"data":{},"execution_count":12,"metadata":{},"output_type":"execute_result"}
#стр 114
dir(1)
['__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']
#
popcorn="iuj"
dir(popcorn)
['__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']
#
p = 'kjgh'
p.upper()
'KJGH'
#
year = 'a'
steps = -3
if steps < 0 or steps > 0 :
    print(steps)
-3
#
print(bool(0))
print(bool(1))
print(bool(1123.23))
print(bool(-500))
False True True True
#
my_sill_list=[]
print(bool(my_sill_list))
my_sill_list=['a','d']
print(bool(my_sill_list))
False True
#
fgg = input("dmdmcf")
if not bool(fgg.rstip()):
    print("year.rstip")
    
#
dir(["hj", "hkl"])
#
dir(1)
File "<ipython-input-22-29d0b8591a2d>", line 3 popcorn."upper" ^ SyntaxError: invalid syntax
#
popcorn="bnfbc"

popcorn.upper()

'BNFBC'
#стр 115
eval("10*5")
50
#стр 116
eval("8+8")
16
#
your_calculation = input("Введите выражение:")
eval(your_calculation)
--------------------------------------------------------------------------- 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:
#
my_small_program = '''print("rreted")
print('fsas')'''
exec(my_small_program)
rreted fsas
#стр 117
float("12")
12.0
#стр 117
float("123.123")
123.123
#стр 118
your_age = input("ввудите ваш возрат:")
age = float(your_age)
if age > 13:
    print("вы на %s лет старше, чем положено" % (age - 13))
--------------------------------------------------------------------------- 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:
#стр 118
int(123.456)
123
#стр 118
len('это тестовая строка')
36
#стр 119
creature_list=["школа", "дом"]
print(len(creature_list))
2
#стр 119
frute = ["яблоко","банан","киви"]
length = len(frute)
for x in range(0, length):
    print("фрукт с индексом %s: %s" % (x, frute[x]))
фрукт с индексом 0: яблоко фрукт с индексом 1: банан фрукт с индексом 2: киви
#стр 120
number=[5,6,31,56]
print(max(number))
56
#стр 120
number=[5,6,31,56]
print(min(number))
#стр120
Guess_this_number=61
player_guesses= [12,23,56,57]
if max(player_guesses)> Guess_this_number:
        print("проиграли")
else:
        print("победил")
победил
#стр 121
for x in range(0,5):
    print(x)
0 1 2 3 4
#cтр 122
print(list(range(0,5)))
[0, 1, 2, 3, 4]
#стр 122

count_down_by_twos=list(range(40, 10, -2))
print(count_down_by_twos)
[40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12]
#стр 122
my_list_of_numers =list(range(0, 500, 50))  
print(my_list_of_numers)
print(sun(my_list_of_numers))
--------------------------------------------------------------------------- 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
print(list(xrange(0,5)))

[0, 1, 2, 3, 4]
#стр 122

s = 'this if is you not are a reading very this good then way you to have hide done a it message wrong'
print(dir(s))
['__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']
help(s.split)
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.
words = s.split()
words
['this', 'if', 'is', 'you', 'not', 'are', 'a', 'reading', 'very', 'this', 'good', 'then', 'way', 'you', 'to', 'have', 'hide', 'done', 'a', 'it', 'message', 'wrong']
words = s.split()
for x in xrange(0, len(words), 2):
    print(words[x])
this is not a very good way to hide a message
# стр 130
class Animal:
    def __init__(self, species, number_of_legs, color):
        self.species = species
        self.number_of_legs = number_of_legs
        self.color=color
# стр 130
import copy 
harry = Animal('гиппогриф', 6, "розовый")
harriet = copy.copy(harry)
print(harry.species)
print(harriet.species)
гиппогриф гиппогриф
# стр 130
harry = Animal('гиппогриф', 6, "розовый")
carrie = Animal("химера", 4, "в зеленый горошек")
billty = Animal("богл", 0,"узочатый")
my_animals = [harry, carrie, billty]
more_animals = copy.copy(my_animals)
print(more_animals[0].species)
print(more_animals[1].species)
гиппогриф химера
# стр 131
my_animals[0].species = "вомпир"
print(my_animals[0].species)
print(more_animals[0].species)
вомпир вомпир
# стр 131
sally = Animal("сфинкс",4, "песочный")
my_animals.append(sally)
print(len(my_animals))
print(len(more_animals))
4 3
# стр 131
more_animals = copy.deepcopy(my_animals)
my_animals[0].species = "дракон"
print(my_animals[0].species)
print(more_animals[0].species)

дракон гиппогриф
# стр 132
import keyword 
print(keyword.iskeyword("if"))
print(keyword.iskeyword("ozwald"))
print(keyword.kwlist)
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']
# стр 133
import random 
print(random.randint(1, 100))
print(random.randint(100, 1000))
print(random.randint(1000, 5000))
30 335 2491
# стр 133
import random 
num = random.randint(1, 100)
while True:
    print("угадай число от 1 до 100")
    guess = input()
    i = int(guess)
    if i == num:
        print("правильно!")
        break
    elif i < num:
        print("загаданное число больше")
    elif i > num:
        print("загаданное число меньше ")
угадай число от 1 до 100 55 загаданное число больше угадай число от 1 до 100 66 загаданное число больше угадай число от 1 до 100 777 загаданное число меньше угадай число от 1 до 100 88 загаданное число больше угадай число от 1 до 100 99 загаданное число меньше угадай число от 1 до 100 93 загаданное число меньше угадай число от 1 до 100 91 правильно!
# стр 135
import random
desserts = ['мороженое', 'кекс ']
print(random.choice(desserts))
кекс
# стр 135
import random
desserts = ['мороженое', 'кекс ']
print(random.choice(desserts))
#стр 136
import sys
sys.exit()
#стр 137
import sys
v = sys.stdin.readline(3)
print(v)
#стр 137
import sys
sys.stdout.write('у кого есть печенька?')
#стр 137
import sys
print(sys.version)
#стр 137
import time
print(time.time())
#стр 138
def lot_of_numbers(max):
    t1 = time.time
    for x in range(0, max):
        print(x)
    t2 = time.time
    print("прошло %s секунд" % (t1-t2))
#стр 139
import time
print(time.asctime())

#стр 139
import time
t= (2020, 2, 23,10)
print(time.asctime(t))

#стр 140
import time
print(time.localtime())

#стр 140
t = time.localtime()
year = t[0]
month = t[1]
print(year)
print(month)
#стр 140
for x range(1, 61)
    print(x)
    time.sleep(1)
#стр 141
import pickle
game_date = {
save_file = open("save.dat", "wd")
pickle.dump(game_data, save_file)
save_file.close()
File "<ipython-input-8-7471ce9ef990>", line 4 save_file = open("save.dat", "wd") ^ SyntaxError: invalid syntax
#стр 141
load_file = open("save.dat", "rd")
loaded_game_date = pickle.load(load_file)
load_file.close()
print(loaded_game_data)
--------------------------------------------------------------------------- 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'
import pickle
love_me = ("мяуконьку", "наташу","себя")
save_file = open("favorites.dat", "wd")
pickle.dump(love_me, save_file)
save_file.close()
def mysquare(size, filled):
if filled == True:
t.begin_fill()
for x in range(1, 5):
t.forward(size)
t.left(90)
if filled == True:
t.end_fill()
from thinter import *
import random
import time

class Ball:
    def __init__(self, canvas, paddle, color):
        self.canvas = canvas
        self.canvas = paddle
        self.id = canvas.create_oval(10, 10, 25, 25, fill=color)
        self.canvas.move(self.id, 245, 100)
        starts = [-3, -2, -1, 1, 2, 3]
        random.shuffle(starts)
        self.x = starts[0]
        self.y = -3
        self.canvas_height = self.canvas.winfo_height()
        self.canvas_width = self.canvas.winfo_width()
        self.hit_bottom = False
        
    def hit_paddle(self, pos):
        paddle_pos = self.canvas_pos.coords(self.paddle.id)
        if pos[2] >= paddle_pos[0] and pos[0] <= paddle_pos[2]:
            if pos[3] >= paddle_pos[1] and pos[3] <= paddle_pos[3]:
            return True
        return False       
               
                                        
    def draw(self):
        self.canvas.move(self.id, self.x, self.y)
        pos = self.canvas.coords(self.id)
        if pos[1] <= 0:
            self.y = 3
        if pos[3] >= self.canvas_height:
            self.hit_bottom = True
        if self.hit_paddle(pos) == True:                
            self.y = -3
        if pos[0] <= 0:
            self.x = 3
            if pos[2] >= self.canvas_width:
            self.x = -3 
     
            
    def turn_left(self, evt):
        self.x = 2 
    def turn_right(self, evt):
        self.x = 2 
            
class Paddle:
    def_init_(self, canvas, color):
        self.canvas = canvas
        self.id = canvas.create_rectangle(0, 0, 100, 10)
        fill = color)
        self.canvas.move(self.id, 200, 300)
        self.x = 0
        self.canvas_width = self.canvas.winfo_width()
        self.canvas.bind_all("<Keypress-Left>", self.turn_left)
        self.canvas.bind_all("<Keypress-Left>", self.turn_right)
        
    def draw(self):
        self.canvas.move(self.id, self.x, 0)
        pos = self.canvas.coords(self.id)
        if pos[0] <= 0:
            self.x = 0
        elif[2] >= self.canvas_widht:
            self.x = 0
            
    def turn_left(self, evt):
        self.x = 2 
        
    def turn_right(self, evt):
        self.x = 2 
            

tk =TK()
tk.title('Игра')
tk.resizable(0,0)
tk.wm_attributes('-topmost', 1)
canvas = Canvas(tk, width=500, height=400, bd=0,highlightthickness=0)
canvas.pack()
tk.update()

paddle = Paddle(canvas, "blue")
ball = Ball(canvas, paddle, 'red')

while l:
    if ball.hit_bottom == False:
        ball.draw()
        paddle.draw()
    tk.update_indletasks()
    tk.update()
    time.sleep(0.01)
















from thinter import *
tk = TK
btn = Button(tk, text="нажми меня")
btn.pack()
import turtle
t = turtle.Pen()
from turtle import *
t = Pen()
def hello():
    print ('привет')
from thinter import *
tk = TK
btn Button(tk, text="нажми меня", command=hello)
btn.pack() 
def person(width. height):
    print('моя ширина- %s, а высота - %s' %(width, height ))
person(4,3)
from thinter import *
tk = Tk
cavas = Canvas(tk, width=500, height=500)
canvas.pack()
from thinter import *
tk = Tk
cavas = Canvas(tk, width=500, height=500)
canvas.pack()
canvas.create_line(0, 0, 500, 500)
import turtle 
turtle.setup(width=500, height=500)
t = turtle.Pen()
t.up()
t.goto(-250, 250)
t.down()
t.goto(500, -500)
from thinter import *
tk = Tk
cavas = Canvas(tk, width=400, height=400)
canvas.pack()
canvas.create_line(10, 10, 50, 50)
from thinter import *
tk = Tk
cavas = Canvas(tk, width=400, height=400)
canvas.pack()
canvas.create_line(10, 10, 300, 50)
from thinter import *
tk = TK
canvas = Canvas(tk, width=400, height=400)
canvas.pack()
def  random_rectangle(width, height):
        x1 = random.randrange(width)
        y1 = random.randrange(height)
        x2 = x1 + random.randrange(width)
        y2 = y1 + random.randrange(height)
        canvas.random_rectangle(x1, y1, x2, y2)
random_rectangle(400, 400)
for x range(0, 400):
    random_rectangle(400, 400)
from thinter import *
import random 
tk = TK()
cavas = Canvas(tk, width=400, height=400)
canvas.pack()

def  random_rectangle(width, height, fill_color):
        x1 = random.randrange(width)
        y1 = random.randrange(height)
        x2 = random.randrange(x1 + random.randrange (width))
        y2 = random.randrange(y2 + random.randrange (height))
        canvas.random_rectangle(x1, y1, x2, y2, fill_color)
random.randrange(400, 400, "green")
random.randrange(400, 400, "red")
random.randrange(400, 400, "blue")
random.randrange(400, 400, "orange")
random.randrange(400, 400, "yellow")
random.randrange(400, 400, "pink")
random.randrange(400, 400, "purple")
random.randrange(400, 400, "violet")
random.randrange(400, 400, "magenta")
random.randrange(400, 400, "cyan")
random_rectangle(400, 400, '#ffd800')
print("%x" % 15)
print("%02x" % 15)
from thinter import *
colorchoose.askcolor()
colorchoose.askcolor()
c = colorchoose.askcolor()
random_rectangle(400, 400, c[1])
canvas.create_arc(10, 10, 200, 100, extent=180, style=ARC)
from thinter import *
import random 
tk = TK()
cavas = Canvas(tk, width=400, height=400)
canvas.pack()
canvas.create_arc(10, 10, 200, 100, extent=180, style=ARC)
from thinter import *
import random 
tk = TK()
cavas = Canvas(tk, width=400, height=400)
canvas.pack()
canvas.create_arc(10, 10, 200, 80, extent=45, style=ARC)
canvas.create_arc(10, 80, 200, 160, extent=90, style=ARC)
canvas.create_arc(10, 160, 200, 240, extent=135, style=ARC)
canvas.create_arc(10, 240, 200, 320, extent=180, style=ARC)
canvas.create_arc(10, 320, 200, 400, extent=359, style=ARC)
--------------------------------------------------------------------------- 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
from thinter import *
import random 
tk = TK()
cavas = Canvas(tk, width=400, height=400)
canvas.pack()
canvas.create_polygon(10, 10, 100, 10, 100, 110, fill='',
outline="black")
canvas.create_polygon(200, 10, 240, 30, 120, 100, 140, 120, fill='',
outline="black")
from thinter import *
import random 
tk = TK()
cavas = Canvas(tk, width=400, height=400)
canvas.pack()
canvas.create_text(150, 100, text="был один человек из Тулузы,")
canvas.create_text(130, 120, text="что сидел на  огромном арбузе,"
fill="red")
canvas.create_text(150, 150, text='Он сказал: "Это ужас,',
font=('Times', 15))
canvas.create_text(200, 200, text='Но бывает и хуже:',
font=('Helvetica', 20))
canvas.create_text(220, 250, text='Вон мой братец сидит',
font=('Courier', 22))
canvas.create_text(220, 300, text='На медузе".', font=('Courier',
30))