Python Tutorials

Python tutorials for Business Analyst – Python sleep()

(Python Tutorial – 050) Python sleep() The sleep() function suspends (waits) execution of the current thread for a given number of seconds. Python has a module named time which provides several useful functions to handle time-related tasks. One of the popular functions among them is sleep(). The sleep() function suspends execution of the current thread for a given number …

Python tutorials for Business Analyst – Python time Module

(Python Tutorial – 049) Python time Module In this article, we will explore time module in detail. We will learn to use different time-related functions defined in the time module with the help of examples. Python has a module named time to handle time-related tasks. To use functions defined in the module, we need to import …

Python tutorials for Business Analyst – Python timestamp to datetime and vice-versa

(Python Tutorial – 048) Python timestamp to datetime and vice-versa In this article, you will learn to convert timestamp to datetime object and datetime object to timestamp (with the help of examples). It’s pretty common to store date and time as a timestamp in a database. A Unix timestamp is the number of seconds between …

Python tutorials for Business Analyst – Python Get Current time

(Python Tutorial – 047) Python Get Current time In this article, you will learn to get current time of your locale as well as different time zones in Python. There are a number of ways you can take to get current time in Python.   Example 1: Current time using datetime object from datetime import …

Python tutorials for Business Analyst – How to get current date and time in Python?

(Python Tutorial – 046) How to get current date and time in Python? In this article, you will learn to get today’s date and current date and time in Python. We will also format the date and time in different formats using strftime() method. There are a number of ways you can take to get …

Python tutorials for Business Analyst – Python strptime()

(Python Tutorial – 045) Python strptime() In this article, you will learn to create a datetime object from a string (with the help of examples). The strptime() method creates a datetime object from the given string. Note: You cannot create datetime object from every string. The string needs to be in a certain format.   Example 1: string to datetime object from …

Python tutorials for Business Analyst – Python strftime()

(Python Tutorial – 044) Python strftime() In this article, you will learn to convert date, time and datetime objects to its equivalent string (with the help of examples) The strftime() method returns a string representing date and time using date, time or datetime object.   Example 1: datetime to string using strftime() The program below converts a datetime object containing current date and …

Python tutorials for Business Analyst – Python datetime

(Python Tutorial – 043) Python datetime In this article, you will learn to manipulate date and time in Python with the help of examples. Python has a module named datetime to work with dates and times. Let’s create a few simple programs related to date and time before we dig deeper.   Example 1: Get Current Date …

Python tutorials for Business Analyst – Python RegEx

(Python Tutorial – 042) Python RegEx In this tutorial, you will learn about regular expressions (RegEx), and use Python’s re module to work with RegEx (with the help of examples). A Regular Expression (RegEx) is a sequence of characters that defines a search pattern. For example, ^a…s$ The above code defines a RegEx pattern. The pattern is: any …

Python tutorials for Business Analyst – Python Decorators

(Python Tutorial – 041) Python Decorators A decorator takes in a function, adds some functionality and returns it. In this tutorial, you will learn how you can create a decorator and why you should use it. Decorators in Python Python has an interesting feature called decorators to add functionality to an existing code. This is also called meta …