SchoolWhool
Quizzes and saved progress, freeSign in freeSign in
Python · Module 1Module material

Jupyter and Python basics interview questions

25 questions interviewers ask on getting started, from first principles to the follow-ups. The first 3 model answers are free to read; Pro opens the rest.

Python and notebooks

  1. Is Python compiled or interpreted?●

    Interpreted, in the usual sense. CPython, the standard implementation, compiles source code to bytecode and then its interpreter executes that bytecode one instruction at a time. There is no separate compile step for the programmer to run.

  2. What is the difference between Python 2 and Python 3 that you are most likely to notice?●

    print is a function in Python 3: print("hello"). Python 2's print "hello" gives SyntaxError: Missing parentheses in call to 'print'. Python 2 reached end of life in 2020, so new code is Python 3.

  3. What is the difference between a statement and an expression?●

    A statement is one instruction, such as the assignment total = 2.25 + 1.25. An expression is any piece of code that evaluates to a value, such as 2.25 + 1.25 on the right of it. An expression can stand alone as a statement, which is why a notebook cell whose last line is 2.25 + 1.25 + 3.50 displays 7.0; an assignment has no value, so a cell ending in one displays nothing.

  4. In a Jupyter notebook, why can a cell that worked earlier fail after a restart, and what do you do about it?●●

Variables and types

  1. Is Python statically or dynamically typed? Is it strongly or weakly typed?●
  2. What actually happens in x = 5?●●
  3. What is the difference between is and ==?●●
  4. Are integers mutable? What does x += 1 do to the object?●●
  5. How do you swap two variables in Python?●
  6. What is None, and how do you check for it?●
  7. Can you name a variable list? Should you?●●
  8. What are type annotations, and does Python enforce them?●●

Conversion and truthiness

  1. What does input() return?●
  2. Which values are falsy in Python?●●
  3. What is the difference between int(2.9) and round(2.9)?●●
  4. Why is "10" > "9" False?●●

Operators

  1. What is the difference between / and //?●
  2. What is -7 // 2, and -7 % 2? Why?●●
  3. What do 2 ** 3 ** 2 and -2 ** 2 evaluate to?●●
  4. Why is 0.1 + 0.2 == 0.3 False, and how should you compare floats?●●
  5. What do and and or return?●●
  6. What is True + True?●●

Formatting

  1. What does print return? What do its sep and end arguments do?●
  2. How do you print a number with two decimal places and a thousands separator?●
  3. What does f"{x=}" do?●●