5. Random & Sleeping & Date/Time

Importing Commands

This section looks at additional commands that you can import and use from Python’s code library. A library is a collection of different coding sequences that automatically come with Python but are separate from the main file. They can be imported (brought in) to your program by using the import command at the start of your program.

Imagine Python’s library to be similar to an actual library. There are different sections in a real library (such as History, Geography, Reference) and different sections in Python’s library (such as random or time). Each real library has many individual books in each section, just like Python. For example in the Sleeping page below we will want to open up Python’s library, go to the section called time and grab just the command called sleep. This is more efficient than just importing the whole time section.

Welcome to Section Five! Click on the links to find out how to import commands to add complexity to your Python programs:



Date & Time

When you have read the pages above and tried the practice task(s) on each page then attempt these:

End of Section Practice Tasks