💻
Programming Hard

Advanced Python and JavaScript Concepts

20 difficult programming questions and answers designed for true quiz masters on Python and JavaScript.

20 Questions
35s Per Question
0+ Plays
← All Programming Quizzes 📚 Study Guide for this category →
💡 Create account to save scores & earn XP
📋 View All 20 Questions & Answers

1. What is a 'generator' in Python?

  • A. A function that returns an iterator and yields values one at a time ✓
  • B. A function that returns a list
  • C. A type of class
  • D. A type of loop

💡 A generator is a special function that yields values one at a time, pausing its state between each yield.

2. What is a 'Promise' in JavaScript used for?

  • A. Handling asynchronous operations and their eventual completion or failure ✓
  • B. Styling webpages
  • C. Declaring variables
  • D. Creating loops

💡 A Promise represents the eventual completion or failure of an asynchronous operation and its resulting value.

3. What does 'this' refer to in a regular JavaScript function (non-arrow)?

  • A. It depends on how the function is called ✓
  • B. It always refers to the global object
  • C. It always refers to the function itself
  • D. It is always undefined

💡 The value of 'this' in a regular function is determined dynamically by how the function is called.

4. What is 'prototypal inheritance' in JavaScript?

  • A. Objects inheriting properties and methods directly from other objects via a prototype chain ✓
  • B. Objects inheriting only from classes
  • C. A type of loop
  • D. A CSS property

💡 In prototypal inheritance, objects inherit properties and methods directly from other objects through a prototype chain.

5. What is 'hoisting' in JavaScript?

  • A. The behavior of moving variable and function declarations to the top of their scope before execution ✓
  • B. Deleting variables
  • C. A type of loop
  • D. A sorting algorithm

💡 Hoisting is JavaScript's behavior of conceptually moving declarations to the top of their containing scope before code execution.

6. What is 'list comprehension' in Python used for?

  • A. Creating lists in a concise, readable way ✓
  • B. Deleting lists
  • C. Sorting lists only
  • D. Comparing lists

💡 List comprehension provides a concise syntax for creating lists based on existing iterables.

7. What does 'async function' return in JavaScript?

  • A. A Promise ✓
  • B. A callback
  • C. A string
  • D. An array

💡 An async function always returns a Promise, even if the function itself doesn't explicitly return one.

8. What does '**kwargs' allow in a Python function?

  • A. Passing a variable number of keyword arguments ✓
  • B. Passing positional arguments only
  • C. Passing exactly one argument
  • D. Passing no arguments

💡 '**kwargs' allows a function to accept any number of keyword arguments as a dictionary.

9. What does the 'spread operator' (...) do in JavaScript?

  • A. Expands an iterable into individual elements ✓
  • B. Combines two functions
  • C. Deletes an array
  • D. Compiles code

💡 The spread operator expands an iterable, like an array, into its individual elements.

10. What does 'strict mode' in JavaScript help with?

  • A. Catching common coding mistakes and preventing certain unsafe actions ✓
  • B. Making code run faster always
  • C. Styling webpages
  • D. Compiling code

💡 Strict mode enforces stricter parsing and error handling, helping catch common coding mistakes.

11. What is a 'decorator' in Python?

  • A. A function that modifies the behavior of another function ✓
  • B. A type of class
  • C. A sorting algorithm
  • D. A data structure

💡 A decorator wraps a function to modify or extend its behavior without changing its actual code.

12. What is a Python 'lambda' function?

  • A. An anonymous, inline function defined with the lambda keyword ✓
  • B. A named function
  • C. A class
  • D. A type of loop

💡 A lambda function is a small, anonymous function defined inline using the 'lambda' keyword.

13. What is a 'context manager' in Python, typically used with 'with'?

  • A. An object that defines the runtime context for executing a block of code ✓
  • B. A type of loop
  • C. A sorting algorithm
  • D. A data structure

💡 A context manager, used with the 'with' statement, defines setup and teardown behavior for a block of code.

14. What is 'currying' in JavaScript/functional programming?

  • A. Transforming a function with multiple arguments into a sequence of functions each taking a single argument ✓
  • B. Combining two functions into one
  • C. Deleting a function
  • D. A type of loop

💡 Currying transforms a function that takes multiple arguments into a sequence of functions, each taking one argument.

15. What is the 'event loop' in JavaScript responsible for?

  • A. Managing the execution of asynchronous code and callbacks ✓
  • B. Styling webpages
  • C. Compiling code
  • D. Managing databases

💡 The event loop manages the execution of asynchronous operations, callbacks, and tasks in JavaScript's single-threaded environment.

16. What is the difference between 'deep copy' and 'shallow copy' in Python?

  • A. A deep copy duplicates nested objects, while a shallow copy does not ✓
  • B. They are identical
  • C. A shallow copy duplicates nested objects, while a deep copy does not
  • D. Neither copies nested objects

💡 A deep copy recursively duplicates nested objects, while a shallow copy only copies the top-level structure.

17. What does '*args' allow in a Python function?

  • A. Passing a variable number of positional arguments ✓
  • B. Passing keyword arguments only
  • C. Passing exactly one argument
  • D. Passing no arguments

💡 '*args' allows a function to accept any number of positional arguments.

18. What does 'GIL' stand for in Python?

  • A. Global Interpreter Lock ✓
  • B. General Interface Language
  • C. Global Instance Loop
  • D. General Iteration Logic

💡 GIL stands for Global Interpreter Lock, a mutex that prevents multiple threads from executing Python bytecode simultaneously.

19. What is 'duck typing' in Python?

  • A. Determining an object's suitability based on the presence of certain methods and properties, rather than its type ✓
  • B. Strict type checking
  • C. A sorting algorithm
  • D. A data structure

💡 Duck typing focuses on what an object can do (its methods and behavior) rather than its explicit type.

20. What is a 'closure' in JavaScript?

  • A. A function that retains access to its outer scope even after the outer function has finished executing ✓
  • B. A type of loop
  • C. A CSS property
  • D. A data type

💡 A closure is a function that 'remembers' the variables from its enclosing scope, even after that scope has finished executing.

More Programming Quizzes

View all Programming quizzes →