Posts for Ariessa Norramli

Programmer | Writer | bitsized dot me at gmail dot com

How to Refer to Base Class in Python

In this article, you will learn how to refer to base class in Python. Let’s say you have 2 classes, a base class named Father and a derived class named Son. class Father(object): def __init__(self, fatherGender): print(fatherGender, ‘is a male.’) class Son(Father): def __init__(self): print(‘Son is 20 years old.’) Refer to Base Class in Python […]

February 28, 2021 in Code examples

How to Use SimpleHTTPServer in Python

In this article, you will learn how to use SimpleHTTPServer in Python. SimpleHTTPServer is a built-in Python module that provides standard GET and HEAD requests. Use SimpleHTTPServer in Python In this example, you need to open up a command prompt (CMD) or Terminal and navigate to any directory. Then, type the following command in your […]

February 28, 2021 in Code examples

How to Join Tuples in Python

In this article, you will learn how to join tuples in Python. Let’s say you have 2 tuples. Join Tuples in Python In order to join tuples, you can use the zip() method and tuple() method. Note: The zip() method functions by creating a series of tuples from each element in both supplied iterables. The […]

February 26, 2021 in Code examples

How to Convert Dictionary to JSON in Python

In this article, you will learn how to convert a dictionary to JSON in Python. Let’s say you have a dictionary named ‘a’. Convert Dictionary to JSON in Python In order to convert a dictionary to JSON, you can use the json.dumps() method. Note: The json.dumps() method functions by converting Python objects to JSON string.

February 26, 2021 in Code examples

How to Append List Elements in Python

In this article, you will learn how to append list elements in Python. Let’s say you have 2 lists of food. Append List Elements in Python In order to append list elements, you can use the list.extend() keyword. Note: The list.extend() keyword functions by appending the elements of supplied iterable at the end of list.

February 25, 2021 in Code examples

How to Set Column As Index in Python

In this article, you will learn how to set a column as an index in Python. Let’s say you have a DataFrame of food. Set Column As Index in Python In order to set a column as an index, you can use the DataFrame.set_index() method. Note: The DataFrame.set_index() method functions by setting the supplied column […]

February 25, 2021 in Code examples

How to Create Multidimensional Arrays in Python

In this article, you will learn how to create multidimensional arrays in Python. In this example, you will be creating 1-dimensional, 2-dimensional, and 3-dimensional arrays. Create Multidimensional Arrays in Python In order to create multidimensional arrays, you can use the numpy.random.randn() method. Note: The numpy.random.randn() method functions by creating an array of specified dimensions and […]

February 25, 2021 in Code examples