Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

homework 4 Fadeev #10

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions Shishkin_Anatoliy_lesson_4/task_4_1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
1. $ pip show pillow
WARNING: Package(s) not found: pillow

2. ��������� ��������� ������ pillow � ���������� ���������
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

следите за кодировками файла - стандартная, рекомендуемая UTF-8

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: [email protected]
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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

просто посмотреть можно ещё через pip list

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: [email protected]
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
$

43 changes: 43 additions & 0 deletions Shishkin_Anatoliy_lesson_4/task_4_2.py
Original file line number Diff line number Diff line change
@@ -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])
Comment on lines +19 to +28
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

хорошо, что это работает, но выглядит крайне избыточным надо бы поискать более оптимальный путь

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)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

пробел после return и не нужно значение обрамлять в скобки

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

если кода нет в ЦБР, то нужно возвращать None, а Ваша функция возвращает 0.00


print(currency_rates('USD'))
print(currency_rates("noname"))