Programming with Python DateTimes

Lab Steps

Connecting to the Python Web IDE
Exercise 1 - DateTime Fundamentals
Exercise 2 - Find Oldest File
Exercise 3 - Find Youngest President

The hands-on lab is part of this learning path

Introduction to Python

Ready for the real environment experience?

Time Limit1h 30m


Lab Overview

The Python 3 DateTime module supplies classes for manipulating dates and times in both simple and complex ways. While date and time arithmetic are supported, the focus of the implementation is on efficient attribute extraction for output formatting and manipulation.

This Lab is designed to introduce you to coding with date and times in Python, using the DateTime module. You will be required to complete each of the following Python coding exercises:

  • Exercise 1 - DateTime: Complete the code required to work with and manipulate DateTime variables
  • Exercise 2 - OldestFile: Complete the code required to query the local filesystem to discover the oldest residing file
  • Exercise 3 - YoungestPresident: Complete the code required to read presidential data stored in a local text file and then sort it based on age

Note: Each exercise has a provided solution to consult with when needed.

Lab Objectives

Upon completion of this lab, you will be able to:

  • Write a Python script that creates DateTime variables and manipulates date and times
  • Write a Python script that queries the current state of the local filesystem
  • Understand how to read in and parse DateTime information stored within a local text file
  • Understand how to perform SQL inserts involving DateTime information into a locally hosted SQLite database
  • Use the terminal to launch and debug Python scripts

You should:

  • Be comfortable with using a browser-based IDE

Lab Environment

This lab will start with the following AWS resources provisioned automatically for you:

  • A single EC2 instance, named ide.python.platform.instance, which will have a public IP address attached. This instance will host a web-based Python IDE (based on the Visual Code editor).

To achieve the lab end state, you will be walked through the process of:

  • Using your local browser, access the web-based Python IDE served from the ide.python.platform.instance
  • Completing the following lab exercises:
    • Exercise 1 - DateTime
    • Exercise 2 - OldestFile
    • Exercise 3 - YoungestPresident
    • Exercise 4 - SQLite3


June 16th, 2018 - Optimized creation of lab resources to reduce the time it takes to access the browser IDE by 60%.

About the Author

Learning paths22

Jeremy is the DevOps Content Lead at Cloud Academy where he specializes in developing technical training documentation for DevOps.

He has a strong background in software engineering, and has been coding with various languages, frameworks, and systems for the past 20+ years. In recent times, Jeremy has been focused on DevOps, Cloud, Security, and Machine Learning.

Jeremy holds professional certifications for both the AWS and GCP cloud platforms.

Covered Topics