Question

The following question is based on Python programming language. Consider the function open(). a) What does...

The following question is based on Python programming language.

Consider the function open().
a) What does open() open?
b) What is the difference in possible actions you can take using the object returned by open() if
you pass the argument 'r', 'w', or 'a'?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

a) What does open() open?

The open() function opens a file, and returns it as a file object.

(b)  What is the difference in possible actions you can take using the object returned by open() if
you pass the argument 'r', 'w', or 'a'?

'r' - Read - Default value. Opens a file for reading, error if the file does not exist

'w' - Write - Opens a file for writing, creates the file if it does not exist

'a'  - Append - Opens a file for appending, creates the file if it does not exist

Add a comment
Know the answer?
Add Answer to:
The following question is based on Python programming language. Consider the function open(). a) What does...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please use python Programming Language: Select one of the following topics: Band Character Account Create a...

    Please use python Programming Language: Select one of the following topics: Band Character Account Create a class based on your chosen topic. Make sure to include at least four attributes of varying types, a constructor, getters/setters for each attribute w/input validation, a toString, a static attribute, and a static method. Then, create a function (outside of your class) that connects to a text file which should contain the attributes of several objects. Read the data from the file, use the...

  • Python Programming QUESTION 16 Which of the following is an example of a Keyword in Python?...

    Python Programming QUESTION 16 Which of the following is an example of a Keyword in Python? elif class for All of the above QUESTION 17 Which of the following is not an acceptable variable name in Python? 2ndVar $amount Rich& ard None of the above are acceptable variable names QUESTION 18 The number 1 rule in creating programs is ___________________- Write the code first Think before you program Let the compiler find you syntax errors There are no rules just...

  • Programming Language : Python Question a) Are there any programming framework for this language? If yes,...

    Programming Language : Python Question a) Are there any programming framework for this language? If yes, where and how do you get them (URL) ? b) What is (are) the program development environments (s) available for this language? and what is provided in each program development environment?

  • Using Python Programming Language: 3. Write a function flatten that takes a 2D list and returns...

    Using Python Programming Language: 3. Write a function flatten that takes a 2D list and returns all the items of each list concatenated together into one new 1D list. For example: flatten ([["a", "b"],["c","0"],["e","f"]]) would return ["a", "b","C","d", "e","f"] Save the function in a PyDev library module named functions.py Write a program t03.py that tests flatten function and prints the returned flat list to the screen. Test your program with a different list, hardcoded in t03.py • Copy the results...

  • Answer based on python (5 Pts.) What keyword is used to define a function in Python?...

    Answer based on python (5 Pts.) What keyword is used to define a function in Python? (5 Pts.) Where is the input/argument of a function placed when calling a function? (5 Pts.) Functions in Python can take 2 types of arguments: “*args” and “**kwargs”, what kind of code structures in Python can be inputted to a function as “**kwargs”?, circle one of the following choices: (Lists, Tuples, Dictionaries, Nested Lists) (5 Pts.) Functions in Python are capable of accomplishing 2...

  • USING PYTHON PROGRAMMING LANGUAGE CELSIUS FUNCTION: def convertF(fTemp): c = (fTemp - 32) * (5 / 9) print(fTemp, "F...

    USING PYTHON PROGRAMMING LANGUAGE CELSIUS FUNCTION: def convertF(fTemp): c = (fTemp - 32) * (5 / 9) print(fTemp, "Fahrenheit is equal to %.0f" % c, "Celsius.") fTemp = float(input("Enter Fahrenheit temp to convert: ")) convertF(fTemp) 2.3. Do you think Python will print anything different if you pass a floating point number to celsius? What would Python print for this expression? Explain >>>celsius(60.0) 24. Do you think the celsius function can deal with negative numbers? What will Python do with this...

  • Python Programming language Write the following functions: getNumInRange(prompt, min, max) - get...

    Python Programming language Write the following functions: getNumInRange(prompt, min, max) - gets a number from the user within the specified range, prompting with 'prompt' calcAvg(values) - calculates and returns the average from a supplied list of numeric values menu(somelist) - creates a numbered menu from a list of strings. Then, have the user select a valid choice (number), and return it. Use the getNumInRange() funtion to do this. getAlbum() - prompts the user for information to populate a dictionary representing...

  • Pascal programming language Implement a symbol balance checker function for the Pascal programming language. Pascal allows...

    Pascal programming language Implement a symbol balance checker function for the Pascal programming language. Pascal allows for the following pairs: {}, (), [], begin end . All programs will begin with the word "begin" and end with the word "end". Your function should receive an ifstream object which is already open and will return true, all of the symbols match, or false, they do not. You do not have to worry about comments in the program but you do have...

  • Question 1 The following function header represents which programming language? double calc_weekly_pay( double hours_worked, double pay_rate)...

    Question 1 The following function header represents which programming language? double calc_weekly_pay( double hours_worked, double pay_rate) Question 1 options: Python A C-based language FORTRAN COBOL Question 2 One of my favorite quotes from Jeanette Wind is "Computational thinking is using abstraction and decomposition when attacking a large complex task or designing a large complex system." This supports using _____________ when developing programs. Question 2 options: Repetition structures Assignment statements Selection structures Functions Question 3 The following assignment statement exhibits which...

  • please I need it urgent thanks. subject programming language and compilers w does not contain Question...

    please I need it urgent thanks. subject programming language and compilers w does not contain Question 2 Consider the following language over the alphabet = {a,b}: L = {w the substring aa} 1. What is I, the complement of L? 2. Write a regular expression for L. 3. Write a regular expression for L. 4. Design a DFA for I. 5. Modify the DFA for I to make it a DFA for L.

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT