Question: create a file called file.txt and insert the following text: This is a test file Hello Student Testing 1,2,3 - testing ! Python rocks !

create a file called file.txt and insert the following text:

This is a test file Hello Student Testing 1,2,3 - testing ! Python rocks !

Follow the instructions below:

Write a code segment that opens a file named file.txt for input and prints the number of lines in that file.

Write a code segment that opens a file for input and prints the number of five-letter words in the file.

Write a code segment that prints the names of all the items in the current working directory.

Write a code segment that prompts the user for a file. If the file does not exist then the program should print an error. Otherwise, the program should print its contents.

Create a file called accounts.txt and enter the following information in the file

100 Mary 34.58 200 Alison 345.67 300 Marc 3.00 400 Zoltar -32.16 500 Kathleen 24.32

6. In the accounts.txt file:

update the name 'Zoltar' to 'Robert'

create a tempfile with the new data

remove accounts.txt file from the directory

rename the tempfile to a new file called myaccounts.txt

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!