Question
Please explain as well, thanks: 1) Which of the following is not a data type in Python? a. float b. string c. tuple d. slice
Please explain as well, thanks:
1) Which of the following is not a data type in Python?
a. float
b. string
c. tuple
d. slice
2) Consider the Python code below
x = ['dog', 'cat'] y = [1,2,3,4] z = [(2,2),(2,4)]
Which of the following statements is correct?
a. x is a list, y is an array, z is a list of arrays
b. x is a list, y is an array, z is a two-dimensional array
c. x, y, and z are all lists
3) Consider the Python code below
a=[[1,2,3],[4,5,6],[7,8,9]] a[2]
What is the correct output? Try to answer without running the code.
a. [4,5,6]
b. 2
c. 3
d. [7,8,9]
4) Suppose that x is a variable that holds a positive number and you want to write a block of code which displays "Fail" if x is less than 50 and "Pass" if x
is greater than or equal to 50. Which of the following code is correct? Try to answer without running the code.
A
if x < 50: print("Fail") if x >= 50: print("Pass")
B
if x < 50: print("Fail") else: print("Pass")
C
if x < 50: print("Fail") elif x >= 50: print("Pass")
D
if x < 50: print("Fail") elif x == 50: print("Pass") elif x > 50: print("Pass")
a. A and B
b. B
c. B,C and D
d. A,B,C and D
5) What is the output of the following code? Try to give the correct answer without running the code.
def my_func(a, b): a = 1 b[0] = 10 number = 5 list = [1,2,3] my_func(number, list) print(number, list[0])
a. 5 1
b. 5 10
c. 1 10
d. 1 1
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started