# Tabs Experiments ## API Auth methods API key Learn more An API key is a unique identifier, acting as a secret token, used to authenticate and authorize a user, developer, or program to access an API. It's like a password for accessing a specific API service. OAuth OAuth is an open standard authorization framework that allows users to grant third-party applications access to their data on other websites or services without revealing their passwords. It uses access tokens to authorize access, enabling secure and delegated access to protected resources. JWT JWT, or JSON Web Token, is a compact, self-contained way to securely transmit information between parties as a JSON object, widely used for authentication and authorization in web applications and APIs ## How to write a simple calculator Python ```python def calculator(a, b, operator): if operator == '+': return a + b elif operator == '-': return a - b elif operator == '*': return a * b elif operator == '/': return a / b if b != 0 else 'Cannot divide by zero' else: return 'Invalid operator' # Example usage print(calculator(10, 5, '+')) # 15 print(calculator(10, 5, '/')) # 2.0 ``` JS ```js function calculator(a, b, operator) { switch (operator) { case '+': return a + b; case '-': return a - b; case '*': return a * b; case '/': return b !== 0 ? a / b : 'Cannot divide by zero'; default: return 'Invalid operator'; } } // Example usage: console.log(calculator(10, 5, '+')); // 15 console.log(calculator(10, 5, '/')); // 2 ``` C++ ```c++ #include using namespace std; double calculator(double a, double b, char op) { switch(op) { case '+': return a + b; case '-': return a - b; case '*': return a * b; case '/': return (b != 0) ? a / b : throw runtime_error("Cannot divide by zero"); default: throw invalid_argument("Invalid operator"); } } int main() { double a = 10, b = 5; char op = '+'; try { cout << "Result: " << calculator(a, b, op) << endl; } catch (exception& e) { cout << "Error: " << e.what() << endl; } return 0; } ``` ## Redocly socials img links Youtube LinkedIn [![LinkedIn](https://cdn.redocly.com/assets/logo-linkedin.svg)](https://www.linkedin.com/company/redocly) X.com [![X](https://cdn.redocly.com/assets/logo-x.svg)](https://x.com/Redocly)