## convert from Centimeters to Yards, Feet and Inches

inCm = float(input(“How many centimeters do you want to convert? “)) yards = inCm // 91.44 left = (inCm / 91.44) – yards inCm = left * 91.44 feet = inCm // 30.48 left = (inCm / 30.48) – feet inCm = left * 30.48 inches = inCm / 2.54 print(“This is”,int(yards),”yards,”,int(feet),”feet,”,inches,”inches”)

## convert from lbs to gallons and ounces

lbs = float(input(“Plase enter the lbs of water treated: “)) ounces = lbs * 16 gallons = int(ounces / 128) ounces = ounces – gallons * 128 print(“That’s”,gallons,”gallons and”,ounces,”ounces of treated waste water.”)

## Total File Size

import os def main(): path = input(“Enter a directory or a file: “).strip() try: print(getSize(path), “bytes”) except: print(“Directory or file does not exist”) def getSize(path): size = 0 if not os.path.isfile(path): lst = os.listdir(path) for subdirectory in lst: size += getSize(path + “\\” + subdirectory) else: size += os.path.getsize(path) return size main()

## Recursive Binary Search

import os def main(): path = input(“Enter a directory or a file: “).strip() try: print(getSize(path), “bytes”) except: print(“Directory or file does not exist”) def getSize(path): size = 0 if not os.path.isfile(path): lst = os.listdir(path) for subdirectory in lst: size += getSize(path + “\\” + subdirectory) else: size += os.path.getsize(path) return size main()

## Fibonacci index

def main(): index = eval(input(“Enter an index for a fibonacci number: “)) print(“The Fibonacci number at index”, index, “is”, fib(index)) def fib(index): if index == 0: # Base case return 0 elif index == 1: # Base case return 1 else: # Reduction and recursive calls return fib(index – 1) + fib(index – 2) main() … Read moreFibonacci index

## Factorial Of

def main(): n = eval(input(“Enter a nonnegative integer: “)) print(“Factorial of “, n, “is”, factorial(n)) # Return the factorial for the specified number def factorial(n): if n == 0: return 1 else: return n * factorial(n – 1) # recursive call main() # Call the main function