Core Python Basic Questions
01. What is dynamic typing in Python?
Answer: Python determines variable type at runtime based on value, not
declaration.
02. How do you check the type of a variable?
Answer:
print(type(10))
03. What are mutable vs immutable data types?
Answer: Mutable types can change (list, dict), immutable cannot (str, tuple,
int).
04. Difference between list and tuple?
Answer: Lists are mutable, tuples are immutable.
05. What is a dictionary?
Answer: A collection of key-value pairs defined using {}.
06. How do arithmetic operators work?
Answer: Operators like +, -, *, /, //, **.
07. What is floor division (//)?
Answer: Division that returns the integer part.
08. What is the modulus operator?
Answer: Returns remainder of division: 10 % 3 == 1.
09. How do you format strings?
Answer: Using f-strings or .format().
print(f"My name is {name}")
10. Difference between == and is:
Answer: == compares values, is checks identity.
11. What is the print() function?
Answer: Outputs text to console.
12. What are logical operators?
Answer: and, or, not.
13. What are relational operators?
Answer: ==, !=, >, <, >=, <=.
14. What is a token in Python?
Answer: Smallest unit like keywords, identifiers, literals, operators.
15. What are constants?
Answer: Values that don’t change during execution.
16. What is a module?
Answer: Python file with reusable code; use import module.
17. What are packages?
Answer: Directories of related modules with an __init__.py.
18. What is the correct file extension for Python?
Answer: .py file extension.
19. How do you take user input?
Answer: Using input() function.
20. How do you check length of a list?
Answer: len(list).
21. What is slicing?
Answer: Accessing part of a sequence using [start:end:step].
22. What is a lambda function?
Answer: Anonymous inline function.
23. What are loops?
Answer: for and while loops repeat code blocks.
24. What are built-in data types?
Answer: Examples: int, str, list, dict, set.
25. How does Python handle arrays vs lists?
Answer: Python lists are more flexible than arrays from the array module.
26. Keywords in Python are
A) User-defined
B) Reserved words
C) Variables
D) Functions
Answer:
27. help() function is used to
A) Debug code
B) Get documentation
C) Compile
D) Execute
Answer:
28. help("keywords") displays
A) All variables
B) All keywords
C) All modules
D) Errors
Answer:
29. Python uses indentation to define
A) Variables
B) Blocks of code
C) Comments
D) Keywords
Answer:
30. Incorrect indentation leads to
A) SyntaxError
B) IndentationError
C) TypeError
D) NameError
Answer:
31. Strings can be enclosed in
A) ''
B) ""
C) ''' '''
D) All of the above
Answer:
32. Multiline statements can be created using
A) /
B) \
C) //
D) ;;
Answer:
33. Single-line comments start with
A) //
B) #
C) /*
D) --
Answer:
34. Multi-line comments use
A) ''' '''
B) //
C) ##
D) --
Answer:
35. Variable is created when
A) Declared
B) Assigned a value
C) Compiled
D) Installed
Answer:
36. Python variables are
A) Statically typed
B) Dynamically typed
C) Machine typed
D) None
Answer:
37. \n represents
A) Space
B) New line
C) Tab
D) Backslash
Answer:
38. \t represents
A) Tab
B) Time
C) Text
D) Type
Answer:
39. To print output in Python, we use
A) echo()
B) printf()
C) print()
D) display()
Answer:
40. print("Hello") will
A) Show error
B) Display Hello
C) Compile
D) Nothing
Answer:
41. Function to read input is
A) get()
B) input()
C) read()
D) scan()
Answer:
42. input() returns data as
A) int
B) float
C) string
D) bool
Answer:
43. Which is NOT a Python data type?
A) list
B) tuple
C) arraylist
D) set
Answer:
44. Which data type is immutable?
A) list
B) dictionary
C) set
D) tuple
Answer:
45. int("10") returns
A) "10"
B) 10
C) Error
D) Float
Answer:
46. float(5) returns
A) 5
B) 5.0
C) "5"
D) Error
Answer:
47. eval("2+3") returns
A) "2+3"
B) 5
C) Error
D) None
Answer:
48. eval() evaluates
A) String expression
B) Integer only
C) Float only
D) Variables only
Answer:
49. eval("10/2") returns
A) 5
B) 5.0
C) 10
D) 2
Answer:
50. eval() can be risky because
A) Slow
B) Executes arbitrary code
C) No output
D) Syntax error
Answer: