Python
# Program to get file metadata
import os
import time
filename = input("Enter filename: ")
try:
stats = os.stat(filename)
print("Size (bytes):", stats.st_size)
print("Last modified:", time.ctime(stats.st_mtime))
except FileNotFoundError:
print("File not found.")Output
Enter filename: notes.txt Size (bytes): 120 Last modified: Mon Nov 25 10:30:00 2025
os.stat returns an object with size, timestamps, and other low-level metadata; time.ctime renders timestamps nicely.