Variables Questions and Answers

Take Exam

Python Programming - Variables Questions with Answers help understand how data is stored and referenced in Python. These Python Variables Questions are key for Infosys, Accenture, and SSC exams testing programming basics and naming conventions

Variables

Showing 10 of 24 questions

11. How do you delete a variable in Python?

  • remove()
  • delete()
  • del
  • clear()
Show Answer Report

12. What is the output of: a = [1, 2, 3]; b = a; b[0] = 5; print(a)?

  • [1, 2, 3]
  • [5, 2, 3]
  • [1, 2, 3, 5]
  • Error
Show Answer Report

13. Which of these is an immutable data type in Python?

  • list
  • dict
  • tuple
  • set
Show Answer Report

14. What does the None keyword represent in Python?

  • Zero
  • Empty string
  • Null value
  • Boolean false
Show Answer Report

15. How do you create a constant variable in Python?

  • const PI = 3.14
  • final PI = 3.14
  • PI = 3.14
  • Use uppercase naming convention
Show Answer Report

16. What is variable shadowing in Python?

  • When a variable changes type
  • When local and global variables have same name
  • When a variable is deleted
  • When a variable is undefined
Show Answer Report

17. Which function converts a string to an integer in Python?

  • str()
  • int()
  • integer()
  • to_int()
Show Answer Report

18. What is the lifetime of a local variable in Python?

  • Entire program execution
  • Only during function execution
  • Until manually deleted
  • One minute
Show Answer Report

19. How do you check if a variable is defined in Python?

  • try-except block
  • if variable exists:
  • Check in locals() or globals()
  • is_defined() function
Show Answer Report

20. What is the difference between = and == in Python?

  • No difference
  • = compares, == assigns
  • = assigns, == compares
  • Both are assignment operators
Show Answer Report
Questions and Answers for Competitive Exams Various Entrance Test