Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 9 Online
OpenStudy (anonymous):

I'm thinking about writing a program for a supermarket. When I looking in a recipe I see everthing is imposible,please can someone give me an idea to get starting?

OpenStudy (e.mccormick):

What type of program? What is it supposed to run on? Much of programming is planning. You need to develop the plan first!

OpenStudy (rsmith6559):

Break the problem down into smaller problems, then break them down into smaller problems and keep on doing that until it looks possible, and then break them down until you're writing small, say 15 or less, lines of code for each of the sub-sub-sub-subproblems.

OpenStudy (anonymous):

Can someone gime me an idea about this problem,I would like to use a loop to deal with this program. def grocery(): product = raw_input("enter the product: ") qty = int(raw_input("enter the qty: ")) inventory = {"banana": 2.25, "pears":2.35, "oranges": 1.75} usr = inventory[product] price = qty * usr product = raw_input("enter the product: ") qty = int(raw_input("enter the qty: ")) usr = inventory[product] price = qty * usr usr = raw_input("enter the product: ") qty = int(raw_input("enter the qty: ")) product = inventory[product] price = qty * product total = price + price + price print total

OpenStudy (rsmith6559):

Each time you assign to price, you overwrite it's previous value. Your total will equal the last price * 3. If you want to use a loop, there are basically two types: a while loop or a for loop. for loops are basically for counting through a number of iterations. while loops basically continue until it's condition becomes false: while( groceryBagIsFull == False ): # add stuff for i in xrange( 0, 10, 1 ): # will count from 0 to 9

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!