55284A: Introduction to Python Quiz Questions and Answers

Answer :
  • "Done " followed by "Nothing is wrong " followed by "Finally we are here "

Explanation :

"Done" will get print as there is no error in code. Then "Nothing is wrong" will print as this print statement is under the else block which will get executed when there is no error and then "Finally we are here" will get printed because "finally" block w
Answer :
  • Syntax Error

Explanation :

This is an example of inner function in which a function is defined inside the body of other function. Two return statements are used in the outer function, so the second return statement will get the value returned by previous return statement of the out
Answer :
  • Parentheses

Explanation :

Just remember: PEMDAS, that is, Parenthesis, Exponentiation, Division, Multiplication, Addition, Subtraction. Note that the precedence order of Division and Multiplication is the same. Likewise, the order of Addition and Subtraction is also the same.
Answer :
  • 2

Explanation :

We use the seed function when we want to use the same random number once again in our program. Hence the output of the code shown above will be 2, since 2 was generated previously following which we used the seed function.
Answer :
  • It is executed fine and no exception is raised, and it returns None.

Explanation :

This get() function of the dictionary will return value for the key specified. If key does not exists then it will return None. It will return an optional value if specified while calling in case when key is not found.
Answer :
  • 3

Explanation :

 In Python the precedence order is first NOT then AND and in last OR. So the if condition and second elif condition evaluates to False while third elif condition is evaluated to be True resulting in 3 as output.
Answer :
  • (8, 7)

Explanation :

This function call will return a tuple and that whole tuple will be stored in a variable. If you would have used two variables to store the result then each variable would have get each value from the function.
Answer :
  • [44, 2, 3]

Explanation :

When function is being called with the list as parameter in it, the function 0th index is being updated. It is possible because list is a mutable object which will get update after the function will be called.