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
Which of the following arguments are valid? Explain your reasoning
klio [65]

Answer:

a) the Statement is Invalid

b) the Statement is Invalid

Explanation:

a)

lets Consider, s: student of my class

A(x): Getting an A

Let b: john

I have a student in my class who is getting ab A: Зs, A(s)

John need not be the student i.e b ≠ s could be true

Hence ¬A(b) could be true and the given statement is invalid

b)

Lets Consider G: girl scout

C: selling 50 boxes of cookies

P: getting prize

s: Suzy

Now every girl scout who sells at least 50 boxes of cookies will get a prize: ∀x ∈ G, C(x) -> P(x)

Suzy, a girl scout, got a prize: s ∈ G, P(s)

since P(s) is true, C(s) need not be true

Main Reason: false → true is also true

Therefore the Statement is Invalid

7 0
2 years ago
Hello, this is mostly meant for 3 certain people (which they are listed in the main comments). I would say only they could answe
In-s [12.5K]

Answer:

bruh please join back im a new fnaf fandom and i need some help to understand what that is

Explanation:

5 0
3 years ago
Read 2 more answers
Write a loop that inputs words until the user enters STOP. After each input, the program should number each entry and print in t
scoray [572]

Answer:

oh wowwwwwwwww

Explanation:

7 0
2 years ago
Read 2 more answers
Given a high-level code you should be able to write the corresponding MIPS assembly code. Simple loop in C; A[ ] is an array of
nevsk [136]

Answer:

Explanation:

The code for the given problem is written below

.data

A : .word 1 2 3 4 5 6 7 8 9 10

.text

la $s5,A

li $s1,0 # load g

li $s2,10 # load h

li $s3,0 # load i

li $s4,1 # load j

loop:

mul $s6,$s3,4

add $s6,$s6,$s5 #address of A[i]

lw $s6,($s6) #get value of A[i] in s3

add $s1,$s1,$s6 #g = g+A[i]

add $s3,$s3,$s4 # i = i+j

bne $s3,$s2,loop #if i!=h jump to loop

4 0
2 years ago
2 ejemplos de sistemas automáticos en la construcción civil.
vodomira [7]

Answer:

ncdjjgcdbywgf ebyafbhfgcabfy bahgfdhvgafvhaef aeyhyfbhavgcjhvvhgfrau ahkgvbha,vjykabvfbhagkfvbadh avhvhav havgkv fa64gfdvwhefv nsdagcyudaf vdabncvyaukefk we7ytryuhaqgryw4tgty gyut r uytr eyuguhjayuft47rgutr7ytr  yuwqGHRUEGW7RUGU4GQATYUERGAYFUGEURGAAQ

Explanation:

8 0
3 years ago
Other questions:
  • Graphic design has evolved rapidly in recent years with the advancement of digital technology. Discuss how the evolution of grap
    8·1 answer
  • Ideation includes all of the following EXCEPT
    5·1 answer
  • Does anyone know a NC wise owl password I can use, it's an emergency!! I can't ask my school because they are closed and I need
    12·1 answer
  • What are six external parts of a computer
    11·1 answer
  • Every node (except of the last node) in a singly linked list contains ____
    5·1 answer
  • Marys total out of pocket costbwere for the year​
    12·1 answer
  • Any1??<br> Write the names of atleast 22 high-level programming languages
    13·1 answer
  • so i just went to play forge of empires and when i logged on to it all of my progress was gone and i was so far in to it
    15·2 answers
  • A motor is controlled by a logic circuit. The circuit has inputs (0 or 1) from three sensors
    8·1 answer
  • Can i get any information on this website i'd like to know what its for ?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!