1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Licemer1 [7]
2 years ago
6

The create_python_script function creates a new python script in the current working directory, adds the line of comments to it

declared by the 'comments' variable, and returns the size of the new file. Fill in the gaps to create a script called "program.py". 1- def create_python_script(filename): 2 comments = "# Start of a new Python program" with open("filename", "w+") as file: file.write(comments) import os filesize - os.path.getsize(filename) print("The size of the file is:") return(filesize) Reset 3 4 5 6 7 Run 9 10 11 print(create python script("progran.py"))
Computers and Technology
1 answer:
Vika [28.1K]2 years ago
6 0

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.

You might be interested in
When saving a file, you must provide a valid file name that adheres to specific rules, referred to as _______________.
Naya [18.7K]

Answer:

a. file-naming conventions

Explanation:

File names need to follow certain criteria and constraints. Examples include:

  • File names must not start with special symbols.
  • File names can consist of letters,digits and special characters such as _.
  • File name can contain an extension after a dot sign.
  • File names must not be duplicates of an existing file.

Such constraints form part of file-naming conventions.

  • file-path represents the complete path to the file in the directory structure.
  • disk partition segments a hard disk into multiple volumes.
  • file-path starts from the root directory and spans one or more subdirectories to the location of the actual file.
6 0
3 years ago
DO NOT ANSWER FOR JUST POINTS
Elza [17]

Answer:

E.

a medium dashed line

Explanation:

I always use medium hehe so I think that'll work.

5 0
2 years ago
Read 2 more answers
Write a family database program. Create a class to represent a person and to store references to the person’s mother, father, an
Gennadij [26K]

Do you go to BASIS?

Sorry I don't have an answer for you, but we have the same assignment in our AP Comp sci class.

Just wondering.

8 0
2 years ago
United Broke Artists (UBA) is a broker for not-so-famous artists. UBA maintains a small database to track painters, paintings, a
lions [1.4K]

Answer:

Check the explanation

Explanation:

Kindly check the attached image below to see the relation and the table names.

7 0
3 years ago
Read 2 more answers
Which of the following are true about the PUSH instruction?
kkurt [141]

Answer:

Option A.

Explanation:

Only option A satisfies the definition of push statements. So it is only the correct option.

7 0
3 years ago
Other questions:
  • A software program that allows a programmer to type in code. modern versions usually make it easy to format the code on the scre
    13·1 answer
  • A plan that outlines the steps and timeline for reaching a certain goal is called a(n):
    13·1 answer
  • Design an algorithm for finding all the factors of a positive integer. For example, in the case of the integer 12, your algorith
    8·1 answer
  • when two pieces of cui or other unclassified information are posted online together or attached together in an email and result
    5·1 answer
  • Which shape is used for input or output?
    15·1 answer
  • What is the correct html for referring to an external style sheet?
    11·1 answer
  • Create an java application that will process 3-digit numbers as follows:
    8·1 answer
  • What power points feature will you use to apply motion effects to different objects of a slide
    5·1 answer
  • Topic: Drivers ed 100 points and brainliest!
    9·1 answer
  • Which of the following is not harmful to the computer?<br> a) Trojan<br> b) Rootkit<br> c)Malware
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!