Friday, May 6, 2022

Python program to calculate stop-loss level for a given buy price.

 def findSLTP():

c = int(input("Enter current market price : "))

print("SLTP for " + str(c) + " at 6% loss should be : " + str(int(c - 0.06*c))) 

x = input("Press Enter to exit application ")

findSLTP()

Python program to calculate profit %

 def findProfit():

    x = 'a'

    while x != 'n' or x != 'N':

        c = float(input("Enter current market price : "))

        s = float(input("Enter expected sell price  : "))

        a = float((s - c)/c)*100

        formatted_a = "{:.2f}".format(a)

        print("% Profit for buy at " + str(c) + " and expected sell at " + str(s) + " would be : " + str(formatted_a) +"%") 

        print()   

        #x= input("Want to continue (y/n) :") 

        #if x == 'n':

            #exit()

findProfit()

Tuesday, May 3, 2022

Top 10 trading stocks


  1. Reliance Inds - Sector: Telecom Long-term trend: UP
  2. TCS - Sector: IT Long-term trend: SIDEWAYS
  3. Persistent Systems - IT Long-term trend: UP
  4. HDFC Bank - Banking Long-term trend: SIDEWAYS
  5. ICICI Bank - Banking Long-term trend: UP
  6. Hindalco - Metals Long-term trend: UP
  7. Tata steel - Metals Long-term trend: UP
  8. Hero motors - Auto Long-term trend: DOWN
  9. Godrej Consumer Products - FMCG Long-term trend: DOWN
  10. Tata Consumer Products - FMCG Long-term trend: SIDEWAYS

Up trending stocks are best for trading, followed by sideways consolidating stocks.

Trading in long-term downtrending stocks should be avoided.

Major sectors and their top players


  1. IT - TCS, Infosys, Wipro, Persistent, LTI, LTTS, Mindtree, Happiest minds, Coforge, Mphasis, Mastek, Latent view.
  2. Metals - Hindalco, Nalco, Tata Steel, Jindal Stainless, JSW steel, JSPL.
  3. Cement - ACC, Ultratech, Grasim, Ambuja Cement.
  4. Banks - ICICI bank, HDFC bank, SBI, IndusInd bank, Axis bank.
  5. Auto - Maruti, M&M, Tata Motors, Hero, Bajaj Auto, TVS, Eicher.
  6. FMCG - GCP, TCP, HUL.
  7. Finance - Bajaj Finance, Bajaj Finserve, Bajaj Holdings, CDSL, Au Small Bank Finance, Cholamandulum, Sundarum Finance, Shriram Transport Finance, Shriram City Union Finance, Muthoot Fianance, Mannapurnam Finance, ICICI securities, Motilal Oswal Financial services, M&M Financial, Indiabulls Housing.
  8. Paint - Asian paints, Kansai Nerolac, Berger paints.
  9. Chemical - Tata chemicals, Deepak Nitrite, Navin Flourine, India Glycols, Pidilite, Solar Industries, Aarti Inds, Alylamines, Balaji amines, SRF.
  10. E-commerce - Info edge, Paytm, PB Fintech, CE infoetch, Nykaa, Zomato.
  11. Power - Generation: NTPC, Reliance Infra, Tata power, Torrent power, JSW Energy, Adani power, Adani Green, Suzlon Energy. Transmission: Adani Transmission, Power Grid, Kalptaru power, KEC International, GE power.
  12. Petroleum - Refineries: BPCL, HPCL, Chennai Petroleum, MRPL, IOC. Oil driling: - ONGC, OIL, GAIL (These two sub-sectors move in opposite directions).
  13. Telecom - Bharti, Idea cellular, Tata communications.
  14. Retail - Avenue supermart, Titan.
  15. Textile - Page Inds, Lux Inds, Dollar Inds, Lovable, Rupa, AB Fashion, Shoppers stop, Ambika cotton, Verdhaman textiles, Arvind, SRF, Raymonds, Century Enka.
  16. Sugar - Triveni Engg, Dhampur sugar, Balrampur sugar.
  17. Paper - Jk paper, West coast paper, Ruchira papers.
  18. Tyre - Apollo tyres, JK tyres, Ceat, Balkrishna Inds, MRF, TVS shrichakra.
  19. Consumer durables - Sympnony, Whirlpool, Bajaj Electricals, IFB Inds, TTK prestige, Amber Enterprises, Blue star, Voltas, V-guard.
  20. Plastics - Supreme Inds, Prince pipes, Astral poly, Polycab, Polyplex, Nilkamal, VIP inds.

Sunday, March 20, 2022

Types of problems in graph theory.

  1. If given pair of graphs is isomorphic?
  2. Determine if there is a graph possible for the given degree sequence?
  3. Draw a graph with given degree sequence.
  4. Find the number of edges if a graph has 4 vertices of degree 3 and an isolated vertex.
  5. Find the number of regions in a connected planar graph if no. of edges is e and no. of vertices n.
  6. Determine if Ore's theorem can be used on given graph?
  7. Determine if Diarc's theorem can be used on given graph?
  8. Is the given graph planar?
  9. Is the given graph bipartite?
  10. Does graph have an Euler circuit?
  11. Does graph have an Hamiltonian circuit?
  12. Find the chromatic number of given graph?
  13. Color the given graph.
  14. Construct a 4 regular graphs on 12 vertices?
  15. Draw complement of given graph.
  16. Draw MSTs of the given graph.
  17. Prove that ............ 
  18. Define ---------  Regular graph, complete graph etc.

Saturday, March 5, 2022

Deterministic and Non-Deterministic Algorithms

 deterministic algorithm, for a given particular input, the computer will always produce the same output going through the same states but in case of non-deterministic algorithm, for the same input, the compiler may produce different output in different runs. In fact non-deterministic algorithms can’t solve the problem in polynomial time and can’t determine what is the next step. The non-deterministic algorithms can show different behaviors for the same input on different execution and there is a degree of randomness to it.


Source: https://www.geeksforgeeks.org/difference-between-deterministic-and-non-deterministic-algorithms/.

Question types in Theory of Computation

 Define a Regular Expression for given DFA.

Define a DFA for the given Regular Expression.

Give the language for the given Regular Expression.

Give the Regular Expression for the given Language.


Construct a DFA for given language.

Construct a PDA for given language.

Construct a TM for given language.



Give a CFG for the given language.

Give the language generated by the given CFG.

Show that given CFG is ambiguous.



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_...