Answer: Have you gotten an answer yet?
Answer:
import os
def create_python_script(filename):
comments = "# new python script file"
with open(filename,"w+") as file:
file.write(comments)
filesize = os.path.getsize(filename)
print(f"The size of the file is: {filesize}")
create_python_script("program.py")
Explanation:
The os module is a built-in python file that is used to interact with the operating system terminal. The with keyword is used to create and open a file with write privileges with no need to close the file.
The path.getsize() method is used to get the size of the newly created file which is printed in the console.
Answer:
40, 5 and 3
See explaination for the details
Explanation:
A)
Consider the data.
Assume D-cache is empty
An integer size =4bytes
The cache block size =4bytes
Therefore, the number of D-cache misses for reading the first 40 integers is,
= (40×4)/4
= 160/4
= 40
b)
Consider the data.
Assume D-cache is empty
An integer size =4bytes
The cache block size =32bytes
Therefore, the number of D-cache misses for reading the first 40 integers is,
= (40×4)/32
= 160/32
= 5
c)
Consider the data.
Assume D-cache is empty
An integer size =4bytes
The cache block size =64bytes
Therefore, the number of D-cache misses for reading the first 40 integers is,
= (40×4)/64
= 160/64
= 3