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
21 changes: 21 additions & 0 deletions cashier_system_project.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# used input() to get the item cost from the cashier
# This section handles getting input values from the cashier (item price and quantity)
price = float(input("Enter the cost of the item: "))
quantity =int(input("Enter quantity: "))

# fixed tax rate to be used later assigned directly instead of using input()
tax_rate = 0.075

# Calculation section: compute subtotal, tax, and total
subtotal = price * quantity
tax = subtotal * tax_rate
total = subtotal + tax

# Output section: display item price, quantity, tax rate, subtotal, tax, and total
print(f"Price of item: ${price:.2f}")
print(f"Quantity: {quantity}")
print(f"Tax rate: {tax_rate*100:.1f}%\n")

print(f"Subtotal: ${subtotal:.2f}")
print(f"Tax: ${tax:.2f}")
print(f"Total: ${total:.2f}")
25 changes: 25 additions & 0 deletions lab_bonus.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
sentence = "We are about to finish the first week of the web development bootcamp using Python It has been an amazing experience full of learning and practice. I got familiar with programming basics, the Command Line, and Git/GitHub fundamentals. I am very excited for the upcoming weeks to apply everything I have learned on real projects."
word = "Python"

# Length of the sentence
print("Length of sentence:", len(sentence))

# Index of first occurrence of the word
print("Index of first occurrence of the word:", sentence.find(word))

# Number of times the word appears
count = sentence.count(word)
print(f"The word {word} appears {count} time(s) in the sentence.")

# Sentence in all uppercase
print("Uppercase:", sentence.upper())

# Sentence in all lowercase
print("Lowercase:", sentence.lower())

# Replace the word with a new word
new_sentence = sentence.replace(word, "Python3")
print("Sentence after replacement:", new_sentence)

# Last character of the sentence
print("Last character of the sentence:", sentence[-1])