<div dir="ltr">Thank you all for your help with this program. Each of your answers helped me piece together an understanding of the assignment. After several days and clearly over-thinking the entire process, I ended up using the following code:<div>
<br></div><div><div>def main ():</div><div>    name = input("Please enter the name of the product: ")</div><div>    weight = float(input("Please enter the weight of the product in pounds: "))</div><div>
<br></div><div>    cal_shiprate (name, weight)</div><div> <br></div><div>def cal_shiprate(product_name, product_weight):</div><div><br></div><div>    if product_weight < 10:</div><div>       ship_rate = 1.5</div><div>    elif product_weight >= 10 and product_weight < 25:</div>
<div>       ship_rate = 1.45</div><div>    else:</div><div>        ship_rate = 1.4</div><div><br></div><div>    total = product_weight * ship_rate</div><div><br></div><div>    print("")</div><div>    print(product_name, "weight in pounds              ", format (product_weight, '9,.2f'))</div>
<div>    print ("Your total to ship", product_name, "is:      $", format (total, '9,.2f'))</div><div>    </div><div>           </div><div><br></div><div><br></div><div>main ()</div><div><br></div>
<div><br></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Oct 20, 2013 at 6:01 PM, Ricardo Aráoz <span dir="ltr"><<a href="mailto:ricaraoz@gmail.com" target="_blank">ricaraoz@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  

    
  
  <div bgcolor="#FFFFFF" text="#000000">
    Sorry, I sent this answer to the OP directly and not to the list.<br>
    <div><br>
      -------- Mensaje original --------
      <table cellpadding="0" cellspacing="0" border="0">
        <tbody>
          <tr>
            <th align="RIGHT" nowrap valign="BASELINE">Asunto:
            </th>
            <td>Re: [Tutor] Passing arguments?</td>
          </tr>
          <tr>
            <th align="RIGHT" nowrap valign="BASELINE">Fecha: </th>
            <td>Sun, 20 Oct 2013 11:25:52 -0300</td>
          </tr>
          <tr>
            <th align="RIGHT" nowrap valign="BASELINE">De: </th>
            <td>Ricardo Aráoz <a href="mailto:ricaraoz@gmail.com" target="_blank"><ricaraoz@gmail.com></a></td>
          </tr>
          <tr>
            <th align="RIGHT" nowrap valign="BASELINE">A: </th>
            <td>Jenny Allar <a href="mailto:jennyallar@gmail.com" target="_blank"><jennyallar@gmail.com></a></td>
          </tr>
        </tbody>
      </table><div><div class="h5">
      <br>
      <br>
      
      <div>El 20/10/13 01:20, Jenny Allar
        escribió:<br>
      </div>
      <blockquote type="cite">
        <div dir="ltr">
          <div>I've written the code below the assignment, and I think I
            have everything covered in terms of asking the user for the
            information I need and somehow calculating costs, but I'm
            just ridiculously confused on the order and placement of the
            functions and components of this program- specifically the
            shiprate variable. Thank you in advance for any help.<br>
          </div>
          <div><br>
          </div>
        </div>
      </blockquote>
      <br>
      Ok, just a couple of things first. <br>
      <br>
      - Your assignment specifically says 'always use "while loops" to
      validate' but I see no loop at all in your code. You might want to
      look into it.<br>
      <br>
          - What your assignment points to when it says to use "while
      loops" is that you should validate that what the user inputs is a
      valid number. If the user will input something else than a number
      as the weight then when you apply the int() function an exception
      will be flagged and your program will terminate ungracefully. You
      may validate input using "exceptions" and "while loops" (look it
      up).<br>
      <br>
      - Your functions should do what their name imply, and preferably
      do only one thing. Having a function named calc_weight_large()
      that also prints the shipping cost is not good.<br>
      <br>
      - Your if asks for >= 10 and your elif for <= 10 when the "=
      10" case was already handled by the first if, that is a mistake.
      Besides which it might be better looking (though this is a matter
      of personal preference) if you ::<br>
              if weight > 25<br>
                  # do something<br>
              elif weight > 10<br>
                  # do something else<br>
              else<br>
                  # do something entirely different<br>
      <br>
      - I would structure the program in the following way ::<br>
              def main():<br>
                  product = in_product()<br>
                  weight = in_weight()<br>
      <br>
                  if weight > 25<br>
                      total = calc_shipping(1.40, weight)<br>
                  elif weight > 10<br>
                      total = calc_shipping(1.45, weight)<br>
                  else<br>
                      total = calc_shipping(1.50, weight)<br>
                  print_data(product, weight, total)<br>
      <br>
      <blockquote type="cite">
        <div dir="ltr">This is my assignment:
          <div>
            <p class="MsoNormal"><span style="font-size:11pt;font-family:Arial,sans-serif">Write

                a program that asks a user for the name of a product
                that they are ordering online and its weight.  The
                program must calculate the cost of shipping the product
                using the following cost structure.  If it weighs less
                than 10 pounds the cost is $1.50 per pound, if it is 10
                pounds or more and less than 25 pounds then the cost is
                $1.45 per pound.  If the weight is 25 pounds or more the
                cost is $1.40 per pound.  You may get the data from the
                user in main.  You must print the name of the product,
                the weight and the cost of shipping in a separate
                function.</span></p>
            <p class="MsoNormal"><span style="font-size:11pt;font-family:Arial,sans-serif"> </span></p>
            <p class="MsoNormal"><b><u><span style="font-size:11pt;font-family:Arial,sans-serif">*********NOTE: 

                    ALWAYS USE “WHILE LOOPS” To
                    Validate*******************</span></u></b></p>
            # This program uses an if-else statement<br>
            <br>
            # It asks for the name of a product and the weight of that
            product.<br>
            # It then determines the shipping cost as defined by the
            weight.<br>
            #<br>
            # Variable          Type          Purpose<br>
            # product           string          hold for name of product<br>
            # weight             float           hold for weight of
            product<br>
            #<br>
            <br>
            def main ():<br>
                product = input("Please enter the name of the product:
            ") <br>
                weight = int(input("Please enter the weight of the
            product: "))<br>
            <br>
                print('Product:', product)<br>
                print('Weight:', weight)<br>
            <br>
                if weight <= 10:<br>
                    shiprate = 1.5<br>
                    calc_weight_small(weight, shiprate)<br>
                elif weight >= 10 and weight <= 25:<br>
                    shiprate = 1.45<br>
                    calc_weight_medium(weight, shiprate)<br>
                else:<br>
                    shiprate = 1.4<br>
                    calc_weight_large(weight, shiprate)<br>
            <br>
            # Calculate shipping cost for product less than 10 pounds<br>
            def cacl_weight_small(weight, shiprate):<br>
                shiprate = 1.5<br>
                total = weight * shiprate<br>
          </div>
        </div>
      </blockquote>
      <br>
      <blockquote type="cite">
        <div dir="ltr">
          <div># Calculate shipping cost for product between 10 and 25
            pounds.<br>
            def calc_weight_medium(weight, shiprate):<br>
                shiprate = 1.45<br>
                total = weight * shiprate<br>
          </div>
        </div>
      </blockquote>
      <br>
      <blockquote type="cite">
        <div dir="ltr">
          <div># Calculate shipping cost for product over 25 pounds.<br>
            #<br>
            #This function calculates and prints the total cost<br>
            # based on the weight category the product falls into<br>
            # Variable            Type         Purpose<br>
            <br>
            #  weight               float        weight of product<br>
            #  shiprate            float        cost per pound<br>
            #  total                   float        total cost to ship
            product<br>
            #<br>
            def calc_weight_large(weight, shiprate):<br>
                shiprate = 1.4<br>
                total = weight * shiprate<br>
                print ()<br>
                print ("The cost to ship", product, "is:        $",
            format (total,  '9,.2f'))<br>
            <br>
            main ()</div>
        </div>
        <br>
      </blockquote>
      <br>
      <br>
    </div></div></div>
    <br>
  </div>

<br>_______________________________________________<br>
Tutor maillist  -  <a href="mailto:Tutor@python.org">Tutor@python.org</a><br>
To unsubscribe or change subscription options:<br>
<a href="https://mail.python.org/mailman/listinfo/tutor" target="_blank">https://mail.python.org/mailman/listinfo/tutor</a><br>
<br></blockquote></div><br></div>