Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Comment and explain each portion of the program. Why is it printing what is printing? How did you find the answer? What was your process
Comment and explain each portion of the program.
Why is it printing what is printing?
How did you find the answer?
What was your process for evaluating each section or a piece of code or line of code.
Code:
import csv import datetime x = datetime.datetime.now() print(x.year) print(x.strftime("%A")) x = datetime.datetime.now() print(x) def deleteLine(): fn = 'List of Famous Cartoon Characters.txt' f = open(fn) output = [] str="A",'B','C',"D",'E','F','G',"He",'Ja','Lo',"Riddle me this Batman!" for line in f: if not line.startswith(str): output.append(line) f.close() f = open(fn, 'w') f.writelines(output) f.close() deleteLine() f = open("List of Famous Cartoon Characters.txt", "r") print(f.read()) f = open("List of Famous Cartoon Characters.txt", "r") print(f.read(5)) f = open("List of Famous Cartoon Characters.txt", "r") for x in f: print(x) f = open("List of Famous Cartoon Characters.txt", "a") f.write(" Riddle me this Batman! ") f.close() #open and read the file after the appending: f = open("List of Famous Cartoon Characters.txt", "r") print(f.read()) fn = 'List of Famous Cartoon Characters.txt' f = open(fn) output = [] str=" " for line in f: if not line.startswith(str): output.append(line) f.close() f = open(fn, 'w') f.writelines(output) f.close() with open('Book1COSC_151_FA20_2025.csv', newline='') as f: reader = csv.reader(f) for row in reader: print(row) ## 5RF4J\O/YnpCS^umc?
Book1COSC_151_FA20_2025.csv -- https://docs.google.com/spreadsheets/d/1cmbnHkyJEHnuneMysGHBtW9W1A3g_G-6Hdm28jQiCro/edit?usp=sharing
List of Famous Cartoon Characters.txt -- https://docs.google.com/document/d/1qfJeTiayeughz-AkUKeYTkLKSeJPHMePKpELPr1kfXY/edit?usp=sharing
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started