Which of the following statements are true? (Select two answers)

Which of the following statements are true? (Select two answers)A . The ** operator uses right-sided binding. B. The result of the / operator is always an integer value. C. The right argument of the % operator cannot be zero. D. Addition precedes multiplication.View AnswerAnswer: B,D Explanation: Topics: exponentiation/power operator...

April 19, 2023 No Comments READ MORE +

What is the expected output of the following code?

What is the expected output of the following code? z = y = x = 1 print(x, y, z, sep='*')A . x*y*z B. 111* C. x y z D. 1*1*1 E. 1 1 1 F. The code is erroneous.View AnswerAnswer: D Explanation: Topic: multiple assignment print() with sep parameter Try...

April 19, 2023 No Comments READ MORE +

A function definition starts with the keyword:

A function definition starts with the keyword:A . def B. function C. funView AnswerAnswer: A Explanation: Topic: def Try it yourself: def my_first_function(): print('Hello') my_first_function() # Hello https://www.w3schools.com/python/python_functions.asp

April 19, 2023 No Comments READ MORE +

Which of the following variable names are illegal? (Select two answers)

Which of the following variable names are illegal? (Select two answers)A . TRUE B. True C. true D. andView AnswerAnswer: B, D Explanation: Topics: variable names keywords True and Try it yourself: TRUE = 23 true = 42 # True = 7  # SyntaxError: cannot assign to True # and...

April 18, 2023 No Comments READ MORE +

What is the expected output of the following code?

What is the expected output of the following code? num = 1 def func(): num = num + 3 print(num) func() print(num)A . 4 1 B. 4 4 C. The code is erroneous. D. 1 4 E. 1 1View AnswerAnswer: C Explanation: Topics: def shadowing Try it yourself: num =...

April 17, 2023 No Comments READ MORE +

Strings in Python are delimited with:

Strings in Python are delimited with:A . backslashes (i.e., ) B. double quotes (i.e., ") or single quotes (i.e., ') C. asterisks (i.e., *) D. dollar symbol (i.e., $)View AnswerAnswer: B Explanation: Topics: strings quotes Try it yourself: print("Hello") # Hello print('World') # World Unlike in other programming languages, in...

April 17, 2023 No Comments READ MORE +

Which of the variables will contain False?

Consider the following code snippet: w = bool(23) x = bool('') y = bool(' ') z = bool([False]) Which of the variables will contain False?A . z B. x C. y D. wView AnswerAnswer: B Explanation: Topic: type casting with bool() Try it yourself: print(bool(23)) # True print(bool('')) # False...

April 16, 2023 No Comments READ MORE +

What is the expected output of the following code?

What is the expected output of the following code? list1 = [1, 3] list2 = list1 list1[0] = 4 print(list2)A . [1, 4] B. [4, 3] C. [1, 3, 4] D. [1, 3]View AnswerAnswer: B Explanation: Topics: list reference of a mutable data type Try it yourself: list1 = [1,...

April 16, 2023 No Comments READ MORE +

What is the expected output of the following code?

What is the expected output of the following code? x = True y = False z = False if not x or y: print(1) elif not x or not y and z: print(2) elif not x or y or not y and x: print(3) else: print(4)A . 4 B. 3...

April 16, 2023 No Comments READ MORE +

What is the expected output of the following code?

What is the expected output of the following code? def func(x): return 1 if x % 2 != 0 else 2 print(func(func(1)))A . The code is erroneous. B. None C. 2 D. 1View AnswerAnswer: D Explanation: Topics: def conditional expression (if else) modulus operator not equal to operator Try it...

April 15, 2023 No Comments READ MORE +