#Credits to NPTEL MOOC, Programming, Data Structures & Algorithms #in Python by Madhavan Mukund, Chennai Mathematical Institute def gcd(m,n): cf = [] for i in range(1,min(m,n)+1): if (m%i) == 0 and (n%i) == 0: cf.append(i) return(cf[-1]) Source link

## GCD using euclids algorithms & looping

# Credits to NPTEL MOOC,Programming, Data Structures & Algorithms #in Python by Madhavan Mukund, Chennai Mathematical Institutedef gcd(m,n): if m < n: # Assume m >= n (m,n) = (n,m) while (m%n) != 0: diff = m-n # diff > n?

## Different Set Operations

A = {1,2,3,4,5,6,7,8};B = {5,10,15,20,25,30,35,40}; print(“Union of A and B is”,A | B) print(“nIntersection of A and B is”,A & B) print(“nDifference of A and B is”,A – B) print(“nSymmetric difference of A and B is”,A ^ B) Source link

## Calculation of Gross and Net Calorific Value

# Credits Name: ANUPRIYA R # HCV – Higher and Gross Calorific Value# LCV – Lower or Net Calorific Value# Compatible with python 3.x.x c=float(input(“enter value of carbon in %: “))h=float(input(“enter value of hydrogen in %: “))s=float(input(“enter value of

## Chemistry Problem Solver

# Credits Name: Abhijith P Email: [email protected]# Compatible with python 3.x.x # Program for problems related to chemistry# 1. Spectroscopy Problems# 2. Hardness of solution or water# 3. Calorific value# 4. Viscosity index # Abhijith P# Roll number 2#import osimport sysimport

## Character Classification based on ASCII value

SingleCharacter = input(“Enter a character:”,)Character = ord(SingleCharacter) # ord –> Convert a string to ASCII valueif Character > 0 and Character <= 31: print(“ASCII value”, Character,” is a control character”)elif Character >= 48 and Character <= 57: print(“ASCII value”, Character,”

## Check wheather a number is composite or not

#Credits to NPTEL MOOC, Programming, Data Structures & Algorithms in #Python by Madhavan Mukund, Chennai Mathematical Institute def composite(n): for i in range(2,n): if n%i == 0: return(True) return(False) Source link

## Use pass for an empty block

#Credits to NPTEL MOOC, Programming, Data Structures & Algorithms in #Python by Madhavan Mukund, Chennai Mathematical Institute while(True): try: userdata = input(“Enter a number: “) usernum = int(userdata) except ValueError: print(“Not a number. Try again”) except NameError: pass else:

## Divison with multiple conditions

#Credits to NPTEL MOOC, Programming, Data Structures & Algorithms in #Python by Madhavan Mukund, Chennai Mathematical Institute def divides(m,n): if n%m == 0: return(True) else: return(False) def even(n): return(divides(2,n)) def odd(n): return(not divides(2,n)) Source link

## Greatest common divisor program using euclids algorithms

#Credits to NPTEL MOOC, Programming, Data Structures & Algorithms in #Python by Madhavan Mukund, Chennai Mathematical Institute def gcd(m,n): if m < n: (m,n) = (n,m) if (m%n) == 0: return(n) else: diff = m-n return(gcd(max(n,diff),min(n,diff))) Source link