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

Работа с файлами #5

Open
wants to merge 3 commits into
base: master
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
272 changes: 272 additions & 0 deletions phw3.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,272 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Задание #1. Введите: 1\n",
"Задание #2. Введите: 2\n",
"Задание #3. Введите: 3\n",
"Задание #4. Введите: 4 или 42\n",
"Задание #5. Введите: 5\n",
"Задание #6. Введите: 6\n",
"\n",
"Выберите задание или введите \"0\", чтобы выйти: 6\n",
"Input text: 3\n",
"3\n",
"Задание #1. Введите: 1\n",
"Задание #2. Введите: 2\n",
"Задание #3. Введите: 3\n",
"Задание #4. Введите: 4 или 42\n",
"Задание #5. Введите: 5\n",
"Задание #6. Введите: 6\n",
"\n",
"Выберите задание или введите \"0\", чтобы выйти: 1\n",
"Enter first number: 6\n",
"Enter second number: 3\n",
"2.0\n",
"\n",
"\n",
"Задание #1. Введите: 1\n",
"Задание #2. Введите: 2\n",
"Задание #3. Введите: 3\n",
"Задание #4. Введите: 4 или 42\n",
"Задание #5. Введите: 5\n",
"Задание #6. Введите: 6\n",
"\n",
"Выберите задание или введите \"0\", чтобы выйти: 2\n",
"Enter name: kolya\n",
"Enter second name: kare\n",
"Enter birth day: 34\n",
"Enter live town: la\n",
"Enter email: [email protected]\n",
"Enter tel number: 67763\n",
"['kolya', 'kare', '34', 'la', '[email protected]', '67763']\n",
"\n",
"\n",
"Задание #1. Введите: 1\n",
"Задание #2. Введите: 2\n",
"Задание #3. Введите: 3\n",
"Задание #4. Введите: 4 или 42\n",
"Задание #5. Введите: 5\n",
"Задание #6. Введите: 6\n",
"\n",
"Выберите задание или введите \"0\", чтобы выйти: 3\n",
"Enter first number: 4\n",
"Enter second number: 2\n",
"Enter third number: 5\n",
"9\n",
"\n",
"\n",
"Задание #1. Введите: 1\n",
"Задание #2. Введите: 2\n",
"Задание #3. Введите: 3\n",
"Задание #4. Введите: 4 или 42\n",
"Задание #5. Введите: 5\n",
"Задание #6. Введите: 6\n",
"\n",
"Выберите задание или введите \"0\", чтобы выйти: 4\n",
"Enter first number: 4\n",
"Enter second number: 2\n",
"0.0625\n",
"\n",
"\n",
"Задание #1. Введите: 1\n",
"Задание #2. Введите: 2\n",
"Задание #3. Введите: 3\n",
"Задание #4. Введите: 4 или 42\n",
"Задание #5. Введите: 5\n",
"Задание #6. Введите: 6\n",
"\n",
"Выберите задание или введите \"0\", чтобы выйти: 9\n",
"Задание #1. Введите: 1\n",
"Задание #2. Введите: 2\n",
"Задание #3. Введите: 3\n",
"Задание #4. Введите: 4 или 42\n",
"Задание #5. Введите: 5\n",
"Задание #6. Введите: 6\n",
"\n",
"Выберите задание или введите \"0\", чтобы выйти: 42\n",
"Enter first number: 9\n",
"Enter second number: 3\n",
"0.00015241579027587258\n",
"\n",
"\n",
"Задание #1. Введите: 1\n",
"Задание #2. Введите: 2\n",
"Задание #3. Введите: 3\n",
"Задание #4. Введите: 4 или 42\n",
"Задание #5. Введите: 5\n",
"Задание #6. Введите: 6\n",
"\n",
"Выберите задание или введите \"0\", чтобы выйти: 5\n",
"Enter list of number or * to exit: 234 3242\n",
"Sum is 3476 + \"\n",
"\"\n",
"Enter list of number or * to exit: fg3\n",
"Enter number or *\n",
"Sum is 3476 + \"\n",
"\"\n",
"Enter list of number or * to exit: *\n",
"Sum is 3476. Exit + \"\n",
"\"\n",
"Задание #1. Введите: 1\n",
"Задание #2. Введите: 2\n",
"Задание #3. Введите: 3\n",
"Задание #4. Введите: 4 или 42\n",
"Задание #5. Введите: 5\n",
"Задание #6. Введите: 6\n",
"\n",
"Выберите задание или введите \"0\", чтобы выйти: 6\n",
"Input text: hello world\n",
"Hello World\n",
"Задание #1. Введите: 1\n",
"Задание #2. Введите: 2\n",
"Задание #3. Введите: 3\n",
"Задание #4. Введите: 4 или 42\n",
"Задание #5. Введите: 5\n",
"Задание #6. Введите: 6\n",
"\n",
"Выберите задание или введите \"0\", чтобы выйти: 0\n"
]
}
],
"source": [
"def Division(a, b):\n",
" try:\n",
" return a / b\n",
" except ZeroDivisionError:\n",
" return 'Zero Division Error'\n",
" except ValueError:\n",
" return \"Wrong input. It's must be numbers\"\n",
" \n",
"def Division_use():\n",
" print(Division((int(input('Enter first number: '))), (int(input('Enter second number: ')))))\n",
" print('\\n')\n",
" \n",
"def Data(**kwargs):\n",
" return list(kwargs.values())\n",
" \n",
"def Data_use():\n",
" print(Data(name = input('Enter name: '),\n",
" s_name = input('Enter second name: '),\n",
" b_date = input('Enter birth day: '),\n",
" l_town = input('Enter live town: '),\n",
" email = input('Enter email: '),\n",
" tel = input('Enter tel number: ')))\n",
" print('\\n')\n",
" \n",
"def My_func(a, b, c):\n",
" s = [a, b, c]\n",
" s.remove(min(a, b, c))\n",
" return sum(s)\n",
" \n",
" \n",
"def My_func_use():\n",
" print(My_func((int(input('Enter first number: '))), (int(input('Enter second number: '))), (int(input('Enter third number: ')))))\n",
" print('\\n')\n",
" \n",
"def My_func_2(x, y):\n",
" return 1 / x ** abs(y)\n",
"\n",
"def My_func_2_use():\n",
" print(My_func_2((int(input('Enter first number: '))), (int(input('Enter second number: ')))))\n",
" print('\\n')\n",
" \n",
"def My_func_2_1(x, y):\n",
" for i in range(abs(y - 1)):\n",
" x *= x\n",
" return 1 / x\n",
"\n",
"def My_func_2_1_use():\n",
" print(My_func_2_1((int(input('Enter first number: '))), (int(input('Enter second number: ')))))\n",
" print('\\n')\n",
"\n",
"def E_5():\n",
" res = 0\n",
" while True:\n",
" numbers = input('Enter list of number or * to exit: ').split()\n",
" for i in numbers:\n",
" try:\n",
" if i == '*':\n",
" print(f'Sum is {res}. Exit + \"\\n\"')\n",
" return\n",
" else:\n",
" res += int(i)\n",
" except ValueError:\n",
" print('Enter number or *')\n",
" print(f'Sum is {res} + \"\\n\"')\n",
"\n",
"def Int_func(text):\n",
" ls = []\n",
" for i in range(len(text)):\n",
" ls.append(text[i][0:1].title() + text[i][1:])\n",
" return ' '.join(ls)\n",
" print('\\n')\n",
"\n",
"def Int_func_use():\n",
" print(Int_func(input('Input text: ').split()))\n",
" \n",
"def functions():\n",
" print('Задание #1. Введите: 1')\n",
" print('Задание #2. Введите: 2')\n",
" print('Задание #3. Введите: 3')\n",
" print('Задание #4. Введите: 4 или 42')\n",
" print('Задание #5. Введите: 5')\n",
" print('Задание #6. Введите: 6' + '\\n')\n",
" \n",
"menu = {1: Division_use,\n",
" 2: Data_use,\n",
" 3: My_func_use,\n",
" 4: My_func_2_use,\n",
" 42: My_func_2_1_use,\n",
" 5: E_5,\n",
" 6: Int_func_use}\n",
" \n",
"action = 1\n",
" \n",
"while action != 0:\n",
" functions()\n",
" action = int(input('Выберите задание или введите \"0\", чтобы выйти: '))\n",
" if action == 0:\n",
" break\n",
" if action in menu:\n",
" x = menu[action]\n",
" x()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Loading