What is the expected output of the following code?
What is the expected output of the following code? print(list('hello'))A . None of the above. B. hello C. [h, e, l, l, o] D. ['h', 'e', 'l', 'l', 'o'] E. ['h' 'e' 'l' 'l' 'o']View AnswerAnswer: D Explanation: Topic: list() Try it yourself: print(list('hello')) # ['h', 'e', 'l', 'l', 'o']...
Which of the following for loops would output the below number pattern?
Which of the following for loops would output the below number pattern? 11111 22222 33333 44444 55555A . for i in range(0, 5): print(str(i) * 5) B. for i in range(1, 6): print(str(i) * 5) C. for i in range(1, 6): print(i, i, i, i, i) D. for i in...
What is CPython?
What is CPython?A . It' a programming language that is a superset of the C language, B. designed to produce Python-like performance with code written in C C. It' a programming language that is a superset of the Python, D. designed to produce C-like performance with code written in Python...
What is the expected behavior of the following program?
What is the expected behavior of the following program? try: print(5/0) break except: print("Sorry, something went wrong...") except (ValueError, ZeroDivisionError): print("Too bad...")A . The program will cause a SyntaxError exception. B. The program will cause a ValueError exception and output the following message: Too bad... C. The program will cause...
if ???
What would you insert instead of so that the program checks for even numbers? if ???: print('x is an even number')A . x % x == 0 B. x % 1 == 2 C. x % 2 == 0 D. x % 'even' == True E. x % 2 ==...
What is the expected output of the following code?
What is the expected output of the following code? x = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]] def func(data): res = data[0][0] for da in data: for d in da: if res < d: res = d return res print(func(x[0]))A . The code is erroneous. B. 8 C....
The value thirty point eleven times ten raised to the power of nine should be written as:
The value thirty point eleven times ten raised to the power of nine should be written as:A . 30.11E9 B. 30E11.9 C. 30.11E9.0 D. 30.11*10^9View AnswerAnswer: A Explanation: Topic: scientific notation Try it yourself: print(30.11E9) # 30110000000.0 # print(30E11.9) # SyntaxError: invalid syntax # print(30.11E9.0) # SyntaxError: invalid syntax #...
What is the expected output of the following code if the user enters 2 and 4?
What is the expected output of the following code if the user enters 2 and 4? x = input() y = input() print(x + y)A . 4 B. 6 C. 24 D. 2View AnswerAnswer: C Explanation: Topics: input() plus operator string concatenation Try it yourself: # x = input() #...
What is the expected output of the following code?
What is the expected output of the following code? x = [0, 1, 2] x.insert(0, 1) del x[1] print(sum(x))A . 3 B. 2 C. 4 D. 5View AnswerAnswer: C Explanation: Topics: insert() del sum() list Try it yourself: x = [0, 1, 2] x.insert(0, 1) print(x) # [1, 0, 1,...
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...