Practice exercise 2: Use modules to add functionality to a python script

Activity Summary

Modules are essential to any python developer. They enable you to “drop-in” additional functionality into your Python programs, drawing on a network of skilled module developers. In this training module, we’ll cover how to add additional functionality to a python program by importing the date-time python module.

Video

Activity Steps

Task: Write a Python program to display the current date and time. 

  1. Create a new Python3 trinket
  2. Import the date-time module
  3. Adapt the broken trinket below (line 5 an 11) and print out current data and time by calling a variable that references the date time module. Ensure that all of the features work (hint: review the comments).
  4. Ensure that all of the features work (hint: review the comments).
  5. (Optional) Change the format of data and make it friendly for your users. Let us know in the comments how you have chosen to format the data

Code Example

Resources

These are the ones I use on in my own Python development:

Skip to toolbar