Question
Asked Oct 13, 2019

Python 3.7.4

Use the file object output to write the string "3.14159" to a file called pi.

check_circle

Expert Answer

Step 1

Following is the program code which writes the string "3.14159" to a file called pi.

To open a file called pi.txt, we declared the variable file. The open() function takes 2 arguments the file we want to open and a string describing the kind of permission or operation that we want to do in the file. Here we used the letter "w" in our argument which signifies writing and the plus sign, which means that if the file does not exist in the library, it will create it. write() function is used to write data in the opened file.

Step 2

#open a file for writing and create it if not exist

file=open("pi",'w')

#variable to store...

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in

Engineering

Computer Science

Related Computer Science Q&A

Find answers to questions asked by student like you

Show more Q&A add
question_answer

Q: The CSM Tech organization has a substantial web presence with several publicly accessible web and ap...

A: The public DNS servers are running recursive queries for both, the internal and external clients whi...

question_answer

Q: A bag of cookies holds 40 cookies. The calorie information on the bag claims that there are 10 servi...

A: Program AlgorithmDeclare the required variable in the main().Get the input from the user for the num...

question_answer

Q: (check all that apply) Which of the following is true about constraint names?A) it can be used for D...

A: A) it can be used for DBA to identify a constraint easily:Yes. Constraints are the rules that are ap...

question_answer

Q: This is my code for an MIPS assignment where im taking numbers into an array and reversing within th...

A: Note:For the given code and attached image, the following explanation is briefly described about the...

question_answer

Q: What part do people play in an information system?

A: Information SystemInformation systems (IS) refers to the combination of hardware and software that i...

question_answer

Q: in c++ Write a program to generate a random number between 1 - 100, and then display which quartile ...

A: Program Instructions:Use the header files, constants, seed and random number generator given in the ...

question_answer

Q: Using Java Eclipse IDE write the following program: (Algebra: add two matrices) Write a method to ad...

A: Program AlgorithmInitialize two 3*3 matrices of type double.Initialize the third matrix of type doub...

question_answer

Q: In C++ I need to compose a function that accepts an array of integer values as an argument and retur...

A: Program Instructions:Pass array to the function getSum().Use the reference of the array to get the s...

question_answer

Q: Discuss the roles of information in globalisation of business

A: Globalization of business:People, organization and governments are integrated or interacted word wid...