Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6844743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:24:56+00:00 2026-05-27T00:24:56+00:00

I have been trying to make a cash register like code, where the user

  • 0

I have been trying to make a cash register like code, where the user types in their product name the price and the quantity. I have four products. After doing all the adding for these i need to get the 5% GST and then print out the total amount including the GST. This is what i could come with so far and i am new to python that’s why i don’t know a lot of error and other keywords. I get and ut in everything but when i multiply it says it can’t multiply string and an integer. I tried changing the variable name and did all other stuff but it wouldn’t give a total.

name1 =raw_input('What Item do you have: ')
price1 = float(input('What is the price of your item: '))
quantity1 = float(input('How many are you buying: '))
name2 = raw_input('What Item do you have: ')
price2 = float(input('What is the price of your item: '))
quantity2 = float(input('How many are you buying: '))
name3 = raw_input('What Item do you have: ')
price3 = float(input('What is the price of your item: '))
quantity3 = float(input('How many are you buying: '))
name4= raw_input('What Item do you have: ')
price4 = float(input('What is the price of your item: '))
quantity4 = float(input('How many are you buying: '))
sum_total= (price1 * quantity1), (price2 * quantity2), (price3 * quantity3), (price4 * quantity4),
print(' %.2f ' %  quantity1+quantity2+quantity3,' X ', name1+name2+name3,' @ %.2f ' %  
price1+ price2+price3,' = %.2f ' % total)
divv = sum_total / 100
percent = divv * 0.05
gst = sum_total + percent
print('The suggested gst is %.2f '% percent )
print('That will be a total of: %.2f '% gst)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T00:24:56+00:00Added an answer on May 27, 2026 at 12:24 am

    It can be simplified a lot.

    Your code for asking about products could be simplified to this:

    def ask_for_products(how_many):
        products = []
        for i in xrange(how_many):
            product = {
                'name': raw_input('What Item do you have: '),
                'price': float(input('What is the price of your item: ')),
                'quantity': float(input('How many are you buying: '))
            }
        products.append(product)
        return products
    

    which will make your code more flexible and modular.

    Total sum can be calculated like this (assuming products contains result of the above function):

    total_sum = sum([i['price']*i['quantity'] for i in products])
    

    Suggested GST, if I understand you correctly, is:

    suggested_gst = .05 * total_sum
    

    You can also print list of products with prices and quantities:

    for p in products:
        print '%.2f X %.2f %s' % (p['quantity'], p['price'], p['name'])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to make a method where the user can input a
I have been trying to make OOP PHP5 code. But I think my attempts
I have been trying to make a simple app with 3 fields like this:
I have been trying to make a clock that the user can set. I
I have been trying to make a VBA code to do the following. I
I have been trying to make a case for using Python at my work.
I have been trying to make a div fade in evey 30sec and out
I have been trying to make the sub-menu horizontal. In my HTML it looks
I have been trying to make an init script using start-stop-daemon. I am stuck
I have been trying to make this to be a little jQuery plugin that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.