Featured Post

PowerCurve for Beginners: A Comprehensive Guide

Image
PowerCurve is a complete suite of decision-making solutions that help businesses make efficient, data-driven decisions. Whether you're new to PowerCurve or want to understand its core concepts, this guide will introduce you to chief features, applications, and benefits. What is PowerCurve? PowerCurve is a decision management software developed by Experian that allows organizations to automate and optimize decision-making processes. It leverages data analytics, machine learning, and business rules to provide actionable insights for risk assessment, customer management, fraud detection, and more. Key Features of PowerCurve Data Integration – PowerCurve integrates with multiple data sources, including internal databases, third-party data providers, and cloud-based platforms. Automated Decisioning – The platform automates decision-making processes based on predefined rules and predictive models. Machine Learning & AI – PowerCurve utilizes advanced analytics and AI-driven models ...

Python 'getsizeof' Command the Real Purpose

Here's a sample python program to get the size of a List array.  Getting the number of elements present in a List is not easy. So how to get this? To do you need the 'getsizeof' command.

Import 'sys' Library.

You need to import the 'sys' library to use the SIZE commands. 

>>> import sys

Congrats to you since you have now imported the SYS library. The command name is "getsizeof".

Check the below example.

print("An Integer:")
i = int(100)
print(sys.getsizeof(i))

The result will be: 100

What is the size command?  - is to get the size of elements. It gives the result based on the object you are being used. Suppose, if you use Strings, you will get String length.

Python Command to get the Size of an Object


How to use the 'getsizeof' command?

Example:1

print("Empty string:")
empty_string = ""
print(sys.getsizeof(empty_string))

Example:2

print("A normal string")
s = "Hello world"
print(sys.getsizeof(s))

Example:3

print("Increasing string:")
for i in range(0,5):
empty_string = empty_string + chr(i)
print(sys.getsizeof(empty_string))

Sources

Comments

Popular posts from this blog

SQL Query: 3 Methods for Calculating Cumulative SUM

5 SQL Queries That Popularly Used in Data Analysis

Big Data: Top Cloud Computing Interview Questions (1 of 4)