On 31 August 2011 21:14, Cranky Frankie <cranky.fran...@gmail.com> wrote:
> I made some headway on the quote of the day program. I just tried to
> do it simple using two assumptions:
>
> - long quotes are going to print funny until I figure out the string
> splitting stuff

Define funny? Normally the linux console will wrap everything up
nicely for you. On a desktop (Gnome/Kde) there are other ways to
display notify texts.

> - hard coding the quotes and authors in the program is simple, and I
> can use a spreadsheet to generate the strings when I put in the rest
> of the quotes (I have a lot of them).

Think about how to store and retrieve these quotes. You could read
from a file and pick a random quotes.

> This code works. Now I just have to figure out:
>
> - how to get Ubuntu to run it at startup

Highly dependant on how and where you login.

> - how to associate .py files in Ubuntu to IDLE

This depends on a couple of factors and not really about learning
python. The Ubuntu forums and wiki are the best place to start.

> Pyhton is fun!

Lets make it more fun :-). Consider the below example (also on [1])
which introduces a different approach to printing quotes. Do not
hesitate to ask questions as I added tuple unpacking and string
formatting which you might not have covered in depth yet in your
tutorial.

import random

quotes = (
    ("Kahlil Gibran", "A candle loses nothing of its light when
lighting another."),
    ("Henrik Ibsen", "The strongest man in the world is he who stands
most alone."),
    ("Dwight Eisenhower", "Leadership consists of nothing but taking
responsibility for everything that goes wrong and giving your
subordinates credit for everything that goes well."),
    ("Will Rogers", "Even if you're on the right track, you'll get run
over if you just sit there."),
    ("Will Rogers", "I belong to no organized party. I am a Democrat."),
    ("Jean de LaFontaine", "Patience and time do more than strength or
passion."),
    ("Eleanor Hibbert", "Never regret. If it's good, it's wonderful.
If it's bad, it's experience."),
    ("Baruch Spinoza", "I have made a ceaseless effort not to
ridicule, not to bewail, not to scorn human actions, but to understand
them."),
    ("Albert Camus", "In the depth of winter I finally learned there
was in me an invincible summer."),
    ("Thomas a Kempi", "Who has a harder fight than he who is striving
to overcome himself."))

author, quote = random.choice(quotes)
print "%s\n\tBy %s" % (quote, author)

Greets
Sander

[1] http://pastebin.com/bdE2ynaG
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to