From 8576ffe887c6a3cc196bb763a79ab06b056d9bc1 Mon Sep 17 00:00:00 2001 From: Norah Saeed Date: Tue, 17 Feb 2026 21:48:57 +0300 Subject: [PATCH] The solution of first lab in python --- Bonus_solution.py | 26 ++++++++++++++++++++++++++ "Lab_\331\215solution.py" | 20 ++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 Bonus_solution.py create mode 100644 "Lab_\331\215solution.py" diff --git a/Bonus_solution.py b/Bonus_solution.py new file mode 100644 index 0000000..922585c --- /dev/null +++ b/Bonus_solution.py @@ -0,0 +1,26 @@ +sentence ="Welcome to the world of programming, where creativity meets logic" +word="Welcome" + +#Print the length of the sentence. +print("The length of the sentence:" ,len(sentence)) + +#Print the index of the first occurrence of the word in the sentence. +print("Index of the first occurrence of the word:",sentence[0]) + +#Print the number of times the word appears in the sentence. +print("Number of times the word appears:", sentence.count(word)) + +#Print the sentence in all uppercase letters. +print("The sentence in uppercase:", sentence.upper()) + +#Print the sentence in all lowercase letters. +print("The sentence in lowercase: ",sentence.lower()) + +# Replace the word in the sentence with a new word of your choice +the_new_word=sentence.replace("programming","coding") +print("the word in the sentence with a new word:",the_new_word) + +#Print the last character of the sentence. +print("the last character of the sentence:",sentence[-1]) + + diff --git "a/Lab_\331\215solution.py" "b/Lab_\331\215solution.py" new file mode 100644 index 0000000..4c86186 --- /dev/null +++ "b/Lab_\331\215solution.py" @@ -0,0 +1,20 @@ +price = 2.99 + +quantity= 3 + +tax_rate = 15 + +subtotal= price * quantity + +tax= round(subtotal * (tax_rate/100),2) + +total= subtotal + tax + +print(f"Price of item: ${price}") +print(f"Quantity: {quantity}") +print(f"Tax rate: {tax_rate}%") + +#Print the subtotal, tax, and total costs, formatted as currency. +print(f"Subtotal: ${subtotal}") +print(f"Tax: ${tax}") +print(f"Total: ${total}")