Creating a date object / displaying current date

Creating a date object / displaying current date

Lesson Details:
June 29, 2020

I: Introduction

A: Learn basic python programming for beginners

Python is a high-level, dynamic programming language for general-purpose programming. It is often compared to languages like Perl, Ruby, Scheme or Java.

Python is simple, yet powerful. As an interpreted language, Python programs can be run on different platforms without having to be re-written in another language. The simplicity of the language makes it easy to read and maintain even large programs. Python supports multiple programming paradigms, including object-oriented, imperative and functional programming or procedural styles.

II: Body

A: Creating a date object / displaying current date



import datetime

Today =


Note that the above example imports the datetime library in order to access the datetime module. All you have to do is type in the above lines in your terminal and press enter. You will get the current date displayed in the terminal window. You can replace today with any other date by replacing it with its date object in the above code. For example, if you want the current year's date instead of today's date, you can simply type in the following line in your terminal:

import datetime

year = #current year in my case is 2018 so I'll type in "year = 2018"


Course content