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
Color ___ indicates that one color is dominating a picture.
nevsk [136]
Color and defense indicates that one color is dominating  a picture
5 0
4 years ago
The information of an management information system comes from?
Debora [2.8K]

A management information system is a computer system consisting of hardware and software that serves as the backbone of an organization's operations

5 0
2 years ago
Fill up the blank:- The picture that graphically represents the items you use in Windows is called a/an .......
vagabundo [1.1K]
The picture that graphically represents the items you use in Windows or any other OS is called an Icon. An icon is a picture that represents the program that is being used. An icon is useful for the user's to directly know what type of program they need to use or such.
8 0
3 years ago
List analog devices, Digital devices and hybrid devices
andrey2020 [161]

Answer:

Types of Hybrid Computers:

1. Large Electronic Hybrid Computer

2. General-Purpose Hybrid Computers

3. Special-Purpose Hybrid Computers

Examples of Hybrid Computers

1. Gasoline Station

2. Electrocardiogram Machine

3. Ultrasound Machine

4. Monitoring Machine

5. Research and Production Industries

6. Forensic

7. Defence

Types of Analogue Computers

1. Slide Rules

2. Differential Analysers

3. Castle Clock

4. Electronic Analogue Computers

5. Mechanical Analogue Computers

Examples of Analogue Computers

1. Thermometer

2. Speedometer

3. Analogue Clock

4. Seismometer

5. Voltmeter

6. Flight Simulators

7. Tide Predictors

Types of Digital Computers

1. Micro Computer

2. Mini Computer

3. Mainframe Computer

4. Super Computer

Examples of Digital Computers

1. Calculator

2. Digital Clock

3. Automobiles

4. Weighing Machine

5. Consumer Electronic Equipments

6. Smart Phones

7. Laptop/Personal Computer

8. ATM

3 0
2 years ago
Nancy needs to find the average of two numbers in the middle from an even count of numbers arranged in descending order. which s
Rus_ich [418]

i would say e. the median

7 0
4 years ago
Read 2 more answers
Other questions:
  • intext:"The browser feature which enables tabs to work independently from one another so if one crashes, the others may continue
    12·1 answer
  • What are some good invention names for an air filter?
    14·1 answer
  • Which symbol is used to identify edge-triggered flip-flops? a triangle on the clock input. the letter e on the enable input. a b
    14·1 answer
  • Rows within a spreadsheet are identified by:
    8·1 answer
  • What email address should you use to send questions to a UC faculty or staff member?
    14·2 answers
  • How to deactivate the brainly app?​
    12·2 answers
  • This image shows a web designer’s grids for different pages on a website. The uppermost box on each page is the website’s identi
    15·2 answers
  • How do i solve this?
    11·1 answer
  • The conversion rate is the percentage of what? A. Customers who received cold calls B. Sales leads who reached the interest stag
    13·1 answer
  • It is a kind of malware (malicious software) that criminals install on your computer so they can lock it from a remote location.
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!