Posts for Ariessa Norramli

Programmer | Writer | bitsized dot me at gmail dot com

How to Get Content Of A Class in Python

In this article, you will learn how to get the content of a class in Python. Let’s say you have a class named Dog with attributes breed and origin. In order to the content of a class, you can use the dir() method. Note: The dir() method functions by returning all properties, methods, and built-in […]

February 24, 2021 in Code examples

How to Reverse A List in Python

In this article, you will learn how to reverse a list in python in Python. Let’s say you have a list named ‘a’ with value [1, 2, 3, 4, 5]. In order to reverse a list, you can use the list.reverse() method. Note: The list.reverse() method functions by reversing the elements in a list.

February 24, 2021 in Code examples

How to Square A Number in Python

In this article, you will learn how to square a number in Python. Let’s say you have an integer named ‘a’ with value 22. In order to calculate the square of a number, you can use the pow() method. Note: The pow() method functions by raising the first argument to the power of the second […]

February 23, 2021 in Code examples

How to Calculate Mean of List in Python

In this article, you will learn how to calculate the mean of a list in Python. Let’s say you have a list named ‘a’ with value [1, 2, 3, 4, 5]. In order to calculate the mean of a list, you can use the statistics.mean() method. Note: The statistics.mean() method functions by returning the mean […]

February 23, 2021 in Code examples

How to Round Off Numbers in Python

In this article, you will learn how to round off numbers in Python. Let’s say you have a float variable with value 123.45 In order to round off numbers, you can use the math.ceil() method or math.floor() method. In this example, you will be rounding up and down the float variable ‘a’. Note: The math.ceil() […]

February 22, 2021 in Code examples