Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

lines 1 to 3: #Write a function called write_weird_file. write_weird_file #should take two positional parameters. The first should be #a filename, and the second should

image text in transcribedlines 1 to 3: #Write a function called write_weird_file. write_weird_file #should take two positional parameters. The first should be #a filename, and the second should be a list. The function

file input/output help

FlexibleFileWriting.py SubmitRun Grades Reset 3 #a filename, and the second should be a list. The function Console output will be displayed here 4 #should also have three keyword parameters: mode, sort-first 5 #and reverse-first. The default value for mode should be "w", 6 #and the default values for both sortfirst and reversefirst - - 7 #should be False 8# 9 #write weird file should write the contents of the list to 10 #the given filename. Each item from the list should be on a 11 #separate line. The list items could be strings, floats, 12 #characters, or integers. If the mode is "w", it should 13 #overwrite the current contents; if the mode is "a", it 14 #should append to the current contents. You may assume there 15 #will be no other value for mode 16 # 17 #If sort first is True, it should sort the list before 18 #writing-If reverse first is True, then it should reverse 19 #the list before writing. If both are True, it should sort, 20 #then reverse 23 #Add your function here! 27 #Below are some lines of code that will test your function 28 #You can change the value of the variable(s) to test your 29 #function with different inputs 30# 31 #If yo 32 #print nothing. However, if you open the file called 33 #output.txt in the top left after running it, the contents 34 #of the file should be: 35 #wait, where'd the other text go? 36 #It's gone! 37 #3 38 #2 39 #1 40 write weird file("output.txt", ["Hmm, I bet this text will disappear.", "I wonder where it will go?"]) 41 write _weird file("output.txt", "Wait, where'd the other text go?", "It's gone! ur function works correctly, this will originally 42 write _wird fileoutput.txt", 2, 1, 3], mode-", sort first-True, ree st-True) 43

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

1. Are my sources credible?

Answered: 1 week ago

Question

3. Are my sources accurate?

Answered: 1 week ago

Question

1. Is it a topic you are interested in and know something about?

Answered: 1 week ago