Question: PYTHON MULTI CHOICE 1) What is wrong with the following code snippet? mystery(10, 2) def mystery(num1, num2): result = num1 ** num2 return result nothing,

PYTHON MULTI CHOICE

1) What is wrong with the following code snippet?

mystery(10, 2) def mystery(num1, num2): result = num1 ** num2 return result

nothing, it will return 20

nothing, it will return 100

a variable must be used to store the result of the function call
the function must be defined before the statement that calls it

2) Consider this function definition:

def some_rec_func(n): if (n < 0): return -1 return some_rec_func(n + 1) 

This function has the following problem -- or none (only one correct choice):

It will always produce an infinite recursive call to itself resulting in a run-time error.

It will always return the same number no matter what is passed in as an argument from the main function.

Nothing is wrong;

It will sometimes return a -1 without error, and other times produce an infinite recursive call to itself resulting in a run-time error.

3) Which are true about instance variables (attributes) of a class

(check all that apply):

They should usually be defined and assigned in the __init__() method (constructor) of that class.

They should be private so that only the objects methods can directly access them. This protects the objects data attributes from accidental corruption.

Member instance methods of the same class must use self. (or, whatever the first formal parameter is, followed by the dot) before their names in order to access them.

The statements

card1 = "hi mom" card2 = 3 card3 = Card() my_card = card3 card1 = Card() 

will cause how many Card objects to be instantiated? (only one correct choice):

1
2
3
4
none

4) A mutator's job is to (check all that apply):

protect instance or class data

return the value of the mutator's associated member data to the client.

set value(s) of data as requested by the client, if the value(s) the client supplies (supply) is (are) deemed acceptable by the class designer.

print errors if bad data is passed.

5) Which statements are true about the built-in Python tuple data type?

(check all the are true)

- tuples are mutable.

- Elements of a tuple can themselves be mutable types.

- If some_var is a tuple that has exactly 10 items in it, the following two variable names reference the same object:

some_var[8]

and

some_var[-2]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!