Complete the code to create a folder named 'Documents' to keep files organized.
import os os.[1]('Documents')
The mkdir function creates a new folder. This helps keep files organized by grouping them.
Complete the code to list all files in the 'Documents' folder.
import os files = os.[1]('Documents') print(files)
The listdir function lists all files and folders inside the specified folder. This helps you see what is inside 'Documents'.
Fix the error in the code to move a file named 'notes.txt' into the 'Documents' folder.
import os os.[1]('notes.txt', 'Documents/notes.txt')
The rename function can be used to move a file by changing its path. This moves 'notes.txt' into the 'Documents' folder.
Fill both blanks to create a dictionary that maps file names to their sizes in the 'Documents' folder.
import os sizes = {file: os.path.[1](os.path.join('Documents', file)) for file in os.[2]('Documents')}
getsize gets the size of a file, and listdir lists all files in the folder. Together, they create a dictionary of file sizes.
Fill all three blanks to filter files larger than 1000 bytes and create a dictionary with their names and sizes.
import os large_files = {file: os.path.[1](os.path.join('Documents', file)) for file in os.[2]('Documents') if os.path.getsize(os.path.join('Documents', file)) [3] 1000}
getsize gets the file size, listdir lists files, and > filters files larger than 1000 bytes.