## 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

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

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

### Re: Need Some help ith coding

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

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

rrashkin

Posts: 35
Joined: Tue Feb 12, 2013 4:47 pm

### Re: Need Some help ith coding

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

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

### Re: Need Some help ith coding

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

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

### Re: Need Some help ith coding

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

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

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

### Re: Need Some help ith coding

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 for off-topic chat!

Please prefer not to PM members. The point of the forum is so that anyone can benefit. We don't want to help you over PMs/emails/Skype chats that others can't benefit from

micseydel

Posts: 2030
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA

### Re: Need Some help ith coding

So what can i do now ? how i making it ?

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

### Re: Need Some help ith coding

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

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
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=2tp=0if 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==4tp==tp+priceprint"",tp8\$"        name="Razer Deathader"tp==tp+priceprint"",tpcaounter==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: 580
Joined: Thu Apr 04, 2013 1:17 pm
Location: Germany, Europe

### Re: Need Some help ith coding

So can some one help me ?

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

### Re: Need Some help ith coding

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 for off-topic chat!

Please prefer not to PM members. The point of the forum is so that anyone can benefit. We don't want to help you over PMs/emails/Skype chats that others can't benefit from

micseydel

Posts: 2030
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA

### Re: Need Some help ith coding

oops i am sorry i didnt pay antation on the changes sorry ;D tnx

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

### Re: Need Some help ith coding

Code: Select all
`bc=input("Please scan or type a barcode");caounter=2tp=0if 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==4tp==tp+priceprint"",tp8\$"        name="Razer Deathader"tp==tp+priceprint"",tpcaounter==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

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

### Re: Need Some help ith coding

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.

stranac

Posts: 1486
Joined: Thu Feb 07, 2013 3:42 pm

### How to code this ?

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.

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

### Re: How to code this ?

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

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

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: 580
Joined: Thu Apr 04, 2013 1:17 pm
Location: Germany, Europe

### Re: Need Some help ith coding

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 for off-topic chat!

Please prefer not to PM members. The point of the forum is so that anyone can benefit. We don't want to help you over PMs/emails/Skype chats that others can't benefit from

micseydel

Posts: 2030
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA