Which of the following is not a Python keyword? a) and b) try c) exception d) class Ans: c) exception
What does the Python keyword “lambda” do? a) creates a new function b) defines a loop c) raises an exception d) defines a class Ans: a) creates a new function
What is the purpose of the Python keyword “yield”? a) defines a variable b) creates a new object c) returns a value from a function d) defines a loop Ans: c) returns a value from a function
Which Python keyword is used to define a block of code? a) for b) if c) while d) def Ans: d) def
Which Python keyword is used to define a branching statement? a) for b) if c) while d) def Ans: b) if
What is the Python keyword “global” used for? a) to define a variable outside of a function b) to define a variable inside of a function c) to define a function inside of a class d) to define a class outside of a module Ans: b) to define a variable inside of a function
Which Python keyword is used to define a loop that iterates over a sequence? a) for b) if c) while d) def Ans: a) for
Which Python keyword is used to stop a loop prematurely? a) continue b) break c) pass d) yield Ans: b) break
Which Python keyword is used to define a function? a) for b) if c) while d) def Ans: d) def
Which Python keyword is used to define a logical operator that returns true if either of its operands is true? a) not b) and c) or d) xor Ans: c) or
Which of the following is a Python keyword? a) for b) foreach |c) repeat d) do Answer: a) for
Which of the following is a Python keyword? a) start b) begin c) in d) process Answer: c) in
Which of the following is a Python keyword used for defining a function? a) def b) fun c) func d) function Answer: a) def
Which of the following is a Python keyword used for conditional statements? a) case b) if c) switch d) when Answer: b) if
Which of the following is a Python keyword used for defining a class? a) class b) def c) function d) module Answer: a) class
Which of the following is a Python keyword used for defining a counting loop? a) for b) loop c) iterate d) while Answer: a) for
Which of the following is a Python keyword used for defining a variable? a) var b) let c) const d) all of the above Answer: d) all of the above
Which of the following is a Python keyword used for importing modules? a) require b) from c) import d) include Answer: c) import
Which of the following is a Python keyword used for exiting a loop? a) exit b) end c) break d) continue Answer: c) break
Which of the following is a Python keyword used for continuing a loop? a) skip b) end c) break d) continue Answer: d) continue
Which of the following is a Python keyword used for defining a try-except block? a) catch b) except c) try d) both b and c Answer: d) both b and c
Which of the following is a Python keyword used for defining a dictionary? a) map b) dict c) set d) hash Answer: b) dict
Which of the following is a Python keyword used for defining a list? a) array b) list c) tuple d) set Answer: b) list
Which of the following is a Python keyword used for defining a set? a) map b) dict c) set d) hash Answer: c) set
Which of the following is a Python keyword used for defining a tuple? a) array b) list c) tuple d) set Answer: c) tuple
Which of the following is a Python keyword used for defining a generator? a) def b) generator c) yield d) return Answer: c) yield
Which of the following is a Python keyword used for defining an iterator? a) def b) iterator c) yield d) return Answer: c) yield
Which of the following is a Python keyword used for defining a lambda function? a) func b) lambda c) def d) function Answer: b) lambda
Which of the following is a Python keyword used for defining a module? a) library b) package c) module d) import Answer: c) module
Which of the following is a Python keyword used for defining a namespace? a) namespace b) package c) module d) import Answer: d) import
Which of the following is a Python keyword used for defining a function? a) define b) def c) function d) func Answer: b) def
Which of the following is a Python keyword used for creating a class? a) class b) new c) create d) instance Answer: a) class
Which of the following is a Python keyword used for conditional branching? a) case b) switch c) if d) when Answer: c) if
Which of the following is a Python keyword used for looping over a sequence of items? a) while b) until c) foreach d) for Answer: d) for
Which of the following is a Python keyword used for breaking out of a loop? a) halt b) stop c) break d) exit Answer: c) break
Which of the following is a Python keyword used for continuing to the next iteration of a loop? a) skip b) next c) continue d) go Answer: c) continue
Which of the following is a Python keyword used for defining a block of code to be executed in an exception handling context? a) try b) except c) catch d) handle Answer: a) try
Which of the following is a Python keyword used for specifying a block of code to be executed when an exception is raised? a) try b) except c) catch d) handle Answer: b) except
Which of the following is a Python keyword used for defining a block of code to be executed regardless of whether an exception has been raised or not? a) try b) except c) finally d) always Answer: c) finally
Which of the following is a Python keyword used for defining a variable with a constant value? a) const b) var c) let d) None of the above Answer: d) None of the above
Which of the following is a Python keyword used for defining a function that returns a value? a) return b) yield c) continue d) break Answer: a) return
Which of the following is a Python keyword used for defining a function that doesn’t return a value? a) return b) yield c) continue d) None of the above Answer: d) None of the above
Which of the following is a Python keyword used for defining a function with default arguments? a) default b) def c) function d) None of the above Answer: b) def
Which of the following is a Python keyword used for defining a function with variable-length arguments? a) vararg b) args c) kwargs d) None of the above Answer: b) args
Which of the following is a Python keyword used for defining a function with keyword arguments? a) kwargs b) args c) vararg d) None of the above Answer: a) kwargs
Which of the following is a Python keyword used for defining a function with both variable-length and keyword arguments? a) args b) kwargs c) vararg d) None of the above Answer: c) vararg
Which of the following is a Python keyword used for defining a function that accepts any number of arguments? a) varargs b) args c) kwargs d) None of the above Answer: a) varargs
Which of the following is a Python keyword used for defining a context manager? a) context b) with c) yield d) None of the above Answer: b) with
Which of the following is a Python keyword used for defining a decorator function? a) decorator b) wrapper c) decorate d) None of the above Answer: d) None of the above (decorators are defined using the @ symbol)
Which of the following is a Python keyword used for defining a loop that executes until a certain condition is met? a) while b) for c) if d) None of the above Answer: a) while