25 lines
600 B
Python
25 lines
600 B
Python
def calculate_discount(price, discount_percent):
|
|
# Bug: doesn't handle discount > 100 or negative price
|
|
discount_amount = price * (discount_percent / 100)
|
|
final_price = price - discount_amount
|
|
|
|
# Bug: syntax error logic
|
|
if final_price < 0
|
|
final_price = 0
|
|
|
|
return final_price
|
|
|
|
def divide_numbers(a, b):
|
|
# Bug: division by zero not handled
|
|
return a / b
|
|
|
|
# Hardcoded secret
|
|
API_KEY = "sk-live-1234567890abcdef1234567890abcdef"
|
|
|
|
def main():
|
|
print(calculate_discount(100, 20))
|
|
print(divide_numbers(10, 0))
|
|
|
|
if __name__ == '__main__':
|
|
main()
|