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
13 changes: 13 additions & 0 deletions bonus.py
Original file line number Diff line number Diff line change
@@ -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])
21 changes: 21 additions & 0 deletions cashier.py
Original file line number Diff line number Diff line change
@@ -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}")