subject
Computers and Technology, 04.11.2021 07:10 ohgeezy

# [ ] Complete the following program to delete the first 10 files inside `files_exercises` (0.txt, 1.txt ... 9.txt) # Make sure the to run the environment setup code before running your own program.

import os

if ('files_exercises' not in os. getcwd()):
print("STOP Run the environment setup code!")

# list the content of `files_exercises`
print('Content of "files_exercises" before removing the files')
print(os. listdir())

#TODO: delete the first 10 files

# [ ] Write a program to delete all the even numbered files inside `files_exercises`
# Make sure the to run the environment setup code before running your own program.

import os
os. mkdir('files__exercises')
if ('files__exercises' not in os. getcwd()):
print("STOP Run the environment setup code!")

#TODO: Your code goes here

# [ ] Write a program to delete all the directories inside `files_exercises`
# Make sure the to run the environment setup code before running your own program.

import os

if ('files_exercises' not in os. getcwd()):
print("STOP Run the environment setup code!")

#TODO: Your code goes here

# [ ] Write a program to ask the user for a file number,
# then delete the file if it exists or display an appropriate error message if it does not.
# Make sure the to run the environment setup code before running your own program.

# Test your program with the following:
# case 1: user inputs 84, 84.txt should be deleted
# case 2: user inputs 84 (again), a File does not exist message is printed
# case 3: user inputs 5, 5.txt should be deleted

import os

if ('files_exercises' not in os. getcwd()):
print("STOP Run the environment setup code!")

#TODO: Your code goes here

# [ ] Write a program to ask the user for a file number,
# then delete the file if it exists or display an appropriate error message if it does not.
# Use file exception handling instead of file existence tests.
# Make sure to run the environment setup code before running your own program.

# Test your program with the following:
# Case 1: When the user inputs 84, the program should delete the file 84.txt
# Case 2: When the user inputs 84 (again), the program should print a File Not Found error message
# Case 3: When the user inputs 5, the program should delete the file 5.txt

import os

if ('files_exercises' not in os. getcwd()):
print("STOP Run the environment setup code!")

#TODO: Your code goes here

# [ ] Write a program to print the first line of every file inside `files_exercises`
# Use a `with` statement to open (and close) every file
# Make sure the to run the environment setup code before running your own program.

import os

if ('files_exercises' not in os. getcwd()):
print("STOP Run the environment setup code!")

#TODO: Your code goes here

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 15:00
This is not a factor that you should use to determine the content of your presentation. your audience your goals your purpose your technology
Answers: 1
question
Computers and Technology, 23.06.2019 13:30
Spoons are designed to be used for: spring hammering. applying body filler. identifying high and low spots. sanding highly formed areas.
Answers: 3
question
Computers and Technology, 23.06.2019 15:30
Brian wants to conduct an online search with a certain phrase. he intends to use the words books that belong to the 1800s in his search. how should he use the word that in his search?
Answers: 1
question
Computers and Technology, 23.06.2019 16:30
How to do this programming flowchart?
Answers: 3
You know the right answer?
# [ ] Complete the following program to delete the first 10 files inside `files_exercises` (0.txt, 1...
Questions
question
Mathematics, 21.08.2020 05:01
question
Mathematics, 21.08.2020 05:01
Questions on the website: 13722361