In this post, we’ll explore Numeric Data Types in Python, which are fundamental to any program that involves calculations, counting, or number manipulation. Specifically, we’ll cover integers, floating-point numbers, and briefly mention complex numbers. Let’s dive in. Python’s Three Primary Numeric Data Types Python provides three core numeric types: Integers (int) Floating-point numbers (float)...
LeetCode #2 solution: Adding two numbers
Problem: #2 adding two numbers LeetCode #2 solution – Adding Two Numbers: You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list. You may assume the two numbers do not contain any leading zero, except...
LeetCode #1 solution: Two Sum
Problem: 1 two sum Leetcode #1 solution – Two Sum: Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order. Examples: Input: nums = [2...
Objects in Python: A comprehensive introduction
In this comprehensive guide, I’ll introduce you to objects in Python. This is an essential concept because, in Python, everything is an object. What are Objects in python? An object in Python is like a package that holds both data and functionality. It contains: Data: Numbers, text, lists, or any other type of value. Methods: Functions that belong to the object, allowing you to interact...
Python Data Types: A Comprehensive Guide for beginners
Data types are one of the fundamental concepts in programming. In Python, understanding data types is crucial for writing effective and efficient code. This guide will delve into what data types are, why they are important, and how Python’s dynamic typing system works. What Are Python Data Types? At its core, a data type defines the kind of value a variable can hold. It tells Python—and...
Python Operators: an introduction
Operators are one of the foundational concepts in any programming language, and Python is no different. They allow you to perform operations on variables and values, whether it’s basic math, comparing numbers, or performing complex bitwise manipulations. In this post, we’ll explore the different types of Python operators and understand their usage. We’ll cover unary, binary, and ternary...