Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- __operators = ('+', '-', '/', '//', '*', '**', '%')
- def print_error_message():
- print("Калкулаторот треба да ги подржува следните операции:\n"
- "Собирање (+)\n"
- "Одземање (-)\n"
- "Множење (*)"
- "Целобројно делење (//)\n"
- "Делење (/)\n"
- "Модуло (остаток) (%)\n"
- "Степенување (**)")
- def do_evaluation(x, operator, y):
- if operator == '+':
- return x + y
- elif operator == '-':
- return x - y
- elif operator == '/':
- return x / y
- elif operator == '//':
- return x // y
- elif operator == '*':
- return x * y
- elif operator == '**':
- return x ** y
- elif operator == '%':
- return x % y
- else:
- return None
- def calculator():
- x = eval(input())
- operator = eval(input())
- y = eval(input())
- print(str(x) + operator + str(y))
- # your code here
- rezultat = do_evaluation(x, operator, y)
- if rezultat is None:
- print_error_message()
- else:
- print(rezultat)
- return rezultat
- if __name__ == "__main__":
- calculator()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement