Podcast
Questions and Answers
Which of the following is the correct syntax for passing an object 'obj' as an argument in a Python function?
Which of the following is the correct syntax for passing an object 'obj' as an argument in a Python function?
- function obj()
- function(obj) (correct)
- function(obj) (correct)
- function obj
What happens if a mutable object is passed as an argument to a function and is modified within the function?
What happens if a mutable object is passed as an argument to a function and is modified within the function?
- The function will return an error
- The original object is modified (correct)
- A new object is created with the modified values
- The object will be deleted
What is the difference between passing an object by value and passing an object by reference?
What is the difference between passing an object by value and passing an object by reference?
- There is no difference between the two
- Passing by value creates a copy of the object, while passing by reference does not (correct)
- Passing by value is faster than passing by reference
- Passing by reference creates a copy of the object, while passing by value does not
Flashcards are hidden until you start studying