What is the expected output of the following code?

What is the expected output of the following code? data = ['Peter', 404, 3.03, 'Wellert', 33.3] print(data[1:3])A . None of the above. B. ['Peter', 404, 3.03, 'Wellert', 33.3] C. ['Peter', 'Wellert'] D. [404, 3.03]View AnswerAnswer: D Explanation: Topic: list indexing Try it yourself: data = ['Peter', 404, 3.03, 'Wellert', 33.3]...

November 6, 2022 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...

November 6, 2022 No Comments READ MORE +

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...

November 6, 2022 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

November 6, 2022 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...

November 5, 2022 No Comments READ MORE +

Assuming that the tuple is a correctly created tuple,

Assuming that the tuple is a correctly created tuple, the fact that tuples are immutable means that the following instruction: my_tuple[1] = my_tuple[1] + my_tuple[0]A . can be executed if and only if the tuple contains at least two elements B. is illegal C. may be illegal if the tuple...

November 4, 2022 No Comments READ MORE +

Which of the following expressions is equivalent to the expression in the function?

You develop a Python application for your company. You have the following code. def main(a, b, c, d): value = a + b * c - d return value Which of the following expressions is equivalent to the expression in the function?A . (a + b) * (c - d)...

November 4, 2022 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...

November 4, 2022 No Comments READ MORE +

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...

November 3, 2022 No Comments READ MORE +

The digraph written as #! is used to:

The digraph written as #! is used to:A . tell a Unix or Unix-like OS how to execute the contents of a Python file. B. create a docstring. C. make a particular module entity a private one. D. tell an MS Windows OS how to execute the contents of a...

November 3, 2022 No Comments READ MORE +