gpt-3.5-turbo-0125· OpenAI
WildChat-4.8M (AI2)
Code a gst tool
- User
Code a gst tool
- Assistant
import sys
def calculate_gst(amount, gst_rate): gst_amount = amount * gst_rate / 100 total_amount = amount + gst_amount return gst_amount, total_amount
if name == "main": if len(sys.argv) != 3: print("Usage: python gst_tool.py <gst_rate>") sys.exit(1)
try: amount = float(sys.argv[1]) gst_rate = float(sys.argv[2]) except ValueError: print("Invalid input. Amount and GST rate must be numbers.") sys.exit(1) gst_amount, total_amount = calculate_gst(amount, gst_rate) print(f"GST amount: {gst_amount}") print(f"Total amount with GST: {total_amount}") - User
Code a gst tool in html
- Assistant
<label for="gst_rate">GST Rate (%):</label> <input type="text" id="gst_rate" name="gst_rate"><br><br> <input type="button" value="Calculate GST" onclick="calculateGST()"> </form> <div id="result"></div> <script> function calculateGST() { var amount = parseFloat(document.getElementById("amount").value); var gstRate = parseFloat(document.getElementById("gst_rate").value); var gstAmount = amount * (gstRate / 100); var totalAmount = amount + gstAmount; document.getElementById("result").innerHTML = "GST Amount: " + gstAmount.toFixed(2) + "<br>Total Amount with GST: " + totalAmount.toFixed(2); } </script>