Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please include an explanation to each correct option. Won\'t take ton of your ti

ID: 3716229 • Letter: P

Question

Please include an explanation to each correct option. Won't take ton of your time. Thanks :)

20. When passing arguments (variables) to a function, they are matched by:
a. Values
b. The order in which the arguments are written
c. Variable names
d. Variable types

21. The arguments (variables) returned by a function are matched by:
a. Order of the variables
b. Variable Types
c. Variable names
d. Values

28. When testing equality of two floating point values, we should be careful because:

a. We must convert floating points to integers before testing their equality
b. It is not possible to test their equality
c. Floating point values are rarely exactly equal and we should allow for a round off error.


31. Consider the following code:
if (test 1):
# code block 1
if (test 2):
# code block 2
if (test 3):
# code block 3
  
Which one of the following statements is correct.
a. It is possible that code block 2 executes and code block 1 does not execute
b. It is possible that only code block 2 and 3 execute
c. Code block 3 will execute only if all three tests are passed/True.
d. If test 1 is False, test 2 and test 3 will still be checked.

Explanation / Answer

Ans: c. Variable names

Explanation: In python, the order of argument doesn't matters, neither the type of value that is being passed in the function

Ans: a. Order of the variables

Explanation: In python, we can return any value as there is no datatype required. It can be collected in any variable as no datatype is explicitly mentioned with a variable.

Ans: a. We must convert floating points to integers before testing their equality

Explanation: It is likely that the when the floating point number is converted to its binary equivalent for comparison, both the numbers will result same. So its better to convert the number to the integer type.

Ans: c. Code block 3 will execute only if all three tests are passed/True.

Explanation: If the outer if blocks are true then only the control will be passed to the inner conditions. Hence in that case only option C follows