What will happen when you attempt to run the following code?
What will happen when you attempt to run the following code? print(Hello, World!)A . The code will raise the SyntaxError exception. B. The code will raise the TypeError exception. C. The code will raise the ValueError exception. D. The code will print Hello, World! to the console. E. The code...
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...
that does not explicitly return any value?
What is the default return value for a function that does not explicitly return any value?A . int B. void C. None D. Null E. publicView AnswerAnswer: C Explanation: Topic: return Try it yourself: def func1(): pass print(func1()) # None def func2(): return print(func2()) # None If a function does...
The result of the following addition:
The result of the following addition: 123 + 0.0A . cannot be evaluated B. is equal to 123.0 C. is equal to 123View AnswerAnswer: B Explanation: Topics: addition operator integer float Try it yourself: print(123 + 0.0) # 123.0 If you have an arithmetic operation with a float, the result...
What is the expected output of the following code?
What is the expected output of the following code? def func(num): res = '*' for _ in range(num): res += res return res for x in func(2): print(x, end='')A . ** B. The code is erroneous. C. * D. ****View AnswerAnswer: D Explanation: Topics: def return for Try it yourself:...
What should you insert instead of XXX, YYY and ZZZ?
The ABC organics company needs a simple program that their call center will use to enter survey data for a new coffee variety. The program must accept input and return the average rating based on a five-star scale. The output must be rounded to two decimal places. You need to...
Python is an example of:
Python is an example of:A . a machine language B. a high-level programming language C. a natural languageView AnswerAnswer: B Explanation: Topic: high-level programming language https://en.wikipedia.org/wiki/Python_(programming_language)
What do you call a tool that lets you lanch your code step-by-step and inspect it at each moment of execution?
What do you call a tool that lets you lanch your code step-by-step and inspect it at each moment of execution?A . A debugger B. An editor C. A consoleView AnswerAnswer: A Explanation: Topic: debugger https://en.wikipedia.org/wiki/Debugger
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? 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']...