What is Python's os and sys modules?
Answer
The os module provides a portable way to interact with the operating system. File operations: os.getcwd() (current directory), os.chdir(path), os.listdir(path), os.mkdir(path), os.makedirs(path, exist_ok=True), os.remove(path), os.rename(src, dst). Path: os.path.join("dir", "file.txt"), os.path.exists(), os.path.abspath(), os.path.basename(), os.path.dirname(). Environment: os.environ.get("HOME"), os.environ["PATH"]. Process: os.getpid(), os.system("cmd") (prefer subprocess). The sys module provides Python runtime information: sys.argv (command-line arguments), sys.path (module search path), sys.version, sys.platform, sys.exit(code) (exit program), sys.stdin/stdout/stderr, sys.getrecursionlimit(), sys.getsizeof(obj) (object memory size in bytes).