Renaming Files with Python Quiz
FREE Online Courses: Click, Learn, Succeed, Start Now!
Quiz Summary
0 of 10 Questions completed
Questions:
Information
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading…
You must sign in or sign up to start the quiz.
You must first complete the following:
Results
Results
0 of 10 Questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 point(s), (0)
Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)
Categories
- Not categorized 0%
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- Current
- Review / Skip
- Answered
- Correct
- Incorrect
-
Question 1 of 10
1. Question
____ function is used to rename a file in Python?
CorrectIncorrect -
Question 2 of 10
2. Question
os.rename() requires atleast ___ argument(s) to rename a file.
CorrectIncorrect -
Question 3 of 10
3. Question
_____ module is required to add a date stamp to a filename.
CorrectIncorrect -
Question 4 of 10
4. Question
___ function is required along with os.rename() to rename multiple files simultaneously.
CorrectIncorrect -
Question 5 of 10
5. Question
Python raises ______ error when it can’t find the source file.
CorrectIncorrect -
Question 6 of 10
6. Question
The function shutil.move() is typically used to move a file from one directory to another directory. Is it possible to use the same function to rename a file?
CorrectIncorrect -
Question 7 of 10
7. Question
import os
from datetime import datetime
datestamp = datetime.now().date()
os.rename(“Funds.txt”, f”Funds {datestamp}.txt”)
CorrectIncorrect -
Question 8 of 10
8. Question
import os
path = “/Users/apple/”
x, y = (0, 3)
while x < y:
for file in os.listdir(path):
if file == f”someFile{y}.txt”:
os.rename(path+file,f”{path}student{y+1}.txt”)
x += 1
y -= 1
CorrectIncorrect -
Question 9 of 10
9. Question
import os
if not len(os.listdir()):
os.rename(‘apple.txt’, ‘mango.txt’)
print(“File Renamed”)
CorrectIncorrect -
Question 10 of 10
10. Question
import os
path = “/Users/apple/”
for i in range(len(os.listdir(path))):
os.rename(path+files[i], f”{path}MarksList{i+1}.txt”)
CorrectIncorrect