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
djyliett [7]
2 years ago
9

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".
def create_python_script(filename):
comments = "# Start of a new Python program"
with ___:
filesize = ___
return(filesize)
print(create_python_script("program.py"))

Computers and Technology
1 answer:
iogann1982 [59]2 years ago
3 0

Answer:

Following are the code to this question:

with open(filename,"w+") as file: #use an open method that open file in w+ mode        

   file.write(comments)#use write method that inputs the value in the file            

   file.close()#closing the file  

import os#import package os for file  

filesize = os.path.getsize(filename)#defining a variable filesize that uses the getsize method to calculate its size.

Explanation:

Following are the full program to this question:

def create_python_script(filename):#defining method create_python_script that accept filename variable as the parameter

   comments = "# Start of a new Python program"#defining a string varaible comments that holds string value      

   with open(filename,"w+") as file: #use an open method that open file in w+ mode        

       file.write(comments)#use write method that inputs the value in the file        

       file.close()#closing the file    

   import os#import package os for file  

  filesize = os.path.getsize(filename)#defining a variable filesize that uses the getsize method to calculate its size.  

 return filesize#return filesize value

print(create_python_script("program.py"))#use print method that call create_python_script and print its return value

Output:

please find program file and its output.

Program description:

In the above-given program, a method "create_python_script" is declared that accept the "filename" as the parameter, inside the method a comments string variable is declared, that holds string value and define an open method to open "program.py" file and assign the string value in the file.

In the next line, the "getsize" method is defined, which counts string value in digits and returns its value and use the print method to call the "create_python_script" with parameter a print its value.

You might be interested in
_____________________ denotes the use of human interactions to gain any kind of desired access. Most often, this term involves e
pishuonlain [190]

Answer:

Social engineering

Explanation:

<u>Social engineering</u> involves exploiting existing relationships and <u>manipulating people to reveal certain confidential information or to grant access to such information, systems, or networks</u>, usually for fraudulent reasons.

4 0
2 years ago
Match each with the correct answer.
natta225 [31]

Answer:

1. E

2. C

3. F

4. D

5. A

6. B

Explanation:

CPU: this is known as the central processing unit and it is considered to be the brain of a computer system. It is the system unit where all of the processing and logical control of a computer system takes place.

A. Decode unit: decodes instructions and data and transmits the data to other areas in an understandable format.

B. Register unit: contains many separate, smaller storage units. Modern CPUs need only a few nanoseconds to execute an instruction when all operands are in its registers.

C. Bus unit: it is used to connect all the other major components together, accepts data, and sends data through the input and output bus sections.

D. Control unit: control of the overall operations of the CPU. The component of the central processing unit (CPU) that controls the overall operation of a computer is the control unit. It comprises of circuitry that makes use of electrical signals to direct the operations of all parts of the computer system. Also, it instructs the input and output device (I/O devices) and the arithmetic logic unit how to respond to informations sent to the processor.

E. Arithmetic logic unit (ALU): performs mathematical functions on data stored in the register area.

F. Cache: small temporary memory area that separates and stores income data and instructions.

8 0
2 years ago
What type of electronic monitoring involves an offender being contacted periodically by telephone or beeper to verify his or her
Masja [62]
The type of electronic monitoring that involves an offender being contacted periodically by telephone or beeper to verify his or her whereabouts is called the programmed contact. It is a method used in investigations to monitor the offender in a certain situation where he is forced to remain.
7 0
3 years ago
Are commonly used to control the number of times that a loop iterates?
pickupchik [31]
Hmm... I feel like this query is much broader than it should be. However, I will start my initial answer, then another potential solution.

My initial answer to your query was: A condition controlled loop is used to control the number​ of times a loop iterates.

The potential answer, my secondary one, is: A count controlled loop iterates a specific number of times.

Two results, but my initial answer is the solution I opted when understanding this.
5 0
3 years ago
Habilidades de la alfabetizacion digital?
Eva8 [605]

Answer:

La American Library Association (ALA) define la alfabetización digital como "la capacidad de utilizar las tecnologías de la información y la comunicación para encontrar, evaluar, crear y comunicar información, lo que requiere habilidades cognitivas y técnicas".

6 0
2 years ago
Other questions:
  • Which presenter would most likely benefit from a custom slide show?
    10·2 answers
  • ____ are systems in which queues of objects are waiting to be served by various servers
    5·1 answer
  • )in the link based implementation of the ADT sorted list what is the worst case time efficiency of the remove method?
    7·1 answer
  • HELP! ASAP I KNOW IT'S QUITE A HANDFUL BUT I NEED THIS ANSWER!!
    10·1 answer
  • Write a function called simulate_several_key_strikes. It should take one argument: an integer specifying the number of key strik
    7·1 answer
  • I'd: 9872093250, password: qqqqq, join the meeting​
    11·1 answer
  • Describe from an administrator perspective what is necessary to prepare a storage device for access by a user.
    14·1 answer
  • What is computer topology​
    5·2 answers
  • What product use programmable control?
    11·1 answer
  • Data elements in a relational database are organized into ____
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!