{"id":51,"date":"2026-05-15T14:11:32","date_gmt":"2026-05-15T14:11:32","guid":{"rendered":"https:\/\/theroyalscode.com\/students\/m_vicander\/?p=51"},"modified":"2026-05-15T14:11:32","modified_gmt":"2026-05-15T14:11:32","slug":"what-i-did-for-my-free-friday","status":"publish","type":"post","link":"https:\/\/theroyalscode.com\/students\/m_vicander\/2026\/05\/15\/what-i-did-for-my-free-friday\/","title":{"rendered":"what i did for my free friday"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">what i did to day was make a calculator<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import math\n\nclass AdvancedCalculator:\n    OPERATIONS = {\n        \"+\": lambda x, y: x + y,\n        \"-\": lambda x, y: x - y,\n        \"*\": lambda x, y: x * y,\n        \"\/\": lambda x, y: x \/ y if y != 0 else \"Error: Division by zero\",\n        \"^\": lambda x, y: x ** y,\n    }\n    \n    SCIENTIFIC_OPS = {\n        \"sin\": lambda x: math.sin(math.radians(x)),\n        \"cos\": lambda x: math.cos(math.radians(x)),\n        \"tan\": lambda x: math.tan(math.radians(x)),\n        \"log\": lambda x: math.log10(x) if x > 0 else \"Error: Domain\",\n        \"sqrt\": lambda x: math.sqrt(x) if x >= 0 else \"Error: Negative sqrt\",\n    }\n\n    def calculate_basic(self, n1, op, n2):\n        return self.OPERATIONS.get(op, lambda x, y: \"Invalid Op\")(n1, n2)\n\n    def calculate_scientific(self, op, n):\n        try:\n            return self.SCIENTIFIC_OPS.get(op, lambda x: \"Invalid Op\")(n)\n        except Exception:\n            return \"Error\"\n\n    def run(self):\n        print(\"--- Advanced Python Calculator ---\")\n        print(\"Basic: +, -, *, \/, ^ | Scientific: sin, cos, tan, log, sqrt\")\n        \n        while True:\n            choice = input(\"\\nType 's' for scientific, 'b' for basic, or 'q' to quit: \").lower()\n            \n            if choice == 'q':\n                break\n            \n            try:\n                if choice == 'b':\n                    n1 = float(input(\"First number: \"))\n                    op = input(\"Operation (+,-,*,\/,^): \")\n                    n2 = float(input(\"Second number: \"))\n                    print(f\"Result: {self.calculate_basic(n1, op, n2)}\")\n\n                elif choice == 's':\n                    op = input(\"Function (sin, cos, tan, log, sqrt): \")\n                    n = float(input(\"Value: \"))\n                    print(f\"Result: {self.calculate_scientific(op, n)}\")\n            \n            except ValueError:\n                print(\"Invalid input. Please enter numbers only.\")\n\nif __name__ == \"__main__\":\n    calc = AdvancedCalculator()\n    calc.run()\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>what i did to day was make a calculator<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-51","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/theroyalscode.com\/students\/m_vicander\/wp-json\/wp\/v2\/posts\/51","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/theroyalscode.com\/students\/m_vicander\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/theroyalscode.com\/students\/m_vicander\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/theroyalscode.com\/students\/m_vicander\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/theroyalscode.com\/students\/m_vicander\/wp-json\/wp\/v2\/comments?post=51"}],"version-history":[{"count":1,"href":"https:\/\/theroyalscode.com\/students\/m_vicander\/wp-json\/wp\/v2\/posts\/51\/revisions"}],"predecessor-version":[{"id":52,"href":"https:\/\/theroyalscode.com\/students\/m_vicander\/wp-json\/wp\/v2\/posts\/51\/revisions\/52"}],"wp:attachment":[{"href":"https:\/\/theroyalscode.com\/students\/m_vicander\/wp-json\/wp\/v2\/media?parent=51"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/theroyalscode.com\/students\/m_vicander\/wp-json\/wp\/v2\/categories?post=51"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/theroyalscode.com\/students\/m_vicander\/wp-json\/wp\/v2\/tags?post=51"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}