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 Bonus_solution.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
sentence ="Welcome to the world of programming, where creativity meets logic"
word="Welcome"

#Print the length of the sentence.
print("The length of the sentence:" ,len(sentence))

#Print the index of the first occurrence of the word in the sentence.
print("Index of the first occurrence of the word:",sentence[0])

#Print the number of times the word appears in the sentence.
print("Number of times the word appears:", sentence.count(word))

#Print the sentence in all uppercase letters.
print("The sentence in uppercase:", sentence.upper())

#Print the sentence in all lowercase letters.
print("The sentence in lowercase: ",sentence.lower())

# Replace the word in the sentence with a new word of your choice
the_new_word=sentence.replace("programming","coding")
print("the word in the sentence with a new word:",the_new_word)

#Print the last character of the sentence.
print("the last character of the sentence:",sentence[-1])


20 changes: 20 additions & 0 deletions Lab_ٍsolution.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
price = 2.99

quantity= 3

tax_rate = 15

subtotal= price * quantity

tax= round(subtotal * (tax_rate/100),2)

total= subtotal + tax

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

#Print the subtotal, tax, and total costs, formatted as currency.
print(f"Subtotal: ${subtotal}")
print(f"Tax: ${tax}")
print(f"Total: ${total}")