Take a look at the snippet, and choose the true statements: (Select two answers)
Take a look at the snippet, and choose the true statements: (Select two answers) nums = [1, 2, 3] vals = nums del vals[1:2]A . 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...
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 AnswerAnswer: 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....
What is the output of the following snippet?
What is the output of the following snippet? dct = {} dct['1'] = (1, 2) dct['2'] = (2, 1) for x in dct.keys(): print(dct[x][1], end='')A . 21 B. (2,1) C. (1,2) D. 12View AnswerAnswer: 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 semanticsView AnswerAnswer: D Explanation: Topics: language alphabet lexis syntax semantics...
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...
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. 2View AnswerAnswer: D Explanation: Topics: logical operators...
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 AnswerAnswer: A,B Explanation: Topics: functions positional parameters keyword parameters Try it yourself: def fun(a, b, c=0):...
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[0] = 42 x = 3 y = [1, 2, 3] func(x, y) print(x, y[0])A . 3 1 B. The code is erroneous. C. 1 42 D. 3 42 E. 1 1View AnswerAnswer: D Explanation:...
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. 1View AnswerAnswer: C Explanation: Topics: if while break else...
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 2View AnswerAnswer: B Explanation: Topic: copying an immutable object by assigning...