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
Select the parts of a business letter.
erastovalidia [21]
First the heading, then the inside address, the greating, the body, the complimentary and last the signature line
6 0
3 years ago
Read 2 more answers
What are three ways to protect yourself from identity theft when using your smartphone or computer?.
raketka [301]

Answer:

1. Always download the latest updates .

2. Don’t click on rogue links .

3.Secure your devices (long, complex password on your computer and phone, using Anti-virus/Anti-Malware program) .

5 0
3 years ago
Please I need this answer now.<br>this is the fill in the blanks​
Nastasia [14]
Mother board

Because that’s where all the processing takes place
8 0
3 years ago
Identify three different meanings of the word "interface" in Java Programing language.
Mnenie [13.5K]

Answer: Interface methods, interface variables and interface markers.

Explanation:

Interface methods are public and abstract by default.

Interface variables can be declared public, static and final

Marker interfaces are simply empty interfaces without any methods.

7 0
3 years ago
On a digital clock the displayed time changes constantly (True or False)
Vlada [557]
The answer is true as it will change on its own
8 0
3 years ago
Other questions:
  • All but one of the following statements about stored procedures is true. Which one is false? a. They consist of one or more SQL
    10·1 answer
  • Once the data center routes to the destination server that hosts the website, whats the next step in the internet process?
    10·1 answer
  • This type of handout prints only the text of the presentation.
    7·1 answer
  • Which best describes what a bibliography includes?
    8·1 answer
  • In a certain computation, 90% of the work is vectorizable. Of the remaining 10%, half is parallelizable for an MIMD machine. Wha
    9·1 answer
  • Write a program that receives a series of numbers from the user and allows the user to press the enter key to indicate that he o
    10·1 answer
  • Study the following two class interfaces: class Question { public: Question(); void set_text(string new_text); void set_answer(s
    11·1 answer
  • Dennis would like to include a video in a presentation. The source of the video is on the internet, but he would like to ensure
    10·2 answers
  • HELP ME!!!!!!! %) select all the correct answer. What will be the output of using the element in the given HTML code? 1011 2 A.
    6·1 answer
  • Assume you have a button control named btndisplaylist. Which is the default name for an event procedure that will be executed wh
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!