Quote of the Day

quoteOfTheDay

Learning Objectives


By completing this challenge you will learn how data can be stored using lists.

You will store a series of quotes in a list and append new quotes to your list.

You will also find out how to pick up a random value from a list using the random.choice() function.

List?


In Python, a list is used to save a collection of values. For instance, to save all the different days of the week we could declare a variable called “daysOfTheWeek” and assign a list as follows (Notice the use of square brackets):

daysOfTheWeek = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]

Based on this what do you think len(daysOfTheWeek) would return?
What’s about daysOfTheWeek[0]?
Or daysOfTheWeek[3]?

Challenge


In this challenge we decided to create list to store a collection of inspirational quotes.

We then randomly pick a quote from this list to display it to the end-user.

Your Task


Look at this page. Update the code above to give more daily items. For instance you could:

  • Store a list of science based facts and display the “fact of the day”,
  • store a list of French words and display the “French word of the day”,
  • store a list of maths equations (e.g. 45 + 52 = ?) and display the “Maths Challenge of the day”,
  • etc.
unlock-access

Solution...

The solution for this challenge is available to full members!
Find out how to become a member:
➤ Members' Area

Did you like this challenge?

Click on a star to rate it!

Average rating 4.2 / 5. Vote count: 10

No votes so far! Be the first to rate this post.

As you found this challenge interesting...

Follow us on social media!

Tagged with: ,