diff --git a/cashier_system_project.py b/cashier_system_project.py new file mode 100644 index 0000000..3b310a1 --- /dev/null +++ b/cashier_system_project.py @@ -0,0 +1,21 @@ +# used input() to get the item cost from the cashier +# This section handles getting input values from the cashier (item price and quantity) +price = float(input("Enter the cost of the item: ")) +quantity =int(input("Enter quantity: ")) + +# fixed tax rate to be used later assigned directly instead of using input() +tax_rate = 0.075 + +# Calculation section: compute subtotal, tax, and total +subtotal = price * quantity +tax = subtotal * tax_rate +total = subtotal + tax + +# Output section: display item price, quantity, tax rate, subtotal, tax, and total +print(f"Price of item: ${price:.2f}") +print(f"Quantity: {quantity}") +print(f"Tax rate: {tax_rate*100:.1f}%\n") + +print(f"Subtotal: ${subtotal:.2f}") +print(f"Tax: ${tax:.2f}") +print(f"Total: ${total:.2f}") \ No newline at end of file diff --git a/lab_bonus.py b/lab_bonus.py new file mode 100644 index 0000000..c0a75ba --- /dev/null +++ b/lab_bonus.py @@ -0,0 +1,25 @@ +sentence = "We are about to finish the first week of the web development bootcamp using Python It has been an amazing experience full of learning and practice. I got familiar with programming basics, the Command Line, and Git/GitHub fundamentals. I am very excited for the upcoming weeks to apply everything I have learned on real projects." +word = "Python" + +# Length of the sentence +print("Length of sentence:", len(sentence)) + +# Index of first occurrence of the word +print("Index of first occurrence of the word:", sentence.find(word)) + +# Number of times the word appears +count = sentence.count(word) +print(f"The word {word} appears {count} time(s) in the sentence.") + +# Sentence in all uppercase +print("Uppercase:", sentence.upper()) + +# Sentence in all lowercase +print("Lowercase:", sentence.lower()) + +# Replace the word with a new word +new_sentence = sentence.replace(word, "Python3") +print("Sentence after replacement:", new_sentence) + +# Last character of the sentence +print("Last character of the sentence:", sentence[-1])