Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions lab bonis.py
Original file line number Diff line number Diff line change
@@ -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])
17 changes: 17 additions & 0 deletions lab.py
Original file line number Diff line number Diff line change
@@ -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}")