Write a program using a for loop that creates a file and adds even numbers the integers 1 through 20 loop to the file. Name the file numbers. txt. Then perform the following on the file: Read all of the numbers stored in the file and calculate their total. Display all the numbers in the file and the calculated total Using a for loop add the following numbers to the file 21 through 30 Delete the following numbers from the file 24, 25, 26 (using a temp.txt file) Change the number 10 to 50 (using a temp.txt file)
Write a program using a for loop that creates a file and adds even numbers the integers 1 through 20 loop to the file. Name the file numbers. txt. Then perform the following on the file: Read all of the numbers stored in the file and calculate their total. Display all the numbers in the file and the calculated total Using a for loop add the following numbers to the file 21 through 30 Delete the following numbers from the file 24, 25, 26 (using a temp.txt file) Change the number 10 to 50 (using a temp.txt file)
C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter8: I/o Streams And Data Files
Section: Chapter Questions
Problem 9PP: (Inventory) Create an ASCII file with the following data, or use the shipped.dat file available on...
Related questions
Question
program - python
- Write a program using a for loop that creates a file and adds even numbers the integers 1 through 20 loop to the file. Name the file numbers. txt. Then perform the following on the file:
- Read all of the numbers stored in the file and calculate their total.
- Display all the numbers in the file and the calculated total
- Using a for loop add the following numbers to the file 21 through 30
- Delete the following numbers from the file 24, 25, 26 (using a temp.txt file)
- Change the number 10 to 50 (using a temp.txt file)
Hint: if you want to use !
Use module os that is part of Python to manipulate files.: import os. You can use functions that come with “os” module. Functions remove and rename can be used as explained below.
- rename(old_name,new_name):This function renames the old_name to new_name).
- remove(filename)method in Python is used to remove or delete a file.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images
Knowledge Booster
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.Recommended textbooks for you
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr