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
18 changes: 18 additions & 0 deletions lab1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
price=2.99
quantity=3
tax_rate=7.5

# calculate subtotal
subtotal=price*quantity
# calculate tax
tax=subtotal*(tax_rate/100)
# Calculate total
total=subtotal+tax

print(f"Price of item: ${price}")
print(f"Quantity: {quantity}")
print(f"Tax rate: {tax_rate}%\n")

print(f"Subtotal: ${subtotal:.2f}")
print(f"Tax: ${tax:.2f}")
print(f"Total: ${total:.2f}")
18 changes: 18 additions & 0 deletions txt1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
sentence1=" Success does not happen overnight it comes from small efforts repeated consistently over time"
sentence2="overnight"

# length of the sentence
print(len(sentence1))
# index of the first occurrence of the word
print(sentence1.index(sentence2))
# number of times the word appears
print(sentence1.count(sentence2))
# sentence in all uppercase letters
print(sentence1.upper())
# sentence in all lowercase letters
print(sentence1.lower())
# Replace the sentence2 with a new word
sentence1=sentence1.replace(sentence2, "instantly")
print(sentence1)
#last character of the sentence
print(sentence1[-1])