Take a look at the snippet, and choose the true statements: (Select two answers) nums = vals = nums del valsA . nums is longer than vals B. nums and vals refer to the same list C. vals is longer than nums D. nums and vals are of the same length...
What will be the output of the following code snippet?
What will be the output of the following code snippet? print(3 / 5)A . 6/10 B. 0.6 C. 0 D. None of the above. View Answer Answer: B Explanation: Topic: division operator Try it yourself: print(3 / 5) # 0.6 print(4 / 2) # 2.0 The division operator does its normal job. And remember...
What is the output of the following snippet?
What is the output of the following snippet? dct = {} dct = (1, 2) dct = (2, 1) for x in dct.keys(): print(dct, end=”)A . 21 B. (2,1) C. (1,2) D. 12 View Answer Answer: A Explanation: Topics: dictionary tuple indexing for dict.keys() print() Try it yourself: dct = {} dct = (1,...
What are the four fundamental elements that make a language?
What are the four fundamental elements that make a language?A . An alphabet, phonetics, phonology, and semantics B. An alphabet, a lexis, phonetics, and semantics C. An alphabet, morphology, phonetics, and semantics D. An alphabet, a lexis, a syntax, and semantics View Answer Answer: D Explanation: Topics: language alphabet lexis syntax semantics We can...
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. 1 View Answer Answer: D Explanation: Topics: def conditional expression (if else) modulus operator not equal to operator Try it yourself: def...
What is the output of the following code?
What is the output of the following code? a = 1 b = 0 x = a or b y = not(a and b) print(x + y)A . The program will cause an error B. 1 C. The output cannot be predicted D. 2 View Answer Answer: D Explanation: Topics: logical operators booleans addition...
Which of the following lines correctly invoke the function defined below:
Which of the following lines correctly invoke the function defined below: def fun(a, b, c=0): # Body of the function. (Select two answers)A . fun(0, 1, 2) B. fun(b=0, a=0) C. fun(b=1) D. fun() View Answer Answer: A,B Explanation: Topics: functions positional parameters keyword parameters Try it yourself: def fun(a, b, c=0): # Body...
What is the expected output of the following code?
What is the expected output of the following code? def func(p1, p2): p1 = 1 p2 = 42 x = 3 y = func(x, y) print(x, y)A . 3 1 B. The code is erroneous. C. 1 42 D. 3 42 E. 1 1 View Answer Answer: D Explanation: Topics: def...
How many stars will the following snippet print to the monitor?
How many stars will the following snippet print to the monitor? i = 4 while i > 0: i -= 2 print(‘*’) if i == 2: break else: print(‘*’) The snippet will enter an infinite loop.A . 0 B. 2 C. 1 View Answer Answer: C Explanation: Topics: if while break else (nobreak) Try...
What will be the output of the following code snippet?
What will be the output of the following code snippet? x = 1 y = 2 z = x x = y y = z print (x, y)A . 1 2 B. 2 1 C. 1 1 D. 2 2 View Answer Answer: B Explanation: Topic: copying an immutable object by assigning Try it...