Python Program to Add Two Numbers

Add Two Integers The most basic Python program to add two integer numbers stored in variables num_1 and num_2 is the expression num_1 + num_2 using the addition operator. The following code shows how to add two numbers 20 and 22 and print the result 42 to the shell: Add Two Integers with User Input … Read more

Python Addition Operator

Python provides the addition operator + to add two objects. The semantics of the addition depends on the operands’ data types. For example, adding two integers perform arithmetic addition whereas adding two lists performs list concatenation. The specific return value of the addition operator is defined in a data types’ __add__() magic method. Have a … Read more

How to Generate a Random String in Python?

Problem Formulation You are tasked with writing Python code to generate a random string.  The string should contain any of the printable characters on your keyboard.  Letters, numbers, and punctuation marks are valid, and we’ll leave out any whitespace characters. What’s the best way to solve this in Python? Method 1: List Comprehension and random.randint() … Read more

K-Nearest Neighbors (KNN) with sklearn in Python

The popular K-Nearest Neighbors (KNN) algorithm is used for regression and classification in many applications such as recommender systems, image classification, and financial data forecasting. It is the basis of many advanced machine learning techniques (e.g., in information retrieval). There is no doubt that understanding KNN is an important building block of your proficient computer … Read more

Python Not Equal To

The Python not equal to (left!=right) operator returns True when its left operand is not equal to its right operand as defined by the __ne__() magic method. Otherwise, it returns False. For example, 3!=2 evaluates to True, but 3!=3 evaluates to False. Examples Let’s explore a couple of examples regarding the not equal to operator. … Read more

Python Equal To

The Python equal to (left==right) operator returns True when its left operand is equal to its right operand. Otherwise, it returns False. For example, 3==3 evaluates to True, but 3==2 evaluates to False. Examples Let’s explore a couple of examples regarding the equal to operator. Is 3 equal to 2? What about ‘h’ equal to … Read more

[Interview Question] Longest Substring Without Repeating Characters

[toc] ?️ Company Tags: As reported by numerous programmers across the globe, this question has been asked in coding interviews/rounds by companies like: Amazon Adobe Bloomberg Yelp So, if you are preparing for your upcoming coding interview, then you might well come across this question in your coding round. Can you solve it optimally? Problem … Read more

Arbitrage Opportunity? Staking ETH 2.0 vs Buying BETH on Binance

πŸ‘‰ Disclaimer: NOT investing advice! What is Staking with ETH 2.0? Ethereum moves from a proof-of-work to a proof-of-stake Blockchain technology with its upcoming launch of ETH 2.0. This means that the network is secured by ETH “stakers” rather than ETH miners or validators. Staking will be the ETH 2.0 equivalent of mining. As a … Read more

An Introduction To Python Classes – Inheritance, Encapsulation, and Polymorphism

This article continues from Introduction to Classes – Part One, where we explained what classes are, their components, and why we use them. We also looked at some unique characteristics of classes that assist us in creating cleaner code. If you haven’t read Part One and are new to classes, I suggest reading that introduction … Read more

Python Less Than or Equal To

The Python less than or equal to (left<=right) operator returns True when its left operand does not exceed the right operand. When the left operand is greater than the right operand, the <= operator returns False. For example, 2<=3 and 2<=2 evaluate to True, but 3<=2 and evaluates to False. Examples Let’s explore a couple … Read more

Bitcoin – Where Are the Women?

A recent Binance Research study shows that approximately 95% of all Bitcoin holders are men. Redistribution of Wealth to Men When reading the Bitcoin whitepaper and the transformation towards a new decentralized, digital monetary system, I realized that we’re in the middle of one of the greatest redistributions of wealth and power in the last … Read more

Python Greater Than or Equal To

The Python greater than or equal to (left>=right) operator returns True when its left operand is not exceeded by its right operand. When the left operand is smaller than the right operand, the >= operator returns False. For example, 3>=2 and 3>=3 evaluate to True, but 2>=3 evaluates to False. Examples Let’s explore a couple … Read more