From b12661072e386a73420db02d6f7dea5da22744b4 Mon Sep 17 00:00:00 2001 From: FadhelAlmalki Date: Tue, 17 Feb 2026 23:20:25 +0300 Subject: [PATCH] added my solution --- bonus.py | 13 +++++++++++++ cashier.py | 21 +++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 bonus.py create mode 100644 cashier.py diff --git a/bonus.py b/bonus.py new file mode 100644 index 0000000..ca9a0f0 --- /dev/null +++ b/bonus.py @@ -0,0 +1,13 @@ +my_sentence = "Success is built on daily discipline, quiet persistence, " \ +"and the courage to keep going when progress feels invisible" + +word = "courage" + +print("Length of my_sentence:",len(my_sentence)) +print("first occurrence index:",my_sentence.index(word)) +print("number of occurrences:",my_sentence.count(word)) +print("uppercase version:",my_sentence.upper()) +print("lowercase version:",my_sentence.lower()) +my_new_sentence = my_sentence.replace(word, "perseverance") +print("new sentence:", my_new_sentence) +print("last character of my_sentence:", my_sentence[-1]) \ No newline at end of file diff --git a/cashier.py b/cashier.py new file mode 100644 index 0000000..f270202 --- /dev/null +++ b/cashier.py @@ -0,0 +1,21 @@ +price:float = 2.99 +quantity:int = 3 +tax_rate:float = 0.075 + +# To Calculate subtotal +subtotal:float = price * quantity + +# To Calculate tax +tax:float = subtotal * tax_rate + +# To Calculate total cost +total:float = subtotal + tax + +# To print the subtotal, tax, and total +print(f"Price of item: ${price:.2f}") +print(f"Quantity: {quantity}") +print(f"Tax rate: {tax_rate:.1%}") +print() +print(f"Subtotal: ${subtotal:.2f}") +print(f"Tax: ${tax:.2f}") +print(f"Total: ${total:.2f}") \ No newline at end of file