diff --git "a/\352\263\204\354\202\260\352\270\260" "b/\352\263\204\354\202\260\352\270\260" new file mode 100644 index 0000000..52ef897 --- /dev/null +++ "b/\352\263\204\354\202\260\352\270\260" @@ -0,0 +1 @@ +{"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"provenance":[{"file_id":"17kBDaMfW0o3kY1Fto8ur1H6CfOkI4ePl","timestamp":1700038079438}],"authorship_tag":"ABX9TyMlcpQhcEFUBEkAGdvBACXS"},"kernelspec":{"name":"python3","display_name":"Python 3"},"language_info":{"name":"python"}},"cells":[{"cell_type":"code","execution_count":null,"metadata":{"id":"EZRZT21oFYC8"},"outputs":[],"source":["def calculate(int_list, str_list):\n"," for operator in prioritize_operations(str_list):\n"," index = str_list.index(operator)\n"," if operator in {'+', '-', '*', '/'}:\n"," a = int_list[index]\n"," b = int_list[index + 1]\n"," if operator == '+':\n"," result = a + b\n"," elif operator == '-':\n"," result = a - b\n"," elif operator == '*':\n"," result = a * b\n"," elif operator == '/':\n"," result = a / b\n"," int_list[index] = result\n"," str_list.pop(index)\n"," int_list.pop(index + 1)\n","\n"," return int_list[0]\n","\n","result = calculate_values([9, 4, 9], ['+', '*'])\n","print(\"Result:\", result)"]}]} \ No newline at end of file diff --git "a/\352\263\204\354\202\260\352\270\260.ipynb.txt" "b/\352\263\204\354\202\260\352\270\260.ipynb.txt" new file mode 100644 index 0000000..329868d --- /dev/null +++ "b/\352\263\204\354\202\260\352\270\260.ipynb.txt" @@ -0,0 +1,22 @@ +def calculate(int_list, str_list): + for operator in prioritize_operations(str_list): + index = str_list.index(operator) + if operator in {'+', '-', '*', '/'}: + a = int_list[index] + b = int_list[index + 1] + if operator == '+': + result = a + b + elif operator == '-': + result = a - b + elif operator == '*': + result = a * b + elif operator == '/': + result = a / b + int_list[index] = result + str_list.pop(index) + int_list.pop(index + 1) + + return int_list[0] + +result = calculate_values([9, 4, 9], ['+', '*']) +print("Result:", result) \ No newline at end of file