From c26c571711cbc489354702abbd4cf651b9608065 Mon Sep 17 00:00:00 2001 From: Egor Fadeev Date: Thu, 3 Feb 2022 20:54:21 +0400 Subject: [PATCH] homework 4 Fadeev --- Shishkin_Anatoliy_lesson_4/task_4_1.txt | 87 +++++++++++++++++++++++++ Shishkin_Anatoliy_lesson_4/task_4_2.py | 43 ++++++++++++ 2 files changed, 130 insertions(+) create mode 100644 Shishkin_Anatoliy_lesson_4/task_4_1.txt create mode 100644 Shishkin_Anatoliy_lesson_4/task_4_2.py diff --git a/Shishkin_Anatoliy_lesson_4/task_4_1.txt b/Shishkin_Anatoliy_lesson_4/task_4_1.txt new file mode 100644 index 0000000..478f1fb --- /dev/null +++ b/Shishkin_Anatoliy_lesson_4/task_4_1.txt @@ -0,0 +1,87 @@ +1. $ pip show pillow +WARNING: Package(s) not found: pillow + +2. Установка последней версии pillow в глобальном окружении +rufadeeeg@RU01NBFADEEEG01 MINGW64 /d/Dropbox/GeekBrains/2074_GB_Python_1- (homework_4_Fadeev) +$ pip install pillow +Collecting pillow + Using cached Pillow-9.0.1-cp310-cp310-win_amd64.whl (3.2 MB) +Installing collected packages: pillow +Successfully installed pillow-9.0.1 +WARNING: You are using pip version 21.2.4; however, version 22.0.3 is available. +You should consider upgrading via the 'C:\Users\rufadeeeg.KROHNEGROUP\AppData\Local\Programs\Python\Python310\python.exe -m pip install --upgrade pip' command. + +rufadeeeg@RU01NBFADEEEG01 MINGW64 /d/Dropbox/GeekBrains/2074_GB_Python_1- (homework_4_Fadeev) +$ pip show pillow +Name: Pillow +Version: 9.0.1 +Summary: Python Imaging Library (Fork) +Home-page: https://python-pillow.org +Author: Alex Clark (PIL Fork Author) +Author-email: aclark@python-pillow.org +License: HPND +Location: c:\users\rufadeeeg.krohnegroup\appdata\local\programs\python\python310\lib\site-packages +Requires: +Required-by: + +3. Проблема с активацией виртуального окружения +rufadeeeg@RU01NBFADEEEG01 MINGW64 ~/Onedrive - KROHNE GROUP/Рабочий стол +$ mkdir task_4_1 + +rufadeeeg@RU01NBFADEEEG01 MINGW64 ~/Onedrive - KROHNE GROUP/Рабочий стол +$ cd task_4_1 + +rufadeeeg@RU01NBFADEEEG01 MINGW64 ~/Onedrive - KROHNE GROUP/Рабочий стол/task_4_1 +$ python3 -m venv virt +bash: python3: command not found + +rufadeeeg@RU01NBFADEEEG01 MINGW64 ~/Onedrive - KROHNE GROUP/Рабочий стол/task_4_1 +$ python -m venv virt + +rufadeeeg@RU01NBFADEEEG01 MINGW64 ~/Onedrive - KROHNE GROUP/Рабочий стол/task_4_1 +$ ls +virt/ + +rufadeeeg@RU01NBFADEEEG01 MINGW64 ~/Onedrive - KROHNE GROUP/Рабочий стол/task_4_1 +$ virt/Scripts/activate.bat + +rufadeeeg@RU01NBFADEEEG01 MINGW64 ~/Onedrive - KROHNE GROUP/Рабочий стол/task_4_1 +$ pip freeze +Pillow==9.0.1 + +rufadeeeg@RU01NBFADEEEG01 MINGW64 ~/Onedrive - KROHNE GROUP/Рабочий стол/task_4_1 +$ "virt/Scripts/activate.bat" + +rufadeeeg@RU01NBFADEEEG01 MINGW64 ~/Onedrive - KROHNE GROUP/Рабочий стол/task_4_1 +$ pip freeze +Pillow==9.0.1 + +4. Установка pillow предыдущей версии в глобальном окружении +rufadeeeg@RU01NBFADEEEG01 MINGW64 ~/Onedrive - KROHNE GROUP/Рабочий стол/task_4_1 +$ pip freeze + +rufadeeeg@RU01NBFADEEEG01 MINGW64 ~/Onedrive - KROHNE GROUP/Рабочий стол/task_4_1 +$ pip install pillow==9.0.0 +Collecting pillow==9.0.0 + Downloading Pillow-9.0.0-cp310-cp310-win_amd64.whl (3.2 MB) +Installing collected packages: pillow +Successfully installed pillow-9.0.0 +WARNING: You are using pip version 21.2.4; however, version 22.0.3 is available. +You should consider upgrading via the 'C:\Users\rufadeeeg.KROHNEGROUP\AppData\Local\Programs\Python\Python310\python.exe -m pip install --upgrade pip' command. + +rufadeeeg@RU01NBFADEEEG01 MINGW64 ~/Onedrive - KROHNE GROUP/Рабочий стол/task_4_1 +$ pip show pillow +Name: Pillow +Version: 9.0.0 +Summary: Python Imaging Library (Fork) +Home-page: https://python-pillow.org +Author: Alex Clark (PIL Fork Author) +Author-email: aclark@python-pillow.org +License: HPND +Location: c:\users\rufadeeeg.krohnegroup\appdata\local\programs\python\python310\lib\site-packages +Requires: +Required-by: + +rufadeeeg@RU01NBFADEEEG01 MINGW64 ~/Onedrive - KROHNE GROUP/Рабочий стол/task_4_1 +$ + diff --git a/Shishkin_Anatoliy_lesson_4/task_4_2.py b/Shishkin_Anatoliy_lesson_4/task_4_2.py new file mode 100644 index 0000000..29a409b --- /dev/null +++ b/Shishkin_Anatoliy_lesson_4/task_4_2.py @@ -0,0 +1,43 @@ +import requests + +def currency_rates(code: str) -> float: + + web_data = requests.api.get('http://www.cbr.ru/scripts/XML_daily.asp') + # user_cur = code + web_list = web_data.text.split('><') + my_list = [] + aux_list = [] + val = '' + currency = '' + result = 0.0 + + + for i in range (0, len(web_list), 1): + if web_list[i].split(' ')[0] == 'Valute': + aux_list = [] + aux_str = '' + aux_list.append(web_list[i + 2][9]) + aux_list.append(web_list[i + 2][10]) + aux_list.append(web_list[i + 2][11]) + aux_list.append(' ') + aux_list.append(web_list[i + 5][6]) + aux_list.append(web_list[i + 5][7]) + aux_list.append('.') + aux_list.append(web_list[i + 5][9]) + aux_list.append(web_list[i + 5][10]) + aux_list.append(web_list[i + 5][11]) + val = aux_list[0] + aux_list[1] + aux_list[2] + currency = aux_list[4] + aux_list[5] + aux_list[6] +aux_list[7] + aux_list[8] + aux_list[9] + aux_list.clear() + aux_list.append(val) + aux_list.append(currency) + my_list.append(aux_list) + + for i in range(0, len(my_list), 1): + if my_list[i][0] == code: + result = result + float(my_list[i][1]) + + return(result) + +print(currency_rates('USD')) +print(currency_rates("noname")) \ No newline at end of file