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
sergij07 [2.7K]
3 years ago
10

Write a function writel that will write the length of a side of a square. If only one argument is passed to the function, it is

the length, and the output will go to the Command Window. If two arguments are passed, however, the first argument will be the length and the second argument will be the file identifier for an output file to which the length should be printed.
Computers and Technology
1 answer:
Levart [38]3 years ago
7 0

def writel(length, file_name = ""):

   if file_name!="":

       f = open(file_name, "w")

       f.write(str(length))

       f.close()

   else:

       print(str(length))

writel(3, "FileName.txt")

I hope this helps!

Remember, you must have the file created prior to running this program. Best of luck.

You might be interested in
Create a 4x5 matrix with ones everywhere and zeros on the last row.
Stells [14]

Answer:

#include <iostream>

using namespace std;

int main() {

   int a[4][5];//declaring a matrix of 4 rows and 5 columns.

   for(int i=0;i<4;i++)

   {

       for(int j=0;j<5;j++)

       {

           if(i==3)//initializing last row as 0.

           {

               a[i][j]=0;

           }

           else//initializing last row as 1.

           {

               a[i][j]=1;

           }

       }

   }

   for(int i=0;i<4;i++)

   {

       for(int j=0;j<5;j++)

       cout<<a[i][j]<<" ";//printing the matrix.

       cout<<endl;

   }

return 0;

}

Output:-

1 1 1 1 1  

1 1 1 1 1  

1 1 1 1 1  

0 0 0 0 0

Explanation:

I have created a matrix of size 4 rows and 5 columns.I have used for loops to fill the array.To fill the last row with 0 i have used if statement.else we are filling it with 1.

7 0
3 years ago
Create a console application to keep track of contact information. Print the contacts of the address book in sorted order first
vaieri [72.5K]

Answer:

The code is written in C++ below with appropriate comments

Explanation:

#include <iostream>

#include <cstring>  //this takes care of the customer details

//that will be imputed into the program

using namespace std;

//using user-defined struct format to store contact details

struct Contact{

char FirstName [60]; //character string for first name

char LastName [60]; //character string for last name

char PhoneNumber [30]; //character string for phone number

//this takes care of cases where international format is used

char Email [40]; //character string for email

};

int main()

{

//case example for storing values of a contact called John

Contact John;

//strcpy is used to assign character strings

//to user-defined structs

strcpy(John.FirstName,"John");

strcpy(John.LastName, "Doe");

strcpy(John.PhoneNumber,"+1234567890");

strcpy(John.Email, "johndoe @ nomail . com");

//added spaces due to regulations

//this has stored the information of Joe

//printing the contact name

cout<<"The customer is:"<<John.LastName<<" "<<John.FirstName;

//prints out the last name then first name as given

//you can edit it for the desired customers

}

3 0
3 years ago
Which finger is the correct finger to key the letter "O"?
Lorico [155]

Answer:

probably the pincky finger I don't know I use what ever

3 0
3 years ago
What is the Big-Oh of the following computation? int sum = 0; for (int counter = 1; counter &lt; n; counter++) sum = sum + count
Brilliant_brown [7]

Answer:

The Big-O notation of the algorithm is O(n)

Explanation:

The declaration and update of the integer variable sum is a constant of O(1). The for loop statement, however, would repeat relative to the size of "n", increasing the counter variable and updating the sum total by the counter.

3 0
3 years ago
What is the limitation of the procedure forward()?
Rina8888 [55]

Answer:

sandwich breadtughug

Explanation:

Katty bread

5 0
3 years ago
Other questions:
  • You can create a ____ partition to hold files that are created temporarily, such as files used for printing documents (spool fil
    13·1 answer
  • What is an activity that can help you enhance the appearance of your computer’s desktop?
    12·2 answers
  • What type of IPv6 address should you use when you have multiple routers on a subnet and want hosts to use the nearest router for
    10·1 answer
  • Which of the following is a valid formula?<br> (C2-D16)<br> O A2/F2<br> O=B5/10<br> O =E10
    14·1 answer
  • Question 4: What will be the output of the code? Show a complete analysis.
    6·1 answer
  • Im building my first gaming pc, got any part suggestions or tips?
    7·2 answers
  • In computer science how can you define "copyright, designs and patents act 1988"?​
    8·1 answer
  • What is the purpose of indexing?
    15·2 answers
  • 2y/3 - y-1/6 + 7y-1/4 = 2 1/6​
    5·1 answer
  • You are looking for a computer to provide a central location for online game play. What kind of computer do you need
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!