Complete the code to copy a file named 'data.txt' to 'backup.txt'.
copyfile('data.txt', [1])
The copyfile function copies the source file to the destination file. Here, the destination should be 'backup.txt'.
Complete the code to move a file 'report.doc' to the folder 'archive/'.
move('report.doc', [1])
The move function moves the file to the new path. The destination must include the folder and the file name.
Fix the error in the code to delete the file 'temp.log'.
os.[1]('temp.log')
The correct function to delete a file in the os module is remove. Other options are not valid functions.
Fill both blanks to copy 'image.png' to 'backup/image_backup.png' only if the file size is greater than 1000 bytes.
if os.path.getsize('image.png') [1] 1000: copyfile('image.png', [2])
The condition checks if the file size is greater than 1000 bytes using '>'. The destination path for copying is 'backup/image_backup.png'.
Fill all three blanks to move all '.txt' files from 'docs/' to 'archive/' folder.
for file in os.listdir('docs/'): if file.endswith([1]): src = 'docs/' + file dst = [2] + file [3](src, dst)
The code checks if files end with '.txt', sets the destination folder to 'archive/', and moves the files using the move function.