Skip to content
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
1 change: 1 addition & 0 deletions 계산기
Original file line number Diff line number Diff line change
@@ -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)"]}]}
22 changes: 22 additions & 0 deletions 계산기.ipynb.txt
Original file line number Diff line number Diff line change
@@ -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)