This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- encoding: utf-8 -*- | |
""" | |
Определение и использование | |
""" | |
a = 3 # name created | |
b = 4 | |
print b * 3, b / 2 # multiplication (4*3), division (4/2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- encoding: utf-8 -*- | |
""" | |
Неявное преобразование целых в вещественные | |
""" | |
a = 3 # name created | |
b = 4 | |
print 2 + 4.0, 2.0 ** b # mixed-type conversions |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- encoding: utf-8 -*- | |
""" | |
Единица - это истина | |
""" | |
if 1: | |
print 'true' | |
if not 1: | |
print 'true' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- encoding: utf-8 -*- | |
""" | |
Сага о кавычках | |
""" | |
print 'spam eggs' | |
print 'doesn\'t' | |
print "doesn't" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- encoding: utf-8 -*- | |
""" | |
Вывод строки | |
""" | |
i = 256 * 256 | |
print 'The value of i is', i |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- encoding: utf-8 -*- | |
""" | |
Определение | |
""" | |
a = ['spam', 'eggs', 100, 1234] | |
print a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- encoding: utf-8 -*- | |
""" | |
Двумерный список | |
""" | |
matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] | |
print matrix[1] | |
[4, 5, 6] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- encoding: utf-8 -*- | |
""" | |
Определение | |
""" | |
d = {"A":"a", "B":"b"} | |
print d | |
print d["A"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- encoding: utf-8 -*- | |
""" | |
Определение | |
""" | |
t = () | |
print t | |
t = 12345, 54321, 'hello!' | |
print t[0] | |
print t |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- encoding: utf-8 -*- | |
""" | |
Открытие файла | |
""" | |
#open() returns a file object, and is most commonly used with two arguments: | |
#"open(filename, mode)". | |
f=open('/tmp/workfile', 'w') | |
print f |
OlderNewer