Write an IPO chat which ask a user to enter the price of a dress as $150. A discount of 5 % is offered. Display the cost of the dress after the discount is applied,
(probably gone after not getting an instant answer)
ChatGPT is where you want to ask. However the AI won’t be able to reliably do math as it is based on language.
It can however write code for you, such as this Python script to make a calculator.
# Define a function to calculate the discounted price
def calculate_discounted_price(original_price, discount_rate):
# Calculate the discount amount
discount = original_price * (discount_rate / 100)
# Calculate the final cost after applying the discount
final_cost = original_price - discount
return final_cost
# Welcome message
print("Welcome to the Dress Price Calculator!")
# Get the original price of the dress from the user
original_price = float(input("Enter the original price of the dress: $"))
# Define the discount rate
discount_rate = 5
# Calculate the discounted price using the function
discounted_price = calculate_discounted_price(original_price, discount_rate)
# Display the result to the user
print(f"After applying a {discount_rate}% discount, the cost of the dress is: ${discounted_price}")
# Thank the user for using the calculator
print("Thank you for using the Dress Price Calculator. Happy shopping!")