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
#!/usr/bin/python
# https://www.codecademy.com/en/courses/python-beginner-en-4CQvah/0/1?curriculum_id=4f89dab3d788890003000096
import datetime
Today = datetime.datetime.now()
print(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 = datetime.date.today().year #current year in my case is 2018 so I'll type in "year = 2018"
print(year)
Write a public review