Font size
WorksheetsBertelsmann AI Track Quiz Initiative #3
Total questions: 20
Worksheet time: 20mins
What is the difference between list and tuples in Python? Choose all correct answers
Lists are mutable i.e they can be edited.
Tuples are mutable i.e they can be edited.
Tuples are immutable (tuples are lists which can’t be edited).
Lists are immutable (Lists are array which can’t be edited).
What are the key features of Python? Choose all correct answers
Python is a compiled language. That means that, like languages like C and its variants, Python does need to be compiled before it is run.
Python is dynamically typed, this means that you don’t need to state the types of variables when you declare them or anything like that.
Python is well suited to object-orientated programming in that it allows the definition of classes along with composition and inheritance.
In Python, functions are first-class objects. This means that they can be assigned to variables, returned from other functions and passed into functions.
How is memory managed in Python? Choose all correct answers
Memory management in python is managed by Python private heap space
Memory management in python is managed by Python private stack space
Python also has an inbuilt garbage collector which recycles all the unused memory
Memory allocation have to be managed by the programmer
Which data types are natively supported in Python? Choose all correct answers
Numbers
Strings
Tensors
Dictionaries
A = "Bertelsman"
B = "Scholarship"
B = A.join(B)
What is the value of B?
Bertelsman Scholarship
BertelsmanScholarship
Scholarship
Error because string is immutable
r = lambda q: q * 2
s = lambda q: q * 3
x = 2
x = r(x)
x = s(x)
x = r(x)
print (x)
What's printed in the console?
6
12
24
48
a = 4.5
b = 2
print (a//b)
What's printed in the console?
0
1.0
1.5
2.0
stg='XYZ'
A=len(stg)
B=stg[0]
print(A,B)
What's printed to the console?
3 X
3 Y
4 X
4 Y
How to modify python array? Choose all correct answers
pop()
slice()
push()
append()
a="Udacity Course"
print(a.split())
What's printed on the console?
["Udacity ", "Course"]
["Udacity", "Course"]
["Udacity Course", ""]
[]
How to import modules in python? Choose all correct answers
import array
import array as arr
from array import *
import * from array
Which library below used for Machine Learning in python? Choose all correct answers
PyTorch
mlpack
Tensorflow
Keras
Which of the following is an invalid statement?
abc = 1,000,000
a,b,c = 1000, 2000, 3000
a b c = 1000 2000 3000
a_b_c = 1,000,000
What are the principal differences between the lambda and def?
Def can hold multiple expressions while lambda is a uni-expression function
Lambda can hold multiple expressions while def is a uni-expression function
Def can have a return statement. Lambda can’t have return statements.
Lambda can have a return statement. Def can’t have return statements.
What does the **kwargs do in Python?
It let us pass N (variable) number of arguments which can be named or keyworded
It gives us the ability to pass N (variable) number of arguments.
Which library below is used to plot a chart in python? Choose all correct answers
Plotly
D3
Matplotlib
Seaborn
Which library below is used to calculate linear algebra except for Numpy? Choose all correct answers
Pandas
PyTorch
Tensorflow
Sympy
import numpy as np
arr = np.array([1, 3, 2, 4, 5])
print(arr.argsort()[-3:][::-1])
What's printed in console?
[4 3 1]
[3 1 2]
[1 3 2]
[3 5 4]
fruits = ["apple", "banana", "cherry"]
newlist = [x for x in fruits if "a" in x]
What this operation is called?
Inline loop
List comprehension
Array spread operation
Conditional array
import math
all([bool(x) for x in [0, 1.2, 0.5, math.inf, math.nan]])
What's the result of the code snippet above?
True
False
