1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
mr Goodwill [35]
3 years ago
12

Write a Python program that takes a file name as input and generates the following output: File size in bytes and KBs Time the f

ile is created in human readable format (i.e., not a timestamp) Last time the file is accessed and modified, also in human readable format First character, middle character (2 character is even size), and last character Number of words in the file Number of lines in the file
Computers and Technology
1 answer:
Airida [17]3 years ago
8 0

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)

You might be interested in
Which button could Pamela press in the Microsoft Word spell checker to make the word “colour” instantly change to “color” whenev
Norma-Jean [14]
She could right click her mouse to select the correct word to add it into her dictionary.
5 0
3 years ago
George borrowed some equipment from his friend for recording his monologue for his art class. He got all the equipment except th
Kitty [74]

Answer:

Internal sound card

Explanation:

In this case, George has used an Internal sound card, this is enough to record a podcast, make and receive video conferences or play video games.

If we're going to use an instrument, an external sound card, it's necessary, but in this case, George can make the record with high quality audio.

If George wants to add an adapter to connect 6'35mm but is not the same quality that an external sound card.

6 0
3 years ago
10 points + brainliest to first correect answer :) incorrect answers/ answers with no effort will be deleted this is easy im jus
Gala2k [10]

Answer:

The first option is incorrect

Explanation:

With the Control+C method, you copy the text. With the Control+V method, you paste it. You do not remove any of the text and instead create a duplicate

6 0
2 years ago
The purpose of a malfunction indicator lamp (MIL) is to:
Serga [27]
C is the right answer
3 0
3 years ago
What is the name of the interface that uses graphics as compared to a command-driven interface?
bonufazy [111]
Answer = GUI (Graphical User Interface)
4 0
3 years ago
Other questions:
  • Whats the best c++ compiler
    9·1 answer
  • What are the first two lines of defense a company should take when addressing security risks?
    10·1 answer
  • Can I change my username?
    6·1 answer
  • Write a method that returns a version of the given array where all the 10's have been removed. The remaining elements should shi
    9·1 answer
  • Consider the following method:
    14·1 answer
  • Pls help have absolutely no clue how to delete this
    12·2 answers
  • The Arizona Department of Transportation has offices throughout the state. State documents are stored on a large server in a cen
    5·2 answers
  • Something I should look for when trying to decide if a source is credible is the publication's ....
    10·1 answer
  • Write a python program that should determine from the range you choose to enter :
    9·1 answer
  • 13. In cell B16, use the SUMIF function and structured references to display the total wins for teams in the Youth league.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!