Answer:
See explaination
Explanation:
import os
import time
from stat import *
file = input("Enter file name: ")
details = os.stat(file)#stores statistics about a file in a directory
print("File size: ", details[ST_SIZE])#retreiving size
print("File last accessed time: ", time.asctime(time.localtime(details[ST_ATIME])))#access time
print("File last modified time: ", time.asctime(time.localtime(details[ST_MTIME])))#modified time
print("File creation time: ", time.asctime(time.localtime(details[ST_CTIME])))#creation time
print("First character: ", file[0])
print("Middle character: ", file[len(file) // 2])
print("Last character: ", file[len(file) - 1])
num_words = 0
num_lines = 0
f=open(file, "r")
lines = f.readlines()
for line in lines:
num_lines = num_lines + 1
num_words = num_words + len(line.split())#add no. of words in that line
print("Number of lines: ", num_lines)
print("Number of words: ", num_words)