diff --git a/1.jpg b/1.jpg deleted file mode 100644 index 5927523..0000000 Binary files a/1.jpg and /dev/null differ diff --git a/1_2.py b/1_2.py new file mode 100644 index 0000000..37ac20f --- /dev/null +++ b/1_2.py @@ -0,0 +1,14 @@ + +def odd_nums(num): + '''get odd numbers''' + for res in range(1, num+1, 2): + yield res + + +num = 15 +odd_to_15 = odd_nums(num) + +print(next(odd_to_15)) + + +odd_to_15 = (x for x in range(1, num+1, 2)) diff --git a/3.py b/3.py new file mode 100644 index 0000000..afdea7f --- /dev/null +++ b/3.py @@ -0,0 +1,21 @@ +from itertools import zip_longest + +tutors = [ + 'Иван', 'Анастасия', 'Петр', 'Сергей', + 'Дмитрий', 'Борис', 'Елена' +] + +klasses = [ + '9А', '7В', '9Б', '9В', '8Б', '10А', '10Б', '9А' +] + +tutor_gen = zip_longest(tutors, klasses, fillvalue=None) +print(next(tutor_gen)) # test + +'''сделал чтобы в tutors было больше элементов чтобы подходить под задание''' +a = ['Станислав', 'Вячеслав', 'Игорь'] +tutors.extend(a) + +tutor_gen2 = zip_longest(tutors, klasses, fillvalue=None) +for i in range(len(tutors)+1): # test2 + print(next(tutor_gen2)) diff --git a/4.py b/4.py new file mode 100644 index 0000000..85e44d4 --- /dev/null +++ b/4.py @@ -0,0 +1,5 @@ +src = [300, 2, 12, 44, 1, 1, 4, 10, 7, 1, 78, 123, 55] + +digit_greater = [src[x] for x in range(1, len(src)) if src[x] > src[x - 1]] + +print(digit_greater) # test diff --git a/5.py b/5.py new file mode 100644 index 0000000..420ab62 --- /dev/null +++ b/5.py @@ -0,0 +1,17 @@ +from collections import Counter + +src = [2, 2, 2, 7, 23, 1, 44, 44, 3, 2, 10, 7, 4, 11] + +li_count = Counter(src) +unic_li = [k for k, v in li_count.items() if v == 1] +print(unic_li) # [23, 1, 3, 10, 4, 11] + + +unic_set = set() +for i in src: + if i not in unic_set: + unic_set.add(i) + else: + unic_set.discard(i) +unic_li = [i for i in src if i in unic_set] +print(unic_li) # [23, 1, 3, 10, 4, 11] diff --git a/README.md b/README.md deleted file mode 100644 index 0117e00..0000000 --- a/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# learning_python - -jgvg diff --git a/dz_2_3_5.py b/dz_2_3_5.py deleted file mode 100644 index af8386c..0000000 --- a/dz_2_3_5.py +++ /dev/null @@ -1,53 +0,0 @@ -import requests -from decimal import Decimal -from time import gmtime, strftime -from sys import argv - - -def currency_rates(find_currency): - '''решение через str''' - req = requests.get('http://www.cbr.ru/scripts/XML_daily.asp') - if req.status_code == 200: # check connection - dat = req.headers - li_date = dat['Date'] - res_date = strftime(li_date, gmtime()) - all_text = req.text - lines = all_text.split('/Valute') - for currency in lines: - if '/ValCurs' in currency: - return None - char_code = cleaner(currency, 'CharCode') - name = cleaner(currency, 'Name') - value = cleaner(currency, 'Value') - '''decimal создан специально для финансовых расчетов''' - value = Decimal(value) - if char_code == find_currency.upper(): - print(f'{char_code} один {name} стоит {value} рублей') - return value, res_date - else: - print('bad connection') - - -def cleaner(currency, val): - '''clean values''' - try: - val = currency.split(val)[1] - except IndexError as e: - # pass - print(e) - li = ['<', '>', '/'] - for i in li: - val = val.replace(i, '') - val = val.replace(',', '.') - val = val.strip() - return val - - -if __name__ == '__main__': - if len(argv) > 1: - res = currency_rates(argv[1]) - print(str(res)) - elif 2 < len(argv): - for i in argv[1:]: - res = currency_rates(argv[1]) - print(str(res)) diff --git a/utils_4.py b/utils_4.py deleted file mode 100644 index 4611a0b..0000000 --- a/utils_4.py +++ /dev/null @@ -1,12 +0,0 @@ -from dz_2_3 import currency_rates - - -def find_currency_cost(): - '''call currency_rates 3 times''' - li_currency = ['eur', 'USD', "GBp"] # check register - for currency in li_currency: - currency_rates(currency) - - -if __name__ == '__main__': - find_currency_cost()