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
Instructions The population of town A is less than the population of town B. However, the population of town A is growing faster
weeeeeb [17]

Answer: The c++ program is given below.

#include <iostream>

using namespace std;

int main() {

float townA, townB, growthA, growthB, populationA, populationB;

    int year=0;    

cout<<"Enter present population of town A : ";

cin >> townA;  

cout<<endl<<"Enter present growth rate of town A : ";

cin >> growthA;

growthA = growthA/100;  

cout<<endl<<"Enter present population of town B : ";

cin >> townB;  

cout<<endl<<"Enter present growth rate of town B : ";

cin >> growthB;

growthB = growthB/100;  

do

{

    populationA = townA + (townA * growthA);

    populationB = townB + (townB * growthB);      

    townA = populationA;

    townB = populationB;      

    year++;      

}while(populationA < populationB);  

cout<<endl<<"After " <<year<< " years, population of town A is "<<populationA << " and population of town B is "<< population<<endl;

return 0;

}

Explanation:

All the variables for population and growth rate are declared with float datatype.

The user inputs the present population of both the towns.

The growth rate entered by the user is the percentage growth.

For example, town A has 10% growth rate as shown in the output image.

The program converts 10% into float as 10/100.

growthA = growthA/100;

growthB = growthB/100;

The above conversion is done to ease the calculations.

The year variable is declared as integer and initialized to 0.

The growth in population is computed in a do-while loop. After each growth is calculated, the year variable is incremented by 1.

The loop continues until population of town A becomes greater than or equal to population of town B as mentioned in the question.

Once the loop discontinues, the final populations of town A and town B and the years needed for this growth is displayed.

The new line is introduced using endl keyword.

The function main has return type int hence, 0 is returned at the end of the program.

6 0
3 years ago
__________ BI apps use real-time or near real-time data in order to support line managers who need to monitor performance of his
ruslelena [56]

Answer: Operational BI(Business Intelligence)

Explanation:Operational business intelligence is the tool that works on the organizational performance through evaluation and testing by analyzing the business process and data.It is rapid responding tool for the changing business pattern and demands.

Strategical, tactical and traditional business intelligence tool don't provide the evaluation of the business performance in the accordance with business trends rather having strategical approach, planned approach and traditional approach respectively.

Thus, the correct option is option(b).

8 0
3 years ago
Match the definition
Katen [24]

Answer:

¿???????????? SORRY..........

8 0
2 years ago
Sue is installing a printer. What program will she need to get the printer to work with her computer? Specify some functionaliti
umka21 [38]

Answer:

Utility software tool​

Explanation:

After connecting the printer and turning it on, you'll need to install the printers software and drivers. Every printer should come with the software used to install a printer in Windows or your operating system.

8 0
2 years ago
Which is the output of the formula =XOR(120&lt;102;83=83;51&lt;24)??
Greeley [361]
The output of the formula will be TRUE because '83 = 83' is the only true expression of that three expressions present in the formula.
The output of the XOR function will be TRUE in case only one logical expression is true and FALSE otherwise.
7 0
3 years ago
Read 2 more answers
Other questions:
  • When a crystal grows in unrestricted space, how does growth occur?
    14·2 answers
  • Write a program in C++ to implement bubblesort using the swap function ?
    11·1 answer
  • Possible consequences for plagiarism, listed in CAVA's Academic Integrity Policy, may include:
    9·1 answer
  • A type of Knowledge Management System is called
    5·1 answer
  • Which of the following could be a constructor for the public class MyClass? a. public MyClass() b. public void MyClass() c. publ
    7·1 answer
  • Program: ASCII art (Python 3)1) Output this tree. 2) Below the tree (with two blank lines), output this cat. (3 pts) /\ /\ o o =
    8·1 answer
  • Me inculparon de crear una cuenta en Facebook y colocaron el barrio donde vivo, ¿cómo podría demostrar lo contrario? Ayuda urgen
    6·1 answer
  • Moving your Sprite from right to left is considered the X coordinate?
    5·1 answer
  • Which is the correct option?
    6·1 answer
  • eocs can be fixed locations, temporary facilities, or virtual structures with staff participating remotely.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!