For this HW assignment, you will demonstrate that you can write data files. Python program will you write data to a file. The specific requirements for each program are: 1) The first program will use the code that is contained in HW12-WriteStart.py to create the data to be written out. Please feel free to examine the code provide but do not modify the code. Place your code below the comment that says to place your code below this line. The code you should add should do the following: a. Specify a default file name to use for the output file. b. Check to see if the file already exists. If it does already exist, ask the user if it is okay to overwrite the file—be sure and tell them the file name. For an extra challenge and bonus points, prompt the user to enter a new file name. c. The data created by the initial code in HW12-WriteStart.py creates a list named Rows that contains rows of data. Each element of Rows is another list that contains a name and some quiz scores. You are to write each row of data to the output file using comma separators between each item and ending the line with a newline character. When writing the information to the file also write an exact copy of the data to the screen using a print command. d. Close the file and exit the program.   The specific requirements for each program are: 1) The  program will use the code that is contained in HW12-WriteStart.py to create the data to be written out. Please feel free to examine the code provide but do not modify the code. Place your code below the comment that says to place your code below this line. The code you should add should do the following: a. Specify a default file name to use for the output file. b. Check to see if the file already exists. If it does already exist, ask the user if it is okay to overwrite the file—be sure and tell them the file name. For an extra challenge and bonus points, prompt the user to enter a new file name. c. The data created by the initial code in HW12-WriteStart.py creates a list named Rows that contains rows of data. Each element of Rows is another list that contains a name and some quiz scores. You are to write each row of data to the output file using comma separators between each item and ending the line with a newline character. When writing the information to the file also write an exact copy of the data to the screen using a print command. d. Close the file and exit the program. If you want an extra challenge for the  program, you could sort the Rows list before writing it to the file. Writestart.py: for i in range(random.randint(6,8)): Col = [Name()] for j in range(random.randint(3,5)): Col.append(random.randint(60,100)/10) Col.append(Col[len(Col)-1]) Rows.append(Col) print(Col) print("Number of Rows is",len(Rows),"\n\n*** Your Output is below ***") # **** Put your code below this line. Do not change anything above this line. **** expected output example: Here's some example output from write program: The data created for your program is: ['Dbhh', 8.5, 7.6, 6.8, 7.2, 7.2] ['Lghh', 8.2, 9.1, 9.5, 9.0, 6.9, 6.9] ['Graa', 6.5, 7.2, 9.0, 8.5, 8.5] ['Piyvv', 8.6, 7.7, 9.9, 7.2, 9.1, 9.1] ['Xfmm', 8.5, 8.7, 9.0, 6.4, 9.3, 9.3] ['Nfebb', 9.9, 9.0, 7.0, 7.8, 6.0, 6.0] ['Lyxll', 7.1, 10.0, 9.0, 9.0] Number of Rows is 7 *** Your Output is below *** HW #12 WriteProgram: Ken Pottebaum HW12data.xxx exists. Okay to overwrite it [y=Yes,N=No]: n Enter new file name or press enter to abort: HW12data2.xxx Here's a copy of what is being written to the file: Dbhh,8.5,7.6,6.8,7.2,7.2 Lghh,8.2,9.1,9.5,9.0,6.9,6.9 Graa,6.5,7.2,9.0,8.5,8.5 Piyvv,8.6,7.7,9.9,7.2,9.1,9.1 Xfmm,8.5,8.7,9.0,6.4,9.3,9.3 Nfebb,9.9,9.0,7.0,7.8,6.0,6.0 Lyxll,7.1,10.0,9.0,9.0 Finished writing fil

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

For this HW assignment, you will demonstrate that you can write data files. Python program will you write data to a file.

The specific requirements for each program are:
1) The first program will use the code that is contained in HW12-WriteStart.py to create the
data to be written out. Please feel free to examine the code provide but do not modify the
code. Place your code below the comment that says to place your code below this line. The
code you should add should do the following:
a. Specify a default file name to use for the output file.
b. Check to see if the file already exists. If it does already exist, ask the user if it is okay
to overwrite the file—be sure and tell them the file name. For an extra challenge and
bonus points, prompt the user to enter a new file name.
c. The data created by the initial code in HW12-WriteStart.py creates a list named Rows
that contains rows of data. Each element of Rows is another list that contains a name
and some quiz scores. You are to write each row of data to the output file using
comma separators between each item and ending the line with a newline character.
When writing the information to the file also write an exact copy of the data to the
screen using a print command.
d. Close the file and exit the program.

 

The specific requirements for each program are:
1) The  program will use the code that is contained in HW12-WriteStart.py to create the
data to be written out. Please feel free to examine the code provide but do not modify the
code. Place your code below the comment that says to place your code below this line. The
code you should add should do the following:
a. Specify a default file name to use for the output file.
b. Check to see if the file already exists. If it does already exist, ask the user if it is okay
to overwrite the file—be sure and tell them the file name. For an extra challenge and
bonus points, prompt the user to enter a new file name.
c. The data created by the initial code in HW12-WriteStart.py creates a list named Rows
that contains rows of data. Each element of Rows is another list that contains a name
and some quiz scores. You are to write each row of data to the output file using
comma separators between each item and ending the line with a newline character.
When writing the information to the file also write an exact copy of the data to the
screen using a print command.
d. Close the file and exit the program.

If you want an extra challenge for the  program, you could sort the Rows list before writing
it to the file.

Writestart.py:

for i in range(random.randint(6,8)):
Col = [Name()]
for j in range(random.randint(3,5)):
Col.append(random.randint(60,100)/10)
Col.append(Col[len(Col)-1])
Rows.append(Col)
print(Col)
print("Number of Rows is",len(Rows),"\n\n*** Your Output is below ***")

# **** Put your code below this line. Do not change anything above this line. ****

expected output example:

Here's some example output from write program:
The data created for your program is:
['Dbhh', 8.5, 7.6, 6.8, 7.2, 7.2]
['Lghh', 8.2, 9.1, 9.5, 9.0, 6.9, 6.9]
['Graa', 6.5, 7.2, 9.0, 8.5, 8.5]
['Piyvv', 8.6, 7.7, 9.9, 7.2, 9.1, 9.1]
['Xfmm', 8.5, 8.7, 9.0, 6.4, 9.3, 9.3]
['Nfebb', 9.9, 9.0, 7.0, 7.8, 6.0, 6.0]
['Lyxll', 7.1, 10.0, 9.0, 9.0]
Number of Rows is 7
*** Your Output is below ***
HW #12 WriteProgram: Ken Pottebaum
HW12data.xxx exists. Okay to overwrite it [y=Yes,N=No]: n
Enter new file name or press enter to abort: HW12data2.xxx
Here's a copy of what is being written to the file:
Dbhh,8.5,7.6,6.8,7.2,7.2
Lghh,8.2,9.1,9.5,9.0,6.9,6.9
Graa,6.5,7.2,9.0,8.5,8.5
Piyvv,8.6,7.7,9.9,7.2,9.1,9.1
Xfmm,8.5,8.7,9.0,6.4,9.3,9.3
Nfebb,9.9,9.0,7.0,7.8,6.0,6.0
Lyxll,7.1,10.0,9.0,9.0
Finished writing file.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
File Input and Output Operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education