diff --git a/lab bonis.py b/lab bonis.py new file mode 100644 index 0000000..6ba237a --- /dev/null +++ b/lab bonis.py @@ -0,0 +1,26 @@ +sentence = "Learning Python is very useful and Python makes programming easier and more enjoyable." + +# Define a word that appears in the sentence +word = "Python" + +# Print the length of the sentence +print("Length of sentence:", len(sentence)) + +# Print the index of the first occurrence of the word +print("First occurrence index:", sentence.find(word)) + +# Print the number of times the word appears +print("Number of occurrences:", sentence.count(word)) + +# Print the sentence in all uppercase letters +print("Uppercase:", sentence.upper()) + +# Print the sentence in all lowercase letters +print("Lowercase:", sentence.lower()) + +# Replace the word with a new word +new_sentence = sentence.replace(word, "Coding") +print("Replaced sentence:", new_sentence) + +# Print the last character of the sentence +print("Last character:", sentence[-1]) \ No newline at end of file diff --git a/lab.py b/lab.py new file mode 100644 index 0000000..967eeaf --- /dev/null +++ b/lab.py @@ -0,0 +1,17 @@ +price = 2.99 # cost of one item +quantity = 3 # number of items +tax_rate = 0.075 # 7.5% tax rate in decimal form + +# Calculate subtotal +subtotal = price * quantity + +# Calculate tax +tax = subtotal * tax_rate + +# Calculate total cost +total = subtotal + tax + +# Print results formatted as currency (two decimal places) +print(f"Subtotal: ${subtotal:.2f}") +print(f"Tax: ${tax:.2f}") +print(f"Total: ${total:.2f}") \ No newline at end of file