Giter Club home page Giter Club logo

lab_arithmetic_string_operations's Introduction

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.

lab_arithmetic_string_operations's People

Contributors

aqeel-aleid avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.