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]
3 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]3 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
Statistics are often calculated with varying amounts of input data. Write a program that takes any number of non-negative intege
sveta [45]

Answer:

// Program is written in Coral Programming Language

// Comments are used for explanatory purpose

// Declare and input n; n stands for the number of input data

integer n

n = Get next input

// Declare and initialise two Variables to 0;

// The first Variable Sum, is used for addition and the second, Max is used for the max

integer sum

integer max

Sum = 0

Max = 0

// Declare and intialise Variable count to hold the number of positive input data

integer count

count = 0

// Declare array. The array is used to hold all input data

integer array(n) Arr

// Declare iterating variable I

integer i

//Use the following iterative statement to input array data

for i = 0; i < Arr.size; i = i + 1

Arr[I] = Get next input

if Arr[i] >= 0

Sum = Sum + Arr[i]

count = count + 1

if Arr[i] >= Max

Max = Arr[I]

// Declare Variable average

float average

//Calculate and print average

average = Sum/count

Put average to output

Put Max to output

7 0
3 years ago
Unlike artistic drawings, which communicate self-expression and
Maurinko [17]

Answer:

The artistic drawings communicate self-expression and emotional content. However, when we come to manufacture or to construct a product, system, or device then you need to communicate its applications firstly, and then its features to prove why its the best choice as a product, system or device. And finally, you need to prove its affordable, if possible prove its still a luxury. And when we communicate size, shape and feature information, we need to prove its the best fit, and according to the requirement as well. Also, you need to prove its domain being quite vast such that more and more people with varied requirements show interest in buying it. And the shape is good in look as well. and features must be the best. If you are able to ensure these, your product, system or device is going to rock.

Explanation:

Please check the answer.

4 0
3 years ago
How can website illustrate cooperations and kidness?
Brilliant_brown [7]
It can illustrate cooperation's and kindness by allowing many different people and strangers to post their opinions and thoughts as long as they are being positive about it! Hope i helped
8 0
4 years ago
The ________ contains the central electronic components of the computer. select one:
Sati [7]
The motherboard contains the central electronic components of the computer.
6 0
3 years ago
Which of the following bit patterns represents the value -9 in two’s complement notation?
nadya68 [22]

Answer:

B. 11110111

Explanation:

Binary representation of number 9 = 00001001

Binary representation of -9 would involve calculating the twos complement representation of 00001001

First we compute the ones complement of this number by reversing the bits.

00001001 => 11110110

Next we calculate the twos complement representation by adding 1 to the ones complement.

11110110+1 = 11110111

So the final representation is 11110111.

5 0
3 years ago
Other questions:
  • The World Wide Web consists of interconnected computer networks throughout the world that everyone can use. True or False
    13·2 answers
  • Which of the following is the best definition of a workplace policy?
    13·2 answers
  • Which is the last step in conducting a URL search?
    5·2 answers
  • _____ are likely to support bigger government, social welfare programs, and legalized abortion.
    8·2 answers
  • Lydia noticed that she feels tired and out of breath after walking her dog up a hill in the park. Which area of fitness does she
    8·1 answer
  • Courteous behavior on the road will
    10·2 answers
  • An adiabatic capillary tube is used in some refrigeration systems to drop the pressure of the refrigerant from the condenser lev
    15·1 answer
  • 4.7 Code Practice: Question 2
    7·1 answer
  • Lasses give programmers the ability to define their own types. <br><br> a. True<br> b. False
    10·1 answer
  • Computer in education are used for teaching and learning aids​
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!