Skip to content

Latest commit

 

History

History
74 lines (38 loc) · 1.28 KB

multiple_choice.md

File metadata and controls

74 lines (38 loc) · 1.28 KB

6 multiple-choice questions. The correct answer is marked with an arrow ('->')


Q1. What is the key difference between a list and a tuple?

-> (a) Lists are mutable, but tuples are immutable objects

(b) Lists can be recursive, but tuples cannot be

(c) Lists are mutable, but tuples are immutable strings

Q2. What should the below be called to setup a new object?

class Student:
    def (self, name):
        self.name = name

-> (a) __init__

(b) __init

(c) __main__

(d) __construct__

Q3. What is the syntax for slicing?

(a) [start : step : stop]

(b) [stop : start : step]

-> (c) [start : stop : step]

(d) [step : start : stop]

Q4. Decorators in Python are able to accept arguments for functions and modify them.

-> (a) true

(b) false

Q5. What is the below code an example of?

mylist = [1, 2, 3, 4]
squared = [x**2 for x in mylist]

(a) list expansion

-> (b) list comprehension

(c) list updating

(d) list rolling

Q6. What is a lambda used for in Python?

-> (a) It is an anonymous function

(b) It is a math module function

(c) It is an anonymous function that can only accept a single argument

(d) It is an anonymous function that can be called only once the program begins