Python: 3 Ways to Select Random Elements from a List
This succinct and practical article shows you a couple of different ways to randomly select one or multiple elements from a given list in Python. Without any further…
Working with statistics.fmean() function in Python
In statistics, mean (also known as average) is a central tendency measurement of a set of values. Mean is calculated by adding up all the values in a…
Python: Generate a Random Float between Min and Max (3 ways)
This practical article shows you 3 different ways to generate a random floating point number in a given range between a min value and a max value. All…
Python: Get the Current Date and Time with Timezone
In Python, you can get the current date and time in a particular time zone by using the datetime.now() method (recommended) or the datetime.fromtimestamp() method and specify the…
Ways to Combine Lists in Python
This succinct and practical article walks you through a couple of different ways to combine multiple lists in Python. Each approach will be accompanied by a clear illustrative…
Python: How to Convert Date Strings into Date Objects
In Python, you can convert a date string (a string representing a date) into a date object by using the datetime.strptime() method. Syntax: Where: Examples This example turns…
How to Compare 2 Dates in Python
There might be cases where you have to compare 2 dates to determine which one is earlier and which one is later. In Python, you can compare 2…
How to Check Python versions on Mac
If your macOS version is lower than 12.3, then Python 2 is pre-installed on your computer, and you can see it version by running the command below: Note:…
Python: Generate a Random Integer between Min and Max
To generate a random integer between two given integers, the quickest and most convenient way is to use the randint() function from the random module. The minimum and…
Extract all links from a webpage using Python and Beautiful Soup
This article shows you how to get all links from a webpage using Python 3, the requests module, and the Beautiful Soup 4 module. For the demonstration purpose,…