1 of 2

Python Interview Questions – Variables & Data Types

1. [Asked in Microsoft] What are the different data types in Python?

Answer:

  • int (Integer)
  • float (Floating point)
  • str (String)
  • bool (Boolean)
  • list (List)
  • tuple (Tuple)
  • dict (Dictionary)
  • set (Set)

2. [Asked in Google] How to check the data type of a variable?

Answer: Using type() function. Example:

x = 10

print(type(x))  # Output: <class 'int'>

3. [Asked in Amazon] What is the difference between mutable and immutable objects?

Answer:

  • Mutable objects can be changed (e.g., list, dict, set).
  • Immutable objects cannot be changed (e.g., int, float, str, tuple).

4. [Asked in Flipkart] What is type conversion in Python?

Answer: Changing the type of a variable explicitly using functions like int(), float(), str(), etc.


5. [Asked in Paytm] What is the difference between is and == operators?

Answer:

  • == checks for value equality.
  • is checks if two objects refer to the same memory location.

6. [Asked in Ola] How to take user input in Python?

Answer: Using the input() function. Example:

name = input("Enter your name: ")

print("Hello, " + name)

7. [Asked in Swiggy] How to convert a string to an integer in Python?

Answer: Using int(). Example:

num = int("10")

print(num)  # Output: 10

8. [Asked in Razorpay] What is the difference between list and tuple?

Answer:

  • List: Mutable, defined using [].
  • Tuple: Immutable, defined using ().

9. [Asked in Freshworks] How to declare multiple variables in one line?

Answer:

a, b, c = 10, 20, “Python”


10. [Asked in Zoho] What is None in Python?

Answer: None represents the absence of a value, similar to null in other languages.