![subject](/tpl/images/cats/informatica.png)
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](/tpl/images/cats/User.png)
Answers: 3
![](/tpl/images/ask_question.png)
![](/tpl/images/ask_question_mob.png)
Other questions on the subject: Computers and Technology
![image](/tpl/images/cats/informatica.png)
Computers and Technology, 21.06.2019 20:30, oofoofoof1
Write a program that reads the file, then displays the average number of steps taken for each month. (the data is from a year that was not a leap year, so february has 28 days.) your program needs to use at least 3 functions not counting main and display the information in a neat well formatted fashion.
Answers: 3
![image](/tpl/images/cats/informatica.png)
![image](/tpl/images/cats/informatica.png)
You know the right answer?
# [ ] Complete the following program to delete the first 10 files inside `files_exercises` (0.txt, 1...
Questions in other subjects:
![Konu](/tpl/images/cats/en.png)
![Konu](/tpl/images/cats/ekonomika.png)
Business, 27.06.2021 14:00
![Konu](/tpl/images/cats/fizika.png)
Physics, 27.06.2021 14:00
![Konu](/tpl/images/cats/mat.png)
Mathematics, 27.06.2021 14:00
![Konu](/tpl/images/cats/en.png)
English, 27.06.2021 14:00
![Konu](/tpl/images/cats/mat.png)
Mathematics, 27.06.2021 14:00
![Konu](/tpl/images/cats/geografiya.png)
Geography, 27.06.2021 14:00
![Konu](/tpl/images/cats/mat.png)
Mathematics, 27.06.2021 14:00
![Konu](/tpl/images/cats/fizika.png)