Skip to content

Commit eeb70b6

Browse files
committed
Created using Colaboratory
1 parent 04afbfa commit eeb70b6

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

1_6_2.ipynb

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
{
2+
"nbformat": 4,
3+
"nbformat_minor": 0,
4+
"metadata": {
5+
"colab": {
6+
"provenance": [],
7+
"authorship_tag": "ABX9TyNpyf3zu0SZNOFXU0FZaq5m",
8+
"include_colab_link": true
9+
},
10+
"kernelspec": {
11+
"name": "python3",
12+
"display_name": "Python 3"
13+
},
14+
"language_info": {
15+
"name": "python"
16+
}
17+
},
18+
"cells": [
19+
{
20+
"cell_type": "markdown",
21+
"metadata": {
22+
"id": "view-in-github",
23+
"colab_type": "text"
24+
},
25+
"source": [
26+
"<a href=\"https://colab.research.google.com/github/Sinrez/PythonProjects/blob/main/1_6_2.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
27+
]
28+
},
29+
{
30+
"cell_type": "code",
31+
"execution_count": 1,
32+
"metadata": {
33+
"colab": {
34+
"base_uri": "https://localhost:8080/"
35+
},
36+
"id": "hV8jK0GQh6vb",
37+
"outputId": "c7d8381e-232c-4073-863a-03e206fae90e"
38+
},
39+
"outputs": [
40+
{
41+
"output_type": "stream",
42+
"name": "stdout",
43+
"text": [
44+
"AMD\n"
45+
]
46+
}
47+
],
48+
"source": [
49+
"import requests\n",
50+
"import json\n",
51+
"\n",
52+
"# Загружаем данные о текущих курсах валют ЦБ РФ\n",
53+
"url = 'https://www.cbr-xml-daily.ru/daily_json.js'\n",
54+
"response = requests.get(url)\n",
55+
"data = json.loads(response.text)\n",
56+
"\n",
57+
"# Получаем словарь с курсами валют, где ключами являются CharCode валюты\n",
58+
"currencies = data['Valute']\n",
59+
"\n",
60+
"# Сортируем список валют в обратном алфавитном порядке\n",
61+
"sorted_currencies = sorted(currencies.values(), key=lambda x: x['CharCode'], reverse=True)\n",
62+
"\n",
63+
"# Получаем значение CharCode из списка для индекса 41 (42-й элемент, так как индексация начинается с 0)\n",
64+
"char_code_at_index_41 = sorted_currencies[41]['CharCode']\n",
65+
"\n",
66+
"print(char_code_at_index_41)\n"
67+
]
68+
}
69+
]
70+
}

0 commit comments

Comments
 (0)