Question: The following is in Python language, any help would be appreciated, thank you! 1. What is the output of the following code? x = 3
The following is in Python language, any help would be appreciated, thank you!
1. What is the output of the following code? x = 3 def change(): global x y = 2 x = y * 2 change() print(x)
2. Write a function that takes an arbitrary number of arguments and returns the average of them.
3. Which function creates a file object?
Select one:
a. open()
b. file()
c. create_file()
d. object(type='file')
4. Write a statement that opens the file 'final.txt' in append mode and assigns it to my_file.
5. Using the os module, write a statement that would delete the file 'final.txt'. *You may assume that the os module has already been imported.
6. What list contains command line arguments? Besure to include the module name in your response. For example: module.list_name
7. What is a module?
8. A module being required by another script is often called a _________
9. Write an import statement that only imports the print_hello() and print_goodbye() functions from the module messages.
10. A package is a directory that, when imported, gives access to all of the modules stored in the directory. True or False?
11. A try block can have multiple exception handlers. True or False?
12. Code that detects an error can execute a ________ statement
13. If a finally clause is present, when does it execute?
Select one or more:
a. If no exception occurs
b. If a handled exception occurs
c. If an unhandled exception occurs
d. If any break, continue, or return statement causes the try block to be exited
14. Code that may produce an exception is placed in a ____ block.
15. If the code in a try block causes an exception, then the code placed in a following _______ block is executed.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
