Re: [Tutor] I need help with my project

2018-12-03 Thread Treyton Hendrix
Awesome! Thanks to your help, I finally got my program done. Click here if
you want to see it! >

On Fri, Nov 30, 2018 at 5:14 PM Cameron Simpson  wrote:

> Avi and Alan and Sibylle, you're making this a bit hard on the OP
> (Treyton).
>
> Yes he's supplied no context, but it is easy to make some suggestions.
> Each of yours suggests he design a much wider system (menu entry, web
> interface, some kind of GUI). All of which is (a) beyond him and (b)
> irrelevant.
>
> Why not pretend he _has_ the existing order, from wherever.
>
> Suggest ways to store that order (in a list, or a dict mapping ordable
> items to counts, or something). Then ask him to write a little Python,
> or even detailed English prose.
>
> Treyton: you seem to have recitied a homework question:
> >If the user selected a sandwich, french fries, and a beverage, reduce
> >the
> >total cost of the order by $1.00.
> >This is what I have to do and I don't know where to start.
>
> Ok, this is clear: Treyton can't get off the ground, very common for
> beginning programmers.
>
> The core challenge is to break your problem into a sequence of tasks.
> How would _you_, a person, do this if you had a food order given to you?
>
> Think about a food order. It is usually a list of standard food items, a
> count of how many of each. And each item will have a cost.
>
> The total cost is the sum of (each item's cost * its price * its count),
> for each item in the order. Or for all possible items, by presuming that
> unordered items just have a count of 0.
>
> So you need:
>
> A label for each item, so you can talk about it. You can just use a
> string for this, eg "sandwich" or "fries". Make the strings simple to
> start with to avoid spelling mistakes. You can always associate better
> names with the short strings later.
>
> You need a table of items and their costs. It is normal to make a
> mapping for this, such a Python's dict type. You can write dicts
> literally:
>
>   costs = {
> "sandwich": 200,
> "fries": 100,
>   }
>
> In the example above, I'm imagining you have dollars and cents, and
> making prices in cents.
>
> You also need a representation of the order, being the item type and the
> count. You could use a Python list for this. Example:
>
>   [ "fries", 2 ]
>
> The whole order might be a list of those, example:
>
>   [ ["fries", 2 ], [ "sandwich", 3 ] ]
>
> So, a list of lists.
>
> For purposes of your program you can just set all this stuff up at the
> beginning, not worrying about GUIs or input forma or any complication.
>
>   whole_order = [
> ["fries", 2 ],
> [ "sandwich", 3 ]
>   ]
>
> Now comes the part you need to do:
>
> - write some Python code to compute the total cost of the order (item
>   cost * item count), summed for all the items. Print this raw total so
>   that you can see it is correct.
>
> - write some totally separate code to look at the order and decide if
>   the client met your special condition (sandwich, fries, beverage) and
>   get a true/false result. Print this, too.
>
> - write a Python statement to subtract $1.00 (or 100 cents) from the
>   total if that condition is true. Print that.
>
> Then fiddle the order and run your programme several times to check that
> it is behaving the way it should.
>
> If you find difficulties you cannot surmount, come back here (by
> replying directly to one of the messages in your discussion) with:
>
> - your complete code
>
> - your expected output, and the output from your programme
>
> - a complete transcript of any error message, for example if your
>   programme raised an exception
>
> Make sure these are inline in your message, _not_ attachments. We drop
> attachments in this list.
>
> Cheers,
> Cameron Simpson 
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] I need help with my project

2018-11-30 Thread Cameron Simpson
Avi and Alan and Sibylle, you're making this a bit hard on the OP 
(Treyton).


Yes he's supplied no context, but it is easy to make some suggestions.  
Each of yours suggests he design a much wider system (menu entry, web 
interface, some kind of GUI). All of which is (a) beyond him and (b) 
irrelevant.


Why not pretend he _has_ the existing order, from wherever.

Suggest ways to store that order (in a list, or a dict mapping ordable 
items to counts, or something). Then ask him to write a little Python, 
or even detailed English prose.


Treyton: you seem to have recitied a homework question:
If the user selected a sandwich, french fries, and a beverage, reduce 
the

total cost of the order by $1.00.
This is what I have to do and I don't know where to start.


Ok, this is clear: Treyton can't get off the ground, very common for 
beginning programmers.


The core challenge is to break your problem into a sequence of tasks.  
How would _you_, a person, do this if you had a food order given to you?


Think about a food order. It is usually a list of standard food items, a 
count of how many of each. And each item will have a cost.


The total cost is the sum of (each item's cost * its price * its count), 
for each item in the order. Or for all possible items, by presuming that 
unordered items just have a count of 0.


So you need:

A label for each item, so you can talk about it. You can just use a 
string for this, eg "sandwich" or "fries". Make the strings simple to 
start with to avoid spelling mistakes. You can always associate better 
names with the short strings later.


You need a table of items and their costs. It is normal to make a 
mapping for this, such a Python's dict type. You can write dicts 
literally:


 costs = {
   "sandwich": 200,
   "fries": 100,
 }

In the example above, I'm imagining you have dollars and cents, and 
making prices in cents.


You also need a representation of the order, being the item type and the 
count. You could use a Python list for this. Example:


 [ "fries", 2 ]

The whole order might be a list of those, example:

 [ ["fries", 2 ], [ "sandwich", 3 ] ]

So, a list of lists.

For purposes of your program you can just set all this stuff up at the 
beginning, not worrying about GUIs or input forma or any complication.


 whole_order = [
   ["fries", 2 ],
   [ "sandwich", 3 ]
 ]

Now comes the part you need to do:

- write some Python code to compute the total cost of the order (item 
 cost * item count), summed for all the items. Print this raw total so 
 that you can see it is correct.


- write some totally separate code to look at the order and decide if 
 the client met your special condition (sandwich, fries, beverage) and 
 get a true/false result. Print this, too.


- write a Python statement to subtract $1.00 (or 100 cents) from the 
 total if that condition is true. Print that.


Then fiddle the order and run your programme several times to check that 
it is behaving the way it should.


If you find difficulties you cannot surmount, come back here (by 
replying directly to one of the messages in your discussion) with:


- your complete code

- your expected output, and the output from your programme

- a complete transcript of any error message, for example if your 
 programme raised an exception


Make sure these are inline in your message, _not_ attachments. We drop 
attachments in this list.


Cheers,
Cameron Simpson 
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] I need help with my project

2018-11-28 Thread Avi Gross
I suggest starting at the beginning when asking a question to people who
have no way of knowing what you have not told them.
Your sentence is completely in middle or even near the end of something that
has to be larger:

" If the user selected a sandwich, french fries, and a beverage, reduce the
total cost of the order by $1.00."

It sounds like you are being asked to emulate a place you can buy food. So I
suspect you need to display a menu, ask the user to enter info, keep a
running total and so on.

So how do you think you would store the order as well as whatever you need
to know about past sales or the non-discounted cost of the current order?
How do you see if the current order has all the parts needed for the
discount. Do you need to apply the discount just once or multiple times if
they ordered food for lots of people? 

Sure, we could write some code for you, but perhaps you need to think it
through first and maybe if you get stuck, ask if someone can tell you what
is wrong with the code.

Given what you sent, the answer is easy.

RECOGNIZE they placed an order that meets the criterion:
SUBTRACT 1.00 from their order.

But that is not written in Python for obvious reasons.


-Original Message-
From: Tutor  On Behalf Of
Treyton Hendrix
Sent: Tuesday, November 27, 2018 7:30 PM
To: tutor@python.org
Subject: [Tutor] I need help with my project

If the user selected a sandwich, french fries, and a beverage, reduce the
total cost of the order by $1.00.

This is what I have to do and I don't know where to start.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] I need help with my project

2018-11-28 Thread Alan Gauld via Tutor
On 28/11/2018 00:30, Treyton Hendrix wrote:
> If the user selected a sandwich, french fries, and a beverage, reduce the
> total cost of the order by $1.00.
> 
> This is what I have to do and I don't know where to start.

Neither do we because we don't know what you are talking about.
There is no context.

How does a user select these items? Is it a web page? a GUI? A CLI?
An in-store sensor that detects items being removed from the fridge?
(Maybe under the control of a Raspbery Pi or Arduino?)

And how do you know the original prices? Are they hard coded?
read from a data file or database? Input by the user? Or maybe the
fridge sensor reads bar codes attached to the actual items?

How do you calculate the total? Is it stored in a variable?
Is it stored as a floating point value (you should never do
that for money!) or as an integer number of pennies/cents?

If the latter

total -= 100

Is the obvious answer to your question.

Is it even in code or do you just write it down on paper?
Or maybe you are using an electronic calculator?

I could go on but hopefully you see how little information
you have given us to work from.?

If it is in code show us what you hae so far and we can
help you add this feature. Without any clue what you are
doing we can't really help very much.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] I need help with my project

2018-11-28 Thread Bob Gailer
On Nov 28, 2018 3:43 AM, "Treyton Hendrix" <2hendri...@stu.bps-ok.org>
wrote:
>
> If the user selected a sandwich, french fries, and a beverage, reduce the
> total cost of the order by $1.00.
>
> This is what I have to do and I don't know where to start.

You start by learning how to ask effective questions. Example:

I am taking python 101 at Fubar University. I have been given the following
assignment:

Here you tell us the entire assignment not just one sentence from it.

Then you show us whatever attempt you have made to solve the problem. Have
you written any Python program? Show us the program. Tell us where you are
stuck.

We really like to help but we do not have any crystal balls to look into.
Help us understand your situation fully.

Bob Gailer
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] I need help with my project

2018-11-28 Thread Sibylle Koczian

Am 28.11.2018 um 01:30 schrieb Treyton Hendrix:

If the user selected a sandwich, french fries, and a beverage, reduce the
total cost of the order by $1.00.

This is what I have to do and I don't know where to start.


Well, you are lucky. I just had my first mind-reading lesson today, you 
are my first victim and I'll tell you what you didn't say about your 
problem:


You know prices for sandwiches (one sort or more, with different 
prices?), french fries and beverages. If the user selects one or two of 
them, he pays the sum of the prices. If he selects one of each, he pays 
the sum minus $1.00.


How would you do this by hand?

If my mind-reading isn't yet perfect, please fill the gaps.


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor