Created
December 12, 2011 12:35
-
-
Save dketov/1466961 to your computer and use it in GitHub Desktop.
Переменные
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 -*- | |
""" | |
Динамическая типизация | |
""" | |
x = 0 # x bound to an integer object | |
print x | |
x = "Hello" # now it's a string | |
print x | |
x = [1, 2, 3] # and now it's a list | |
print x |
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 -*- | |
""" | |
Цепочечное присваивание | |
""" | |
x = y = z = 0 # Zero x, y and z | |
print x | |
print y | |
print z |
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 range(7) | |
(MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY) = range(7) | |
print MONDAY | |
print TUESDAY | |
print SUNDAY |
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 -*- | |
""" | |
Групповое присваивание | |
""" | |
v = ('a', 'b', 'e') | |
(x, y, z) = v | |
print x | |
print y | |
print z |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment