Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #35559

Re: Please help if you can!

Date 2012-12-26 19:53 -0500
From Mitya Sirenef <msirenef@lightbird.net>
Subject Re: Please help if you can!
References <7333128a-6866-4e3c-8436-d5b2397beadc@googlegroups.com> <mailman.1304.1356565828.29569.python-list@python.org> <e3214f67-f6c3-40e4-9fed-6feadb526fc3@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.1310.1356569625.29569.python-list@python.org> (permalink)

Show all headers | View raw


On 12/26/2012 07:04 PM, bobflipperdoodle@gmail.com wrote:
> First, sorry for starting a new post - I didn't want anyone to have to read through the whole first one when the questions were completely different :/
>
> Second, I honestly have no idea how to answer your questions.  I am a sophomore in high school and I am trying to learn this on my own because my teacher is not very good at explaining things.
>
> i just cant figure out how to get the total when an order is placed without the customer ordering at least one of each item.  I also can't figure out how to get the shipping to calculate correctly. It is an intro class and we are using just the basics. Most of what Mitya said is stuff I've never seen before, although I am very grateful for her response, I am supposed to use only what the teacher "taught".


I'm sorry to hear that, I just want to clarify - the teacher did not yet 
cover
the use of lists, dictionaries and functions?

If that's the case, I have to agree with you that he's probably not a very
good teacher because this task can be done much easier and better
with those 3 concepts, all of which are very easy. If you are barred from
using them, Joshua's post will be most helpful.

If you are curious about the 3 concepts I mentioned, they are covered
in the official python tutorial, but the quick rundown is:

list: a list of items, e.g. a shopping list:

shoplist = ["tea", "cake", "blueberries"]

dictionary: a collection of keys/values, like words/definitions in a 
dictionary:

shopping_cart = {"yoda": 3, "dvd": 5}      # 3 of yoda figures, 5 dvds


function: a way to group a bunch of code together:

def main():
   # do something
   # do something else
   # la la la

main()

The nice thing about functions is that if you need to repeat
something, let's say, two thousand times, you just call the
function two thousand times, e.g.:

for x in range(2000): main()

Which is much easier than typing in two thousand copies of the same code
  (don't ask me how I know!)

  - mitya


-- 
Lark's Tongue Guide to Python: http://lightbird.net/larks/

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Please help if you can! bobflipperdoodle@gmail.com - 2012-12-26 15:04 -0800
  Re: Please help if you can! Dave Angel <d@davea.name> - 2012-12-26 18:49 -0500
    Re: Please help if you can! bobflipperdoodle@gmail.com - 2012-12-26 16:04 -0800
      Re: Please help if you can! Chris Angelico <rosuav@gmail.com> - 2012-12-27 11:35 +1100
      Re: Please help if you can! Joshua Landau <joshua.landau.ws@gmail.com> - 2012-12-27 00:45 +0000
      Re: Please help if you can! Mitya Sirenef <msirenef@lightbird.net> - 2012-12-26 19:53 -0500
      Re: Please help if you can! Chris Angelico <rosuav@gmail.com> - 2012-12-27 12:00 +1100
        Re: Please help if you can! alex23 <wuwei23@gmail.com> - 2012-12-26 22:33 -0800
      Re: Please help if you can! Mitya Sirenef <msirenef@lightbird.net> - 2012-12-26 20:17 -0500
      Re: Please help if you can! Chris Angelico <rosuav@gmail.com> - 2012-12-27 12:23 +1100
      Re: Please help if you can! Mitya Sirenef <msirenef@lightbird.net> - 2012-12-26 20:42 -0500
      Re: Please help if you can! Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-12-26 21:45 -0500
    Re: Please help if you can! bobflipperdoodle@gmail.com - 2012-12-26 16:04 -0800
  Re: Please help if you can! Joshua Landau <joshua.landau.ws@gmail.com> - 2012-12-26 23:57 +0000
    Re: Please help if you can! bobflipperdoodle@gmail.com - 2012-12-26 16:19 -0800
    Re: Please help if you can! bobflipperdoodle@gmail.com - 2012-12-26 16:19 -0800
  Re: Please help if you can! Dennis <daodennis@gmail.com> - 2012-12-26 17:20 -0800

csiph-web