[Tutor] Quote of the Day version 1.0

Cranky Frankie cranky.frankie at gmail.com
Wed Aug 31 21:14:17 CEST 2011


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
- 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).

This code works. Now I just have to figure out:

- how to get Ubuntu to run it at startup
- how to associate .py files in Ubuntu to IDLE

Thanks for all who commented, I really appreciate it. Pyhton is fun!





# Quote_a_day_V1.py
#
# This program displays a random quotation
#
# Frank L. Palmeri August 31, 2011

import random

print("\n\tHere is today's quote of the day:\n")

author = (
    "Kahlil Gibran",
    "Henrik Ibsen",
    "Dwight Eisenhower",
    "Will Rogers",
    "Will Rogers",
    "Jean de LaFontaine",
    "Eleanor Hibbert",
    "Baruch Spinoza",
    "Albert Camus",
    "Thomas a Kempi"
    )

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

numAuthors = len(author)

printAuthor = random.randrange(numAuthors)

print(quotation[printAuthor])

print("by ", author[printAuthor])

input("\nPress the enter key to exit.")




-- 
Frank L. "Cranky Frankie" Palmeri
Risible Riding Raconteur & Writer

" . . . and the extended forecast,
until you come back to me, baby,
is high tonight, low tomorrow,
and precipitation is expected."
- Tom Waits, "Emotional Weather Report"


More information about the Tutor mailing list