Welcome to the Blog!
Solving Problem: Leap Year
(If-elif-else Control Flow) Problem Statement Check if a year is a leap year. As per the Gregorian calendar (in 1582), the following rule is used to determine the kind of year: The task is to determine if the given year is a leap year or not. Output messages: “Leap year.” if the year is a…
Solving Problem: Symmetric Difference
(Sets) Problem Statement: Given 2 sets of integers M and N, print their symmetric difference in ascending order. The term symmetric difference indicates those values that exist in either but do not exist in both. Solution: Output: Reference: https://www.hackerrank.com/challenges/symmetric-difference/problem
Solving Problem: Trigonometry
(Python) Problem Statement: ABC is a right triangle, 90° at B.Therefore, ∠ ABC = 90. Point M is the midpoint of the hypotenuse. You are given the lengths AB and BC.Your task is to find ∠MBC (angle θ, as shown in the figure) in degrees. Input Format The first line contains the length of side AB.The second line contains the length of…
Solving Problem: Tax Calculator
(If-elif control flow) Problem Statement: Once upon a time, there was a country inhabited by happy and prosperous people. The people paid taxes, of course – their happiness had limits. The most important tax, called the Personal Income Tax (PIT ), had to be paid yearly and was evaluated using the following rule: Your task is to write…
Solving Problem: Two Sum
(Python) Problem Statement: 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. Example 1: Input: nums = [2,7,11,15], target = 9 Output:…
Bit Manipulation Basics
(Python) Let’s have a quick review of Bit Manipulation techniques in Python. Bitwise Operators Operator Description Example & Bitwise AND a & b ` Bitwise OR a ` b ^ Bitwise XOR a ^ b ~ Bitwise NOT ~a << Left Shift a << n >> Right Shift a >> n Example Program Output: a…
Types of AI
Artificial Intelligence (AI) is a trending technology around the world. Let’s understand its types. What is AI? Artificial Intelligence (AI) is the capability of a computational system to pursue human intelligence, like learning, reasoning, perception, problem solving, and decision making. Types of AI Types of AI based on capabilities: Narrow AI (Weak AI): Narrow AI…
Object Oriented Programming – Polymorphism
What is Polymorphism? Polymorphism means “many forms”.In OOP, it allows the same method name (or operator) to behave differently depending on the object or data type it is acting upon. It helps in: Types of Polymorphism in Python Python mainly supports runtime polymorphism (method overriding) and compile-time-like polymorphism (method overloading via default arguments or *args). 1. Polymorphism with Functions and Objects A single function…
Object Oriented Programming – Inheritance
What is Inheritance? Inheritance is a fundamental concept in object-oriented programming (OOP) that allows a class to inherit attributes and methods from another class. This promotes code reusability and establishes a hierarchical relationship between classes. Basic Syntax and Example In Python, inheritance is implemented by defining a new class that derives from an existing class.…
Object Oriented Programming – Abstraction
What is Abstraction? Abstraction is a fundamental concept in Object-Oriented Programming (OOP) that focuses on hiding the internal implementation details of a class or method while exposing only the necessary functionality. This simplifies code interaction, reduces complexity, and enhances maintainability. In Python, abstraction is achieved using abstract classes and abstract methods, which are defined in the abc module. Abstract Classes and Methods…
Something went wrong. Please refresh the page and/or try again.
Follow My Blog
Get new content delivered directly to your inbox.
