<jupyter_start><jupyter_text>Python-3 2020-05-15<jupyter_code>type('')
string = 'Вы - самый крутой студент в SkillFactory'
for letter in string:
    print(':' + letter, end = '')

string[0::6]
string[-1::-1]

proverb = 'Программисты - это устройства, преобразующие кофеин в код.'
proverb[0:11]

proverb[-13:-9]

proverb[19:28]+'o'
proverb.split()[3][:-2]+'o'

proverb[19:29].split()[0]+'o'
proverb = 'Программисты - это устройства, преобразующие кофеин в код.'

odd_str = proverb[1::2]
even_str = proverb[::2]

new_proverb = ''.join([odd_str[i] + even_str[i] for i in range(len(odd_str))])

basic_word = 'программирование'

inverted_word = basic_word[-1::-1]

if basic_word == inverted_word:
    print('Слово "' + basic_word +'" является палиндромом')
else:
    print('Слово "' + basic_word + '" - это не палиндром')<jupyter_output>Слово "программирование" - это не палиндром<jupyter_text>3.3  3.3.3<jupyter_code>email = '<EMAIL>'

email[email.find('@')+1:]<jupyter_output><empty_output><jupyter_text>3.3.4<jupyter_code>number = 56.257

print(sum([int(s) for s in str(number)[str(number).find('.')+1:]]))<jupyter_output>14<jupyter_text>3.3.5<jupyter_code>emails_list = ['<EMAIL>', 
          '<EMAIL>', 
          '<EMAIL>', 
          '<EMAIL>', 
          '<EMAIL>', 
          'noname<EMAIL>', 
          '<EMAIL>', 
          '<EMAIL>', 
          '<EMAIL>', 
          '<EMAIL>']

emails_dict = {}

for email in emails_list:
    domain = email[email.find('@')+1:]

    if domain in emails_dict.keys():
        emails_dict[domain] += 1
    else:
        emails_dict[domain] = 1

emails_dict<jupyter_output><empty_output><jupyter_text>3.4  3.4.4<jupyter_code>string = 'Тяжёлая интернет-зависимость - это когда ты выходишь из интернета, а он из тебя нет.'

new_str = []
for letter in string:
    if letter in ['.', ',', ':', '-', '!', '?']:
        new_str.append(':)')
    else:
        new_str.append(letter)

string = ''.join(new_str)
string<jupyter_output><empty_output><jupyter_text>3.4.5<jupyter_code>name = 'Анна'

letters = 'а е ё и о у ы э ю я'.split()

for l in name:
    if l.lower() in letters:
        print(l + ' - гласная буква')
    else:
        print(l + ' - согласная буква')<jupyter_output>А - гласная буква
н - согласная буква
н - согласная буква
а - гласная буква<jupyter_text>3.5<jupyter_code>import re
pattern = re.compile('[А-Я][а-я]*\W')
string = '!!! Йо! Учиться, Учиться и учиться! Вперёд! Только вперд!'
pattern.match(string)
pattern.search(string)
pattern.findall(string)<jupyter_output><empty_output><jupyter_text>3.5.1<jupyter_code>text = 'Разработка языка Python была начата в конце 1980-х годов сотрудником голландского института CWI Гвидо ван Россумом. Для распределённой ОС Amoeba требовался расширяемый скриптовый язык, и Гвидо начал писать Python на досуге, позаимствовав некоторые наработки для языка ABC (Гвидо участвовал в разработке этого языка, ориентированного на обучение программированию). В феврале 1991 года Гвидо опубликовал исходный текст в группе новостей alt.sources. Название языка произошло вовсе не от вида пресмыкающихся. Автор назвал язык в честь популярного британского комедийного телешоу 1970-х "Летающий цирк <NAME>".'
pattern = re.compile('\d+')
pattern.search(text)

text.find('1')<jupyter_output><empty_output><jupyter_text>3.6<jupyter_code>pattern = re.compile('[A-Za-z]+')
pattern.findall(text)

pattern = re.compile('[А-Яа-я]+ка')
pattern.findall(text)
pattern = re.compile('а\w\wи')
pattern.findall(text)<jupyter_output><empty_output><jupyter_text>3.6.5<jupyter_code>pattern = re.compile('[А-Яа-я]*[АЁЕИОУЫЭЮЯаёеиоуыэюя]\s[БВГДЖЗЙКЛМНПРСТФХЦЧШЩбвгджзйклмнпрстфхцчшщ]+')
len(pattern.findall(text))<jupyter_output><empty_output><jupyter_text>3.7<jupyter_code>f = open('StudentsPerformance.csv')

info = ''
for line in f:
    info = line
    break
f.close()
info.split(',')[0][1:-1]<jupyter_output><empty_output><jupyter_text>3.7.1<jupyter_code>f = open('StudentsPerformance.csv')

parents = 0
for line in f:
    par_degree = line.split(',')[2]
    if 'bachelor' in par_degree:
        parents += 1

parents
f.close()<jupyter_output><empty_output><jupyter_text>3.7.2<jupyter_code>f = open('StudentsPerformance.csv')

levels = []
f.readline()

for line in f:
    par_degree = line.split(',')[2]
    if par_degree in levels:
        continue
    levels.append(par_degree)

f.close()

len(levels)<jupyter_output><empty_output><jupyter_text>3.7.3<jupyter_code>f = open('StudentsPerformance.csv')
f.readline()

total = 0
lunch = 0

for line in f:
    data = line.split(',')[3]
    if 'standard' in data:
        lunch += 1
    total += 1

f.close()

print('lunch: {}, total: {}'.format(lunch, total))<jupyter_output>lunch: 645, total: 1000<jupyter_text>3.7.4<jupyter_code>f = open('StudentsPerformance.csv')
f.readline()

race = 0

for line in f:
    data = line.split(',')[1]
    if 'group C' in data:
        race += 1

f.close()
race<jupyter_output><empty_output><jupyter_text>3.7.5<jupyter_code>f = open('StudentsPerformance.csv')
f.readline()

races = []

for line in f:
    data = line.split(',')[1]
    if data in races:
        continue
    races.append(data)

f.close()
len(races)<jupyter_output><empty_output><jupyter_text>3.8  3.8.1<jupyter_code>f = open('StudentsPerformance.csv')
f.readline()

reading = []

for line in f:
    data = line.split(',')[-2]
    reading.append(int(data[1:-1]))

f.close()

avg_read = sum(reading)/len(reading)
avg_read<jupyter_output><empty_output><jupyter_text>3.8.2<jupyter_code>less_then_avg_read = 0

for score in reading:
    if score < avg_read:
        less_then_avg_read += 1

less_then_avg_read<jupyter_output><empty_output><jupyter_text>3.8.3<jupyter_code>f = open('StudentsPerformance.csv')
f.readline()

reading_girls = []

for line in f:
    data = line.split(',')
    score = data[-2]
    gender = data[0]
    if 'female' in gender:
        reading_girls.append(int(score[1:-1]))

f.close()

avg_read_girls = sum(reading_girls)/len(reading_girls)
avg_read_girls<jupyter_output><empty_output><jupyter_text>3.8.4, 3.8.5<jupyter_code>import re

pattern = re.compile('\d+')

f = open('StudentsPerformance.csv')
f.readline()

wr_stat_gt_90 = 0
# stats = []

for line in f:
    data = line.split(',')
    score = data[-1]
    lunch = data[3]
    if int(pattern.search(score)[0]) > 90 and 'standard' in lunch:
        wr_stat_gt_90 += 1

# line = f.readline()

f.close()
wr_stat_gt_90/68*100

# stats
# data = line.split(',')
# pattern.search(data[-1])[0]
# data[3]<jupyter_output><empty_output><jupyter_text>3.9  3.9.1<jupyter_code>f = open('StudentsPerformance.csv')
f.readline()

total = 0

for line in f:
    data = line.split(',')
    gender = data[0][1:-1]
    lunch = data[3]
    if gender == 'male' and 'standard' in lunch:
        total += 1

f.close()

total<jupyter_output><empty_output><jupyter_text>3.9.2<jupyter_code>f = open('StudentsPerformance.csv')
f.readline()

total = 0

for line in f:
    data = line.split(',')
    gender = data[0][1:-1]
    test = data[4]
    if gender == 'male' and 'completed' in test:
        total += 1

f.close()

total<jupyter_output><empty_output><jupyter_text>3.9.3<jupyter_code>f = open('StudentsPerformance.csv')
f.readline()

total = 0

for line in f:
    data = line.split(',')
    gender = data[0][1:-1]
    test = data[2]
    if gender == 'female' and 'master' in test:
        total += 1

f.close()

total<jupyter_output><empty_output><jupyter_text>3.9.4<jupyter_code>f = open('StudentsPerformance.csv')
f.readline()

total = 0

for line in f:
    data = line.split(',')
    race = data[1]
    test = data[4]
    if 'group C' in race and 'completed' in test:
        total += 1

f.close()

total<jupyter_output><empty_output><jupyter_text>3.9.5<jupyter_code>f = open('StudentsPerformance.csv')
f.readline()

total = 0

for line in f:
    data = line.split(',')
    gender = data[0][1:-1]
    test = data[2]
    score_math = int(data[-3][1:-1])
    if gender == 'female' and 'master' in test and score_math > 90:
        total += 1

f.close()

total<jupyter_output><empty_output><jupyter_text>3.10<jupyter_code>str = 'test'
str[-1::-1] 

import re
pattern = re.compile('\d\d\d')
secret = pattern.findall('2 x 2 = 4')
secret<jupyter_output><empty_output><jupyter_text>3.10.8<jupyter_code>f = open('StudentsPerformance.csv')
f.readline()

total = 0
count = 0
scores = []

for line in f:
    data = line.split(',')
    gender = data[0][1:-1]
    test = data[2]
    score_read = int(data[-2][1:-1])
    if gender == 'male':
        scores.append(score_read)
        count += 1

f.close()

total
# 31558
count
sum(scores)/count<jupyter_output><empty_output><jupyter_text>3.10.9<jupyter_code>f = open('StudentsPerformance.csv')
f.readline()

count = 0
read_scores = []
# math_scores = []

for line in f:
    data = line.split(',')
    # gender = data[0][1:-1]
    # test = data[2]
    score_read = int(data[-2][1:-1])
    score_math = int(data[-3][1:-1])
    # math_scores.append(score_math)
    if score_math == 100:
        read_scores.append(score_read)
        count += 1

f.close()

# max_math = max(math_scores)
# math_scores
# print(max(math_scores))
sum(read_scores)/count<jupyter_output><empty_output><jupyter_text>3.10.10<jupyter_code>f = open('StudentsPerformance.csv')
f.readline()

write_scores = []

import re
pattern = re.compile('\d+')

for line in f:
    data = line.split(',')
    score_write = int(pattern.search(data[-1])[0])
    lunch = data[3]

    # print(score_write, lunch)

    if 'free' in lunch:
        write_scores.append(score_write)
        # print(score_write, lunch)

f.close()
sum(write_scores)/len(write_scores)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16281000311300198, 'fraction_numerical': 0.02905468506796721, 'mean_word_length': 4.165058949624866, 'pattern_counts': {'":': 0, '<': 126, '<?xml version=': 0, '>': 127, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '29', 'dir': 'jupyter-structured-clean-dedup', 'id': '247912', 'license': 'MIT', 'n_tokens_mistral': 4139, 'n_tokens_neox': 4135, 'n_words': 713, 'path': 'units/unit-0/python-3/python-3.ipynb', 'repo_name': 'mtungusov/DST-19', 'size': '9749'}