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()

inheritance super class and sub class example

Super Class class GeometricObject: def __init__(self, color = “green”, filled = True): self.__color = color self.__filled = filled def getColor(self): return self.__color def setColor(self, color): self.__color = color def isFilled(self): return self.__filled def setFilled(self, filled): self.__filled = filled def __str__(self): return “color: ” + self.__color + ” and filled: ” + str(self.__filled)     Sub … Read moreinheritance super class and sub class example