# Usage Examples for rad_cs_myfirstmodel ## Basic Questions ``` >>> Who are you? I'm rad_cs, your computer science specialist. >>> What do you specialize in? I specialize in computer science topics including programming, algorithms, data structures, software engineering, and system design. ``` ## Programming Help ``` >>> Write a Python function to find the factorial of a number def factorial(n): if n < 0: raise ValueError("Factorial is not defined for negative numbers") if n == 0 or n == 1: return 1 return n * factorial(n - 1) # Iterative version for better performance def factorial_iterative(n): if n < 0: raise ValueError("Factorial is not defined for negative numbers") result = 1 for i in range(2, n + 1): result *= i return result ``` ## Algorithm Explanations ``` >>> Explain bubble sort Bubble Sort is a simple comparison-based sorting algorithm: 1. Compare adjacent elements 2. Swap if they're in wrong order 3. Repeat until no swaps needed 4. Time Complexity: O(n²) 5. Space Complexity: O(1) def bubble_sort(arr): n = len(arr) for i in range(n): for j in range(0, n - i - 1): if arr[j] > arr[j + 1]: arr[j], arr[j + 1] = arr[j + 1], arr[j] return arr ``` ## System Design Questions ``` >>> Design a simple REST API Here's a basic Flask REST API structure: from flask import Flask, jsonify, request app = Flask(__name__) # GET endpoint @app.route('/api/users', methods=['GET']) def get_users(): return jsonify({'users': users_data}) # POST endpoint @app.route('/api/users', methods=['POST']) def create_user(): user_data = request.get_json() # Process and store user return jsonify({'status': 'created'}), 201 if __name__ == '__main__': app.run(debug=True) ``` ## Off-Topic Redirect ``` >>> What's the weather like? I specialize in computer science topics. Please ask about programming, algorithms, systems, or software development. >>> Tell me a joke I focus on computer science subjects. How about asking me to explain an algorithm or help with coding instead? ```