[Tutor] Creating To Do List Program - Question

Dave Angel davea at davea.name
Mon Sep 30 21:14:39 CEST 2013


On 30/9/2013 09:00, Rafael Knuth wrote:

> Hej Dave,
>
> thank you for your response.
>
>> Your original program had some code that interacted with the user.  So
>> when you went from that to a giant print statement, I, and proably many
>> others, thought you were just kidding.
>
> I noticed that, but I was serious about that. I mean, my giant print
> statement was really ridiculous to say the least but it did what I
> wanted the program to do - adding items to the To Do List and printing
> that list

But it didn't do any such thing.  It just displayed some python code to
the user, without running any of it.

> However, I knew this was my very first iteration and I
> wanted to improve my program by making those incremental baby steps.
>
>> Are you using Python 3.3, under Windows?
>
> Python 3.0 under Windows.

Version 3.0 was probably the buggiest version in a decade.  You really
should upgrade to at least 3.3.2
>
>> So let me ask some questions about your level of understanding.
>
> Sure.
>
>> Do you know what an if statement is?  How about a for or while
>> statement?
>
> Yes, I am familiar with both.
>
>> Can you write code in a function, have it take parameters and return
>> results?  Do you know how to call such a function?
>
> Yes.
>
>> Do you know what a list is?  Can you manipulate it at all?  Can you
>> create it from a literal, using the [] syntax.
>
> Yes.
>
>> Do you know what a file is?  Do you know the difference between text
>> file and binary file?  Can you read a text file into a list?  Can you
>> write a list of strings out to a text file?
>
> I worked with text files yet, I have to admit I haven't worked with
> binary files though - and I don't know yet what they are.  But I will
> figure that out.

I'm not as concerned that you know how to deal with them, as that you're
aware that there are files that are not text, and the rules for
manipulating them will be different. You won't need them for this
program.

>
>> If you understand all these pieces, you're probably ready to try to
>> construct a todo list program.  If not, I second the suggestion to
>> follow a tutorial, till it's covered at least all of these.
>
> Ok, cool.
>
>> (I may have missed quite a few items, but I think all of these are
>> necessary.)
>
> Ok, so I will rewrite that To Do list as you (and the others)
> suggested and I will get back to you in case I have any further
> questons.
>
>> For example, write a function that builds a list of strings by asking
>> the user, a line at a time, till the user enters a blank string.  The
>> function should return the list.
>
> Ok, understood.

You can write such a function, and test it, without writing any other
pieces of the to-do list.  That's why I suggest you start there.  Write
it, test it, and then show it here for comment.

Later, you can use that to take in one-day's worth of to-do items.

>
>> Once you think you have the function written, write a simple top-level
>> program that calls the function and prints the results.  Then have it
>> print the results one line at a time.
>
> I don't understand yet what a top-level program is, but I will figure that out.

Any code written at the left margin is top-level.  Python runs only the
top-level code in your script;  it's up to that code to call the various
functions and/or classes that you may also define.  But many beginners
put everything at top-level, which is very limiting.

>
> Again, thank you all.
> I have a fairly good understanding of how I should proceed now.
>
> Rafael
> _______________________________________________

-- 
DaveA




More information about the Tutor mailing list