Skip to content

alhanoufALLUHAYDAN/LAB_ARITHMETIC_STRING_OPERATIONS

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

LAB_ARITHMETIC_STRING_OPERATIONS

You are a cashier at a grocery store. Write a Python program to calculate the total cost of a customer's purchase, including tax.

  1. Define a variable named "price" and set its value to the cost of the item the customer is purchasing (e.g., $2.99).

  2. Define a variable named "quantity" and set its value to the number of items the customer is purchasing (e.g., 3).

  3. Define a variable named "tax_rate" and set its value to the tax rate in your area (e.g., 7.5%).

  4. Calculate the subtotal by multiplying the price by the quantity and store the result in a variable named "subtotal".

  5. Calculate the tax by multiplying the subtotal by the tax rate (in decimal form, e.g., 0.075) and store the result in a variable named "tax".

  6. Calculate the total cost by adding the subtotal and the tax, and store the result in a variable named "total".

  7. Print the subtotal, tax, and total costs, formatted as currency (e.g., $8.97 for the total cost).

Example output:

Price of item: $2.99
Quantity: 3
Tax rate: 7.5%

Subtotal: $8.97
Tax: $0.67
Total: $9.64

Bonus, create a new python file and do the following:

  • Define a string variable containing a sentence with at least 10 words.
  • Define a string variable containing a word that appears in the sentence.
  • Print the length of the sentence.
  • Print the index of the first occurrence of the word in the sentence.
  • Print the number of times the word appears in the sentence.
  • Print the sentence in all uppercase letters.
  • Print the sentence in all lowercase letters.
  • Replace the word in the sentence with a new word of your choice.
  • Print the last character of the sentence.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%