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
1. What have you understood about the do's and don'ts inside the computer lab?
fiasKO [112]

Answer:

1.do=turn off machine after you are done using it

work quietly and ask permission before using

don't =bring any food or drinks

don't change computer settings

Explanation:

plz give me as brainlist question

7 0
3 years ago
One lap around a standard high-school running track is exactly 0.25 miles. Write the function miles_to_laps() that takes a numbe
Cerrena [4.2K]

def miles_to_laps(mi):

   return f"{mi} mile(s) is {mi/0.25} lap(s)"

print(miles_to_laps(1))

I wrote my code in python 3.8. I hope this helps!

6 0
3 years ago
Placeholders for fields such as "Last Name" and "Address" would be inserted into which
MrMuchimi

Answer:

Explanation:

The last name goes inside the main body of the mail specifically at the "closing block".

While the Address is inserted into the Subject Line specifically to the "To block"

7 0
3 years ago
Which part of the network communication process is responsible for sending and receiving data to and from the network media?
Whitepunk [10]

Answer:

Network Interface

Explanation:

Network interface is a piece of hardware or software that interfaces between two or more pieces of equipment or protocol layers in the computer network.

To do this, the computer needs a network interface card (NIC).

Ths NIC controls the wired and wireless connections of a computer to exchange information with other computers and the Internet.

4 0
3 years ago
Which is an example of a withholding you might see on your pay stub?
Arisa [49]
An example of a withholding you might see on your stub who'll be money.
3 0
3 years ago
Other questions:
  • Which of the following are stages in the computer life cycle? Check all of the boxes that apply.
    13·2 answers
  • Why isn't there a Psychology section on this app?
    5·1 answer
  • Which option best describes the cheapest way to file your federal income taxes?
    5·1 answer
  • Using your idea about how to solve this DUI problem, list two actions you can take that will make more people aware of this issu
    15·1 answer
  • Suppose Alice and Bob are sending packets to each other over a computer network. Suppose Trudy positions herself in the network
    8·1 answer
  • What file does a aac run under
    11·1 answer
  • ________ is a publicly accessible website that allows users to add and edit interlinked web pages and make contributions from th
    8·2 answers
  • Which of the following is one of the tools in REPL.it that helps prevent syntax errors?
    10·1 answer
  • Network footprinting is used to ______________________. Group of answer choices test for vulnerabilities determine what services
    12·1 answer
  • which dual-stack architecture allows ipv4 and ipv6 at the network layer to access a single tcp/udp stack
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!