<jupyter_start><jupyter_text>Типы данных в Python  1. Числовые  int<jupyter_code>x = 5
print (x)
print(type(x))
a = 4 + 5
b = 4 * 5
c = 5 // 4

print(a, b, c)
print -5 / 4
print -(5 / 4)<jupyter_output>-1<jupyter_text>long<jupyter_code>x = 5 * 1000000 * 1000000 * 1000000 * 1000000 + 1
print x
print type(x)
y = 5
print type(y)
y = x
print type(y)<jupyter_output><type 'int'>
<type 'long'><jupyter_text>float<jupyter_code>y = 5.7
print y
print type(y)
a = 4.2 + 5.1
b = 4.2 * 5.1
c = 5.0 / 4.0

print a, b, c
a = 5
b = 4
print float(a) / float(b)
print 5.0 / 4
print 5 / 4.0
print float(a) / b<jupyter_output>1.25<jupyter_text>bool<jupyter_code>a = True
b = False

print a
print type(a)

print b
print type(b)
print a + b
print a + a
print b + b
print int(a), int(b)
print True and False
print True and True
print False and False
print True or False
print True or True
print False or False<jupyter_output>True
True
False<jupyter_text>2. None<jupyter_code>z = None
print z
print type(z)
print int(z)<jupyter_output><empty_output><jupyter_text>3. Строковые  str<jupyter_code>x = "abc"
print x
print type(x)
a = 'Ivan'
b = "Ivanov"
s = a + " " + b
print s
print a.upper()
print a.lower()
print len(a)
print bool(a)
print bool("")
print int(a)
print a
print a[0]
print a[1]
print a[0:3]
print a[0:4:2]<jupyter_output>Ia<jupyter_text>unicode<jupyter_code>x = u"abc"
print x
print type(x)
x = u'<NAME>'
print x, type(x)
y = x.encode('utf-8')
print y, type(y)
z = y.decode('utf-8')
print z, type(z)
q = y.decode('cp1251')
print q, type(q)
1
x = u'<NAME>'
print x, type(x)
y = x.encode('utf-8')
print y, type(y)
z = y.decode('utf-8')
print z, type(z)
q = y.decode('cp1251')
print q, type(q)
print str(x)
print y[1:]
print len(y), type(y)
print len(x), type(x)
y = u'<NAME>'.encode('utf-8')
print y.decode('utf-8')
print y.decode('cp1251')
splitted_line = "<NAME>".split(' ')
print splitted_line
print type(splitted_line)
print "<NAME>".split(" ")
print "\x98"
print u"<NAME>".split(" ")<jupyter_output>[u'\u0418\u0432\u0430\u043d\u043e\u0432', u'\u0418\u0432\u0430\u043d', u'\u0418\u0432\u0430\u043d\u043e\u0432\u0438\u0447']<jupyter_text>3. Массивы  list<jupyter_code>saled_goods_count = [33450, 34010, 33990, 33200]
print saled_goods_count
print type(saled_goods_count)
income = [u'Высокий', u'Средний', u'Высокий']
names = [u'<NAME>', u'<NAME>', u'<NAME>']

print income
print names
print "---".join(income)
features = ['<NAME>', 'Medium', 500000, 12, True]
print features
print features[0]
print features[1]
print features[3]
print features[0:5]
print features[:5]
print features[1:]
print features[2:5]
print features[:-1]
features.append('One more element in list')
print features
del features[-2]
print features<jupyter_output>['<NAME>', 'Medium', 500000, 12, 'One more element in list']<jupyter_text>tuple<jupyter_code>features_tuple = ('<NAME>', 'Medium', 500000, 12, True)
print type(features_tuple)
features_tuple[2:5]
features_tuple.append('one more element')<jupyter_output><empty_output><jupyter_text>4. Множества и словари  set<jupyter_code>names = {'Ivan', 'Petr', 'Konstantin'}
print type(names)
print 'Ivan' in names
print 'Mikhail' in names
names.add('Mikhail')
print names
names.add('Mikhail')
print names
names.remove('Mikhail')
print names
names.add(['Vladimir', 'Vladimirovich'])
names.add(('Vladimir', 'Vladimirovich'))
print names
a = range(10000)
b = range(10000)
b = set(b)
print a[:5]
print a[-5:]
%%time
print 9999 in a
%%time
print 9999 in b<jupyter_output>True
CPU times: user 49 µs, sys: 9 µs, total: 58 µs
Wall time: 55.1 µs<jupyter_text>dict<jupyter_code>words_frequencies = dict()
words_frequencies['I'] = 1
words_frequencies['am'] = 1
words_frequencies['I'] += 1

print words_frequencies
print words_frequencies['I']
words_frequencies = {'I': 2, 'am': 1}
print words_frequencies
yet_another_dict = {'abc': 3.4, 5: 7.8, u'123': None}
print yet_another_dict
yet_another_dict[(1,2,5)] = [4, 5, 7]
print yet_another_dict
yet_another_dict[[1,2,7]] = [4, 5]<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16687453230231977, 'fraction_numerical': 0.06934397605387878, 'mean_word_length': 5.628099173553719, 'pattern_counts': {'":': 0, '<': 51, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '11', 'dir': 'jupyter-structured-clean-dedup', 'id': '7197', 'license': 'MIT', 'n_tokens_mistral': 1922, 'n_tokens_neox': 1748, 'n_words': 437, 'path': 'MathAndPython/week1/Types_in_Python.ipynb', 'repo_name': 'ishatserka/MachineLearningAndDataAnalysisCoursera', 'size': '4139'}