Software Design principals and patterns. (Design Patterns)
1. https://bytebytego.com/
Tuesday, December 2, 2025
Tuesday, November 25, 2025
Python library for all standard data structures.
# Help on package pygorithm.data_structures
help(data_structures)
Output:NAME
pygorithm.data_structures - Collection of data structure examples
PACKAGE CONTENTS
graph
heap
linked_list
quadtree
queue
stack
tree
trie#Example 1:# import the required data structure
from pygorithm.data_structures import stack
# create a stack with default stack size 10
myStack = stack.Stack()
# push elements into the stack
myStack.push(2)
myStack.push(5)
myStack.push(9)
myStack.push(10)
# print the contents of stack
print(myStack)
# pop elements from stack
myStack.pop()
print(myStack)
# peek element in stack
print(myStack.peek())
# size of stack
print(myStack.size())Output:2 5 9 10
2 5 9
9
3
#Example 2:# to get code for BinarySearchTreeBStree = tree.BinarySearchTree.get_code()
print(BStree)
Output:class BinarySearchTree(object):
def __init__(self):
self.root = None
def insert(self, data):
"""
inserts a node in the tree
"""
if self.root:
return self.root.insert(data)
else:
self.root = BSTNode(data)
return True
def delete(self, data):
"""
deletes the node with the specified data from the tree
"""
if self.root is not None:
return self.root.delete(data)
def find(self, data):
if self.root:
return self.root.find(data)
else:
return False
def preorder(self):
"""
finding the preorder of the tree
"""
if self.root is not None:
return self.root.preorder(self.root)
def inorder(self):
"""
finding the inorder of the tree
"""
if self.root is not None:
return self.root.inorder(self.root)
def postorder(self):
"""
finding the postorder of the tree
"""
if self.root is not None:
return self.root.postorder(self.root)
@staticmethod
def get_code():
"""
returns the code of the current class
"""
return inspect.getsource(BinarySearchTree)Example 3:To get complexities for the following scripts:# create a stack with default stack size 10
Bsort = sorting.bubble_sort.time_complexities()
Output:Best Case: O(n), Average Case: O(n ^ 2), Worst Case: O(n ^ 2).
For Improved Bubble Sort:
Best Case: O(n); Average Case: O(n * (n - 1) / 4); Worst Case: O(n ^ 2)
Source code of this package: https://github.com/OmkarPathak/pygorithmWednesday, November 19, 2025
Integer caching in python
Python (specifically the default CPython implementation) uses integer caching to optimize performance and memory usage by pre-allocating a range of commonly used small integer objects.
How Integer Caching Works
- Cached Range: CPython pre-loads all integer objects in the range of -5 to 256 during interpreter startup.
- Singleton Instances: When you assign a variable an integer value within this range, Python simply returns a reference to the existing, pre-allocated object rather than creating a new one. This makes each integer in this range a singleton.
- Memory and Performance: This optimization saves significant memory and computation time because small integers are used very frequently (e.g., as loop counters or list indices).
- Immutability: Integer caching is safe because integers are immutable data types. Sharing the same object across multiple variables does not cause issues, as any operation that appears to modify an integer actually creates a new integer object.
- Within the Cached Range:
- >>> a = 100
- >>> b = 100
- >>> a is b
- True
- >>> id(a) == id(b)
- True
- and point to the same memory location because 100 is within the range.
- Outside the Cached Range (in the Python REPL):
- >>> x = 257
- >>> y = 257
- >>> x is y
- False
- >>> id(x) == id(y)
- False
- and are different objects with different memory locations because 257 is outside the cached range.
- When running a whole script, the Python compiler can optimize and reuse identical integer literals even outside the standard range, making return for .
- In the REPL, code is compiled line-by-line, limiting this optimization and making the distinct object creation more apparent.
Tuesday, November 18, 2025
What apparatus is used to measure the electrostatic force between two objects
A torsion balance is the apparatus used to measure the electrostatic force between two objects. This device, famously used by Charles-Augustin de Coulomb, uses a suspended rod with a charged ball and measures the force by the twist of a fiber, which is proportional to the torque created by the electrostatic repulsion or attraction.
- Torsion Balance: This is a sensitive instrument consisting of a rod suspended from its center by a thin fiber.
- How it works: A charged object is placed near a second charged ball on the rod. The resulting electrostatic force causes the rod to twist the fiber through a specific angle. By measuring this angle and knowing the properties of the fiber, the force can be calculated. [1, 4, 5]
What apparatus is used to measure the gravitational force between two objects?
The primary apparatus for measuring the gravitational force between two objects is a torsion balance, famously used in the Cavendish experiment. For measuring the gravitational force of a planet, a gravimeter is used, which can be based on a spring or a free-fall method. [1, 2, 3, 4, 5]
- Principle: This device measures the extremely small twist in a wire caused by the gravitational pull between two large, known masses and two smaller masses suspended at the ends of a rod.
- Function: By measuring the angle of the twist (often using a mirror and laser pointer), the force can be calculated. This was the first method to accurately measure the gravitational constant, . [4, 5, 6, 7, 8]
- Principle: A gravimeter is used to measure the Earth's gravitational field, which is a measure of gravitational acceleration (). It works on the principle that gravitational force is a type of acceleration.
- Function: It measures the gravitational force exerted by the Earth on an object.
Saturday, June 21, 2025
Basic Flask web app
from flask import Flask
app = Flask(__name__)
#In Flask, URL rules can be added using either the @app.route() decorator or the app.add_url_rule() method.
@app.route('/')
def hello_world():
return '<center><h1><I>Hello World</I></h1></center>'
def bye_world():
return '<center><h1><I>Bye World</I></h1></center>'
app.add_url_rule('/bye', 'bye', bye_world)
if __name__ == "__main__":
app.run(debug = True)
Thursday, May 1, 2025
Query for finding high dividend paying stocks
Post the following query in Screen.in, to get list of high dividend yield stocks:
Dividend yield > 6
AND
Dividend last year > 1000
AND
Dividend preceding year > 1000
AND
Profit after tax > 0
_________________________________________________________________________
you can further add few more filters to know which ones are low priced now
AND
Price to Earning < Industry PE
AND
%Down from 52w high > 20
Tuesday, April 1, 2025
Python Certification
Python course from codebasics https://codebasics.io/courses/python-beginner-to-advanced?utm_source=infocard&utm_medium=yt&utm_campaign=infocard&utm_id=youtube
Also see this YT tutorial on Python https://www.youtube.com/watch?v=eykoKxsYtow&list=PLeo1K3hjS3uv5U-Lmlnucd7gqF-3ehIh0
Thursday, March 27, 2025
Python script to show Laptop Battery Percentage
Source: https://www.geeksforgeeks.org/python-script-to-show-laptop-battery-percentage/
# python script showing battery details
import psutil
# function returning time in hh:mm:ss
def convertTime(seconds):
minutes, seconds = divmod(seconds, 60)
hours, minutes = divmod(minutes, 60)
return "%d:%02d:%02d" % (hours, minutes, seconds)
# returns a tuple
battery = psutil.sensors_battery()
print("Battery percentage : ", battery.percent)
print("Power plugged in : ", battery.power_plugged)
# converting seconds to hh:mm:ss
print("Battery left : ", convertTime(battery.secsleft))
Battery Notifier : A Python program
Source:
(i) www.geeksforgeeks.org/create-battery-notifier-for-laptop-using-python
(ii) stackoverflow.com - question - doing-something-before-program-exit.
NOTE: First enable 'Notifications' in your Windows PC. (Click on the Clock icon, at the right corner in the status bar and turn off the 'Do not disturb' button. Web link: plyer-notifications-are-not-visible
#Save this Python program as 'BatteryNotifier.py' in your 'Users' folder, and run this program in DOS #prompt, and keep the DOS window open as long as you are working on your PC.
# Install and Import the 'psutil' module, for accessing info on running processes and system utilization.
# Install and Import the 'plyer' module, for accessing features of the Hardware, like displaying Notifications on the Desktop.
------------------------------------------------------------------------------------------------------------
import psutil
from plyer import notification
import time
import sys
import atexit
import signal
#To handle killing the process with kill or Ctrl+C.
def kill_handler(*args):
print("BatteryNotifier is turned OFF")
sys.exit(0)
signal.signal(signal.SIGINT, kill_handler)
signal.signal(signal.SIGTERM, kill_handler)
print("Battery Notifier is ON!!")
#from psutil we use the sensors_battery.
while(True):
battery = psutil.sensors_battery()
percent = battery.percent
if percent < 70:
notification.notify(title="Recharge battery!! ", message=str(percent)+"% Battery remaining", timeout=30)
time.sleep(35)
if battery.power_plugged:
print("Power is plugged IN")
else:
notification.notify(message = "Power is plugged OUT", timeout=30)
if percent > 97:
notification.notify(title="Battery Full!! ", message=str(percent)+"% Battery remaining", timeout=30)
#after every 5 mins this loop will iterate & show the respective notifications as long as anyone of the battery conditions is met.
time.sleep(60*5)
continue
------------------------------------------------------------------------------------------------------------------
Output:
Console output at beginning of the program:
Sunday, March 23, 2025
Trending Sectors
- Auto & Aviation - Tata Motors, M&M, Hero, TVS, Bajaj Auto, Inter globe aviation.
- Banking, Finance, Broking & Insurance - Axis bk, ICICI bk, HDFC bk, SBI, AU small bk, M&M Finance, BSE, MCX, CDSL, Dixon.
- Computer (IT & Software) - Infy, TCS, Wipro, Persistent.
- Metals - Vedanta, Hindalco, Tata Steel.
- Pharma - Sun, Lupin, Aurobindo, Glenmark, Divi's labs
- FMCG - TCP, GCP, Britannia, Colgate, HUL, ITC.
- PSU - NTPC, CIL, ONGC, HAl, BEL, BHEL, REC, PFC.
- CG - ABB, Siemens, Cummins, Polycab, Havells, Voltas.
- MISC - Indian Hotels, Trent, Bharti Airtel, LIC, RIL.
Thursday, February 13, 2025
Derivatives stock list at NSE
- ABB India Ltd
- ACC Ltd
- APL Apollo Tubes Ltd
- AU Small Finance Bank Ltd
- Aarti Industries Ltd
- Abbott India Ltd
- Adani Energy Solutions Ltd
- Adani Enterprises Ltd
- Adani Green Energy Ltd
- Adani Ports & Special Economic Zone Ltd
- Adani Total Gas Ltd
- Aditya Birla Capital Ltd
- Aditya Birla Fashion & Retail Ltd
- Alkem Laboratories Ltd
- Ambuja Cements Ltd
- Angel One Ltd
- Apollo Hospitals Enterprise Ltd
- Apollo Tyres Ltd
- Ashok Leyland Ltd
- Asian Paints Ltd
- Astral Ltd
- Atul Ltd
- Aurobindo Pharma Ltd
- Avenue Supermarts Ltd
- Axis Bank Ltd
- BSE Ltd
- Bajaj Auto Ltd
- Bajaj Finance Ltd
- Bajaj Finserv Ltd
- Balkrishna Industries Ltd
- Bandhan Bank Ltd
- Bank of Baroda
- Bank of India
- Bata India Ltd
- Berger Paints India Ltd
- Bharat Electronics Ltd
- Bharat Forge Ltd
- Bharat Heavy Electricals Ltd
- Bharat Petroleum Corporation Ltd
- Bharti Airtel Ltd
- Biocon Ltd
- Birlasoft Ltd
- Bosch Ltd
- Britannia Industries Ltd
- CESC Ltd
- CG Power & Industrial Solutions Ltd
- Can Fin Homes Ltd
- Canara Bank
- Central Depository Services (India) Ltd
- Chambal Fertilisers & Chemicals Ltd
- Cholamandalam Investment & Finance Company Ltd
- Cipla Ltd
- City Union Bank Ltd
- Coal India Ltd
- Coforge Ltd
- Colgate-Palmolive (India) Ltd
- Computer Age Management Services Ltd
- Container Corporation Of India Ltd
- Coromandel International Ltd
- Crompton Greaves Consumer Electricals Ltd
- Cummins India Ltd
- Cyient Ltd
- DLF Ltd
- Dabur India Ltd
- Dalmia Bharat Ltd
- Deepak Nitrite Ltd
- Delhivery Ltd
- Divis Laboratories Ltd
- Dixon Technologies (India) Ltd
- Dr Lal Pathlabs Ltd
- Dr Reddys Laboratories Ltd
- Eicher Motors Ltd
- Escorts Kubota Ltd
- Exide Industries Ltd
- FSN E-Commerce Ventures Ltd
- Federal Bank Ltd
- GAIL (India) Ltd
- GMR Airports Ltd
- Glenmark Pharmaceuticals Ltd
- Godrej Consumer Products Ltd
- Godrej Properties Ltd
- Granules India Ltd
- Grasim Industries Ltd
- Gujarat Gas Ltd
- Gujarat Narmada Valley Fertilizers & Chemicals Ltd
- HCL Technologies Ltd
- HDFC Asset Management Company Ltd
- HDFC Bank Ltd
- HDFC Life Insurance Company Ltd
- HFCL Ltd
- Havells India Ltd
- Hero MotoCorp Ltd
- Hindalco Industries Ltd
- Hindustan Aeronautics Ltd
- Hindustan Copper Ltd
- Hindustan Petroleum Corporation Ltd
- Hindustan Unilever Ltd
- Housing & Urban Development Corporation Ltd
- ICICI Bank Ltd
- ICICI Lombard General Insurance Company Ltd
- ICICI Prudential Life Insurance Company Ltd
- IDFC First Bank Ltd
- IRB Infrastructure Developers Ltd
- ITC Ltd
- Indiamart Intermesh Ltd
- Indian Bank
- Indian Energy Exchange Ltd
- Indian Hotels Co Ltd
- Indian Oil Corporation Ltd
- Indian Railway Catering & Tourism Corporation Ltd
- Indian Railway Finance Corporation Ltd
- Indraprastha Gas Ltd
- Indus Towers Ltd
- IndusInd Bank Ltd
- Info Edge (India) Ltd
- Infosys Ltd
- Interglobe Aviation Ltd
- Ipca Laboratories Ltd
- J K Cements Ltd
- JSW Energy Ltd
- JSW Steel Ltd
- Jindal Stainless Ltd
- Jindal Steel & Power Ltd
- Jio Financial Services Ltd
- Jubilant Foodworks Ltd
- KEI Industries Ltd
- KPIT Technologies Ltd
- Kalyan Jewellers India Ltd
- Kotak Mahindra Bank Ltd
- L&T Finance Ltd
- L&T Technology Services Ltd
- LIC Housing Finance Ltd
- LTIMindtree Ltd
- Larsen & Toubro Ltd
- Laurus Labs Ltd
- Life Insurance Corporation of India
- Lupin Ltd
- MRF Ltd
- Macrotech Developers Ltd
- Mahanagar Gas Ltd
- Mahindra & Mahindra Financial Services Ltd
- Mahindra & Mahindra Ltd
- Manappuram Finance Ltd
- Marico Ltd
- Maruti Suzuki India Ltd
- Max Financial Services Ltd
- Max Healthcare Institute Ltd
- Metropolis Healthcare Ltd
- Mphasis Ltd
- Multi Commodity Exchange of India Ltd
- Muthoot Finance Ltd
- NBCC (India) Ltd
- NCC Ltd
- NHPC Ltd
- NMDC Ltd
- NTPC Ltd
- National Aluminium Company Ltd
- Navin Fluorine International Ltd
- Nestle India Ltd
- Oberoi Realty Ltd
- Oil & Natural Gas Corpn Ltd
- Oil India Ltd
- One 97 Communications Ltd
- Oracle Financial Services Software Ltd
- P I Industries Ltd
- PB Fintech Ltd
- PVR Inox Ltd
- Page Industries Ltd
- Persistent Systems Ltd
- Petronet LNG Ltd
- Phoenix Mills Ltd
- Pidilite Industries Ltd
- Piramal Enterprises Ltd
- Polycab India Ltd
- Poonawalla Fincorp Ltd
- Power Finance Corporation Ltd
- Power Grid Corporation of India Ltd
- Prestige Estates Projects Ltd
- Punjab National Bank
- RBL Bank Ltd
- REC Ltd
- Reliance Industries Ltd
- SBI Cards & Payment Services Ltd
- SBI Life Insurance Company Ltd
- SJVN Ltd
- SRF Ltd
- Samvardhana Motherson International Ltd
- Shree Cement Ltd
- Shriram Finance Ltd
- Siemens Ltd
- Solar Industries India Ltd
- Sona BLW Precision Forgings Ltd
- State Bank of India
- Steel Authority of India Ltd
- Sun Pharmaceuticals Industries Ltd
- Sun TV Network Ltd
- Supreme Industries Ltd
- Syngene International Ltd
- TVS Motor Company Ltd
- Tata Chemicals Ltd
- Tata Communications Ltd
- Tata Consultancy Services Ltd
- Tata Consumer Products Ltd
- Tata Elxsi Ltd
- Tata Motors Ltd
- Tata Power Company Ltd
- Tata Steel Ltd
- Tech Mahindra Ltd
- The Ramco Cements Ltd
- Titan Company Ltd
- Torrent Pharmaceuticals Ltd
- Torrent Power Ltd
- Trent Ltd
- Tube Investments of India Ltd
- UPL Ltd
- UltraTech Cement Ltd
- Union Bank of India
- United Breweries Ltd
- United Spirits Ltd
- Varun Beverages Ltd
- Vedanta Ltd
- Vodafone Idea Ltd
- Voltas Ltd
- Wipro Ltd
- Yes Bank Ltd
- Zomato Ltd
- Zydus Lifesciences Ltd
Monday, February 10, 2025
Saturday, January 18, 2025
Friday, January 10, 2025
What is a data structures
Data structure is a tool in the hands of a programmer for storing a large number of data items in the main memory (RAM) of a computer which can be reference by a single name, to enable their efficient storing, access and modification during program execution.
It can also be understood as a specialized format (layout) for storing, processing and retrieving data.
Resources for preparing for SDE2/SDE3 roles
Software Design principals and patterns. (Design Patterns) 1. https://bytebytego.com/ 2. https://refactoring.guru/
-
//The HTML index page <!DOCTYPE html> <!-- To change this license header, choose License Headers in Project Properties. To change ...
-
Acronym Full Form AJAX Asynchronous JavaScript and XML API Application Programming Interface APK Android Application Package ASP Activ...
-
Here are some links to online work sites https://www.upwork.com/ https://www.guru.com/ https://studio.envato.com/freelance-switch/ htt...


