Need Some help ith coding

This is the place for queries that don't fit in any of the other categories.

Need Some help ith coding

Postby vadimak » Wed May 01, 2013 1:11 pm

Hello i have this sumetive to do :

Mr. is starting a computer parts store in his spare time. He would like to employ his student to write a computer program that would handle the cash sales.
When a customer brings their purchases up to the cash register, the bar code of the item will be scanned by your program. When all the items are scanned, a receipt will be printed out on the computer screen showing

How can i do it ?? i think i should make kind of detabase of products with prices and barcodes . But how?

Thank for any Help
vadimak
 
Posts: 15
Joined: Wed May 01, 2013 1:07 pm

Re: Need Some help ith coding

Postby hansn » Wed May 01, 2013 2:23 pm

You can use a dictionary.

dictionary = {00001111 : ("apple", cost, etc)}
Last edited by hansn on Wed May 01, 2013 5:00 pm, edited 1 time in total.
hansn
 
Posts: 87
Joined: Thu Feb 21, 2013 8:46 pm

Re: Need Some help ith coding

Postby rrashkin » Wed May 01, 2013 2:29 pm

Consider a dictionary, dctCodes, where the key would be the barcode. Then the associated value could be a tuple containing the item name, the number in stock, the price, anything else you want. So dctCodes = {1234567: ('thing 1',12, 4.22), ...}.

Now I don't know what device reads the code but once it's read,

price=dctCodes[1234567][2]
num=dctCodes[1234567][1]
name=dctCodes[1234567][0]

Then after the transaction: dctCodes[1234567]=(name,num-1,price)
___________________
Bob Rashkin
User avatar
rrashkin
 
Posts: 35
Joined: Tue Feb 12, 2013 4:47 pm

Re: Need Some help ith coding

Postby vadimak » Wed May 01, 2013 2:32 pm

Tnx. I cant find examples in internet can you help me.
for exmaple :
i5 3570k - 218$ Barcod - 02315782
i7-3570k 493$ 0439379

How i amking its working i want to buy this items and get total cost?


tnx again
vadimak
 
Posts: 15
Joined: Wed May 01, 2013 1:07 pm

Re: Need Some help ith coding

Postby vadimak » Wed May 01, 2013 3:11 pm

When i am using this codes : 02315782,04395379 its becoming red and saing invalid token
vadimak
 
Posts: 15
Joined: Wed May 01, 2013 1:07 pm

Re: Need Some help ith coding

Postby hansn » Wed May 01, 2013 5:00 pm

vadimak wrote:When i am using this codes : 02315782,04395379 its becoming red and saing invalid token


Show us the code you have, and the error you get, in code tags.
hansn
 
Posts: 87
Joined: Thu Feb 21, 2013 8:46 pm

Re: Need Some help ith coding

Postby vadimak » Thu May 02, 2013 2:49 am

Code: Select all
i5-3570 = {02315782 : ('name':i5-3570k,'Price':25,'Barckode':02315782)}
i7-3570 = {02315782 : ('name':i7-3570k,'Price':50,'Barckode':0439379)}

How can i make it works now?
i need to input a barcodes for example i want to buy 2 of i5-3570 and 3 of i7-3570 so i am inputing the barocd of i5 two times and i7 three time and then i am press Done and it will show me the price of total .
and i will count downt the stock level ;D

Thank for helping
vadimak
 
Posts: 15
Joined: Wed May 01, 2013 1:07 pm

Re: Need Some help ith coding

Postby micseydel » Thu May 02, 2013 4:12 am

You can't have a minus sign on the left hand side of an assignment (equals sign). Variable names must be composed of characters, numbers and underscores and not start with a number. If you want a label like that in your code, you can use a dictionary to store arbitrary strings, and whatever you want associated with it.
Join the #python-forum IRC channel on irc.freenode.net!

Please do not PM members regarding questions which are meant to be discussed publicly. The point of the forum is so that others can benefit from it. We don't want to help you over PMs or emails.
User avatar
micseydel
 
Posts: 1222
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA

Re: Need Some help ith coding

Postby vadimak » Thu May 02, 2013 12:19 pm

So what can i do now ? how i making it ?
vadimak
 
Posts: 15
Joined: Wed May 01, 2013 1:07 pm

Re: Need Some help ith coding

Postby setrofim » Thu May 02, 2013 1:37 pm

Code: Select all
bar_codes = {
    'i5-3570' : {02315782 : ('name':i5-3570k,'Price':25,'Barckode':02315782)}
    'i7-3570' : {02315782 : ('name':i7-3570k,'Price':50,'Barckode':0439379)}
}
setrofim
 
Posts: 288
Joined: Mon Mar 04, 2013 7:52 pm

Re: Need Some help ith coding

Postby Kebap » Thu May 02, 2013 1:53 pm

Quoted for reference
vadimak wrote:Hello i have this sumetive to do :

Mr. is starting a computer parts store in his spare time. He would like to employ his student to write a computer program that would handle the cash sales.
When a customer brings their purchases up to the cash register, the bar code of the item will be scanned by your program. When all the items are scanned, a receipt will be printed out on the computer screen showing

How can i do it ?? i think i should make kind of detabase of products with prices and barcodes . But how?

Thank for any Help
vadimak wrote:Tnx. I cant find examples in internet can you help me.
for exmaple :
i5 3570k - 218$ Barcod - 02315782
i7-3570k 493$ 0439379

How i amking its working i want to buy this items and get total cost?


tnx again
vadimak wrote:
Code: Select all
i5-3570 = {02315782 : ('name':i5-3570k,'Price':25,'Barckode':02315782)}
i7-3570 = {02315782 : ('name':i7-3570k,'Price':50,'Barckode':0439379)}

How can i make it works now?
i need to input a barcodes for example i want to buy 2 of i5-3570 and 3 of i7-3570 so i am inputing the barocd of i5 two times and i7 three time and then i am press Done and it will show me the price of total .
and i will count downt the stock level ;D

Thank for helping
vadimak wrote:So can some one help me ?
oops i am sorry i didnt pay antation on the changes sorry ;D tnx
Code: Select all
bc=input("Please scan or type a barcode");
caounter=2
tp=0

if caounter<3:

    if bc==04353736:

         price="218$"
         name="i5-3570k"


    if bc==04322575:

        price="493$"
        name="i7-3570k"



    if bc==04201221:

        price="40$"
        name="CM Hyper 212 Evo"



    if bc==03745501:

        price="330$"
        name="AMD HD 7950"



    if bc==01323661:

        price="990$"
        name="GTX Titan"



    if bc==04221214:

        price="49$"
        name="Haf 912 Advance"



    if bc==04664125:

        price="67$"
        name="8GB (2x4GB) 1600"



    if bc==04664125:

        price="67$"
        name="8GB (2x4GB) 1600"



    if bc==07743210:

        price="139$"
        name="MSI Z77A-G43"



    if bc==01236252:

        price="99$"
        name="ADATA 120GB 6GB/S"




    if bc==04625152:

        price="48$"
        name="Razer Deathader"

    if bc==0:
        caounter==4

tp==tp+price
print"",tp

8$"
        name="Razer Deathader"

tp==tp+price
print"",tp
caounter==4

THis is what i did but its not working. So i was tring to do in a loop. i will input a barckods until i hit "0" and then it will give me a total sum

Last edited by Kebap on Fri May 03, 2013 11:12 am, edited 3 times in total.
Learn: How To Ask Questions The Smart Way
Join the #python-forum IRC channel on irc.freenode.net and chat with uns directly!
Kebap
 
Posts: 382
Joined: Thu Apr 04, 2013 1:17 pm
Location: Germany, Europe

Re: Need Some help ith coding

Postby vadimak » Thu May 02, 2013 11:10 pm

So can some one help me ?
vadimak
 
Posts: 15
Joined: Wed May 01, 2013 1:07 pm

Re: Need Some help ith coding

Postby micseydel » Thu May 02, 2013 11:16 pm

setrofim tried to give you an example of what I told you. If you aren't helped yet, you need to ask a specific question. Or likely, even go through a beginner's tutorial.
Join the #python-forum IRC channel on irc.freenode.net!

Please do not PM members regarding questions which are meant to be discussed publicly. The point of the forum is so that others can benefit from it. We don't want to help you over PMs or emails.
User avatar
micseydel
 
Posts: 1222
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA

Re: Need Some help ith coding

Postby vadimak » Thu May 02, 2013 11:45 pm

oops i am sorry i didnt pay antation on the changes sorry ;D tnx
vadimak
 
Posts: 15
Joined: Wed May 01, 2013 1:07 pm

Re: Need Some help ith coding

Postby vadimak » Fri May 03, 2013 3:36 am

Code: Select all
bc=input("Please scan or type a barcode");
caounter=2
tp=0

if caounter<3:

    if bc==04353736:

         price="218$"
         name="i5-3570k"


    if bc==04322575:

        price="493$"
        name="i7-3570k"



    if bc==04201221:

        price="40$"
        name="CM Hyper 212 Evo"



    if bc==03745501:

        price="330$"
        name="AMD HD 7950"



    if bc==01323661:

        price="990$"
        name="GTX Titan"



    if bc==04221214:

        price="49$"
        name="Haf 912 Advance"



    if bc==04664125:

        price="67$"
        name="8GB (2x4GB) 1600"



    if bc==04664125:

        price="67$"
        name="8GB (2x4GB) 1600"



    if bc==07743210:

        price="139$"
        name="MSI Z77A-G43"



    if bc==01236252:

        price="99$"
        name="ADATA 120GB 6GB/S"




    if bc==04625152:

        price="48$"
        name="Razer Deathader"

    if bc==0:
        caounter==4

tp==tp+price
print"",tp

8$"
        name="Razer Deathader"

tp==tp+price
print"",tp
caounter==4

THis is what i did but its not working. So i was tring to do in a loop. i will input a barckods until i hit "0" and then it will give me a total sum
vadimak
 
Posts: 15
Joined: Wed May 01, 2013 1:07 pm

Re: Need Some help ith coding

Postby stranac » Fri May 03, 2013 10:46 am

Your code makes absolutely no sense.
You should really go through a beginners tutorial.
Friendship is magic!

R.I.P. Tracy M. You will be missed.
User avatar
stranac
 
Posts: 1096
Joined: Thu Feb 07, 2013 3:42 pm

How to code this ?

Postby vadimak » Sun May 05, 2013 6:27 pm

Hello
i need to make a cash register but i dont know how to do it.
i was thinking about to make it in loop but i dont know how to make its. i need to input a barcode of product each barcode has price an stock level. In the loop i will input a barcode all the time untile i input "Done" and then it will out put me total price and show me how mach left in the stok.

abd i was thinking do make it in dicturiany but i dont know how to make the program take out the price.

Thank for any help ;D
in Python 2.7.3
Last edited by micseydel on Mon May 06, 2013 11:23 pm, edited 1 time in total.
Reason: This was started as a new topic, and has been merged into the proper one.
vadimak
 
Posts: 15
Joined: Wed May 01, 2013 1:07 pm

Re: How to code this ?

Postby Kebap » Mon May 06, 2013 8:45 am

You should maybe try and split this big problem into many smaller problems, which you can then solve 1 by 1. :mrgreen:

Also, what happened to your last thread about this idea? Did you follow the advise given there?

edit: While we are collecting threads by this user, maybe somebody can make sense of it all.. I know I can't

edit: vadimak, Please read this tutorial on How to ask smart questions
Last edited by Kebap on Tue May 07, 2013 10:58 am, edited 2 times in total.
Learn: How To Ask Questions The Smart Way
Join the #python-forum IRC channel on irc.freenode.net and chat with uns directly!
Kebap
 
Posts: 382
Joined: Thu Apr 04, 2013 1:17 pm
Location: Germany, Europe

Re: Need Some help ith coding

Postby micseydel » Mon May 06, 2013 11:29 pm

vadimak, I wrote a very nasty post for you recently that I didn't end up posting because it was inspired by a bitter mood that wasn't your fault. But here's the thing...

We want to help you. But we're not here to do it for you, and you're not helping us to help you. It is extremely rude to ignore the advice of the people in this thread and then start a new one without even acknowledging their generous attempts to help you. You're in luck though, because despite your repeated mistakes, most if not all of us still want to help you. Talk to us. If our advice isn't helping you, tell us why. And I am not joking: go read a tutorial, they're good for you.
Join the #python-forum IRC channel on irc.freenode.net!

Please do not PM members regarding questions which are meant to be discussed publicly. The point of the forum is so that others can benefit from it. We don't want to help you over PMs or emails.
User avatar
micseydel
 
Posts: 1222
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA


Return to General Coding Help

Who is online

Users browsing this forum: No registered users and 1 guest