Skip to main content

Python Skills Assessment

Test your Python knowledge across 8 progressive phases. Each phase has 10 questions — answer at least 7 correctly to advance.


Phase 1: Introduction & Basics

Covers: Python intro, installation, hello world, print(), comments

1. Who created the Python programming language?

  • A) Dennis Ritchie
  • B) James Gosling
  • C) Guido van Rossum
  • D) Brendan Eich

Answer: C

2. In which year was Python first released?

  • A) 1989
  • B) 1991
  • C) 1995
  • D) 2000

Answer: B

3. What is the correct file extension for Python scripts?

  • A) .python
  • B) .pt
  • C) .py
  • D) .p

Answer: C

4. Which command runs a Python script named script.py in the terminal?

  • A) python script.py
  • B) run script.py
  • C) python run script.py
  • D) execute script.py

Answer: A

5. What does print("Hello") output?

  • A) 'Hello'
  • B) Hello
  • C) "Hello"
  • D) Hello

Answer: B

6. How do you print text without adding a newline at the end?

  • A) print("text", newline=False)
  • B) print("text", end="")
  • C) print("text", no_newline=True)
  • D) print_no_newline("text")

Answer: B

7. Which symbol is used for single-line comments in Python?

  • A) //
  • B) /*
  • C) #
  • D) --

Answer: C

8. How do you write a multi-line comment in Python?

  • A) /* comment */
  • B) <!-- comment -->
  • C) Using triple quotes """ ... """
  • D) {- comment -}

Answer: C

9. What is IDLE?

  • A) A Python web framework
  • B) Python's built-in IDE
  • C) A Python package manager
  • D) A Python data type

Answer: B

10. Which of these is NOT a valid way to install Python packages?

  • A) pip install package_name
  • B) python -m pip install package_name
  • C) python install package_name
  • D) pip3 install package_name

Answer: C


Phase 2: Variables & Data Types

Covers: Variables, data types (int/float/str/bool/None), operators, type(), type casting, strings, keywords, booleans

11. What is the data type of x = 5?

  • A) float
  • B) int
  • C) str
  • D) bool

Answer: B

12. What is the output of type(3.14)?

  • A) <class 'float'>
  • B) <class 'int'>
  • C) <class 'double'>
  • D) <class 'decimal'>

Answer: A

13. What is the result of int("5") + 2?

  • A) "52"
  • B) 7.0
  • C) 7
  • D) Error

Answer: C

14. Which of the following is NOT a Python keyword?

  • A) import
  • B) def
  • C) variable
  • D) class

Answer: C

15. What does bool(0) return?

  • A) False
  • B) True
  • C) None
  • D) 0

Answer: A

16. What is the value of None in Python?

  • A) 0
  • B) ""
  • C) False
  • D) It represents the absence of a value

Answer: D

17. What is the output of print("Hello" * 3)?

  • A) Hello 3
  • B) HelloHelloHello
  • C) Hello Hello Hello
  • D) TypeError

Answer: B

18. What does the // operator do?

  • A) Regular division
  • B) Floor (integer) division
  • C) Modulus
  • D) Exponentiation

Answer: B

19. What is the type of True in Python?

  • A) int
  • B) bool
  • C) str
  • D) NoneType

Answer: B

20. Which operator is used for exponentiation in Python?

  • A) ^
  • B) **
  • C) ^^
  • D) exp()

Answer: B


Phase 3: Control Flow

Covers: if-elif-else, for loops, while loops, range(), break, continue, comparisons, logical operators

21. What does range(5) generate?

  • A) 1, 2, 3, 4, 5
  • B) 0, 1, 2, 3, 4
  • C) 0, 1, 2, 3, 4, 5
  • D) 1, 2, 3, 4

Answer: B

22. What does the break statement do inside a loop?

  • A) Skips the current iteration
  • B) Exits the loop immediately
  • C) Restarts the loop
  • D) Pauses the loop

Answer: B

23. What is the output of for i in range(3): print(i, end=" ")?

  • A) 1 2 3
  • B) 0 1 2
  • C) 0 1 2 3
  • D) 1 2

Answer: B

24. What does the elif keyword mean?

  • A) else if (shorthand)
  • B) else then
  • C) else if — another condition to check
  • D) end if

Answer: C

25. What is the output of print(5 == 5.0)?

  • A) False
  • B) True
  • C) TypeError
  • D) 5

Answer: B

26. What does the continue statement do?

  • A) Exits the loop
  • B) Skips the rest of the current iteration and moves to the next
  • C) Stops the program
  • D) Repeats the loop from the beginning

Answer: B

27. What is the output of print(not True)?

  • A) True
  • B) False
  • C) None
  • D) Error

Answer: B

28. What is the result of (5 > 3) and (2 < 1)?

  • A) True
  • B) False
  • C) Error
  • D) None

Answer: B

29. How many times will while False: print("Hi") execute?

  • A) Once
  • B) Infinite
  • C) Zero
  • D) Syntax error

Answer: C

30. What does for ch in "abc": print(ch) output?

  • A) abc
  • B) 'a' 'b' 'c'
  • C) a b c (each on a new line)
  • D) "abc"

Answer: C


Phase 4: Data Structures

Covers: Lists (append/remove/slicing/indexing), tuples, dicts (keys/values/items), sets, nested data structures

31. Which of the following is mutable?

  • A) List
  • B) Tuple
  • C) String
  • D) Integer

Answer: A

32. What is the output of [1, 2, 3][-1]?

  • A) 1
  • B) 2
  • C) 3
  • D) Error

Answer: C

33. What does my_dict.keys() return?

  • A) A list of values
  • B) A view of all keys in the dictionary
  • C) A list of tuples
  • D) The first key

Answer: B

34. What is the key difference between a list and a tuple?

  • A) Lists are faster
  • B) Tuples are immutable
  • C) Tuples can hold more data types
  • D) Lists cannot be nested

Answer: B

35. What does {1, 2, 3, 2, 1} evaluate to?

  • A) {1, 2, 3, 2, 1}
  • B) {1, 2, 3}
  • C) [1, 2, 3]
  • D) (1, 2, 3, 2, 1)

Answer: B

36. What does my_list.append(5) do?

  • A) Replaces the last element with 5
  • B) Adds 5 to the end of the list
  • C) Inserts 5 at index 0
  • D) Removes the element 5

Answer: B

37. What is the output of [1, 2, 3, 4, 5][1:3]?

  • A) [1, 2]
  • B) [2, 3]
  • C) [2, 3, 4]
  • D) [1, 2, 3]

Answer: B

38. Which method returns key-value pairs from a dictionary?

  • A) .keys()
  • B) .values()
  • C) .items()
  • D) .pairs()

Answer: C

39. How do you access the value 10 in data = {"a": {"b": 10}}?

  • A) data[0]["b"]
  • B) data["a"]["b"]
  • C) data["b"]
  • D) data.a.b

Answer: B

40. Which of these is NOT a valid set operation?

  • A) Union (|)
  • B) Intersection (&)
  • C) Difference (-)
  • D) Concatenation (+)

Answer: D


Phase 5: Functions & Modules

Covers: def functions, return, arguments, default params, lambda, list comprehension, import, name

41. What does a function return if it has no return statement?

  • A) 0
  • B) False
  • C) None
  • D) ""

Answer: C

42. What is the output of (lambda x: x * 2)(5)?

  • A) 5
  • B) x * 2
  • C) 10
  • D) 25

Answer: C

43. What does *args allow a function to accept?

  • A) A variable number of positional arguments
  • B) A variable number of keyword arguments
  • C) Only one argument
  • D) No arguments

Answer: A

44. What does [x**2 for x in range(4)] produce?

  • A) [0, 2, 4, 6]
  • B) [0, 1, 4, 9]
  • C) [1, 4, 9, 16]
  • D) [0, 4, 16, 36]

Answer: B

45. When a Python script is run directly, what is the value of __name__?

  • A) "__main__"
  • B) "main"
  • C) "__script__"
  • D) None

Answer: A

46. What is the correct way to import only the sqrt function from the math module?

  • A) import math
  • B) from math import sqrt
  • C) import sqrt from math
  • D) include math.sqrt

Answer: B

47. What happens if you call a function with more arguments than it expects?

  • A) Extra arguments are ignored
  • B) A TypeError is raised
  • C) Only the first arguments are used
  • D) The function returns None

Answer: B

48. What is the purpose of **kwargs in a function definition?

  • A) Accepts any number of positional arguments
  • B) Accepts any number of keyword arguments
  • C) Accepts only keyword arguments named "kwargs"
  • D) Accepts no arguments

Answer: B

49. Given def func(x=5): return x + 1, what does func() return?

  • A) Error
  • B) 1
  • C) 6
  • D) 5

Answer: C

50. What is the output of print(len([1, 2, 3])) when used inside a list comprehension's if clause? (Trick: just evaluate len)

  • A) 3
  • B) 2
  • C) 1
  • D) 0

Answer: A


Phase 6: Object-Oriented Programming

Covers: Classes, init, self, inheritance, super(), methods, @property, encapsulation, access modifiers

51. What is the purpose of the __init__ method in a Python class?

  • A) To delete the object
  • B) To initialize (constructor) a new object
  • C) To print the object
  • D) To compare two objects

Answer: B

52. What does self refer to in a Python class method?

  • A) The class itself
  • B) The specific instance of the class
  • C) The parent class
  • D) The module

Answer: B

53. What is the correct syntax for class inheritance in Python?

  • A) class Dog extends Animal:
  • B) class Dog inherits Animal:
  • C) class Dog(Animal):
  • D) class Dog : Animal

Answer: C

54. What does super() do?

  • A) Calls a method from the parent class
  • B) Creates a new instance
  • C) Deletes the current instance
  • D) Returns the class name

Answer: A

55. What is the @property decorator used for?

  • A) To mark a method as private
  • B) To define a method that can be accessed like an attribute
  • C) To create a class method
  • D) To define a static method

Answer: B

56. How do you indicate an attribute should be treated as private (encapsulated)?

  • A) private var
  • B) Prefix with double underscore __var
  • C) Prefix with priv_
  • D) Add @private decorator

Answer: B

57. What is a class variable?

  • A) A variable inside a method
  • B) A variable shared by all instances of a class
  • C) A variable unique to each instance
  • D) A variable passed to __init__

Answer: B

58. What happens when a child class defines a method with the same name as the parent?

  • A) The parent method is called
  • B) The child method overrides the parent method
  • C) Both methods are called
  • D) An error is raised

Answer: B

59. Which decorator is used to define a static method in Python?

  • A) @classmethod
  • B) @staticmethod
  • C) @staticmethodmethod
  • D) @abstractmethod

Answer: B

60. What is the output of class A: pass followed by print(type(A()))?

  • A) <class 'type'>
  • B) <class 'A'>
  • C) <class '__main__.A'>
  • D) <class 'object'>

Answer: C


Phase 7: Files, Errors & Algorithms

Covers: File open/read/write, try/except/finally, raise, Exception types, linear/binary search, bubble sort

61. Which mode opens a file for writing (overwrites existing content)?

  • A) "r"
  • B) "w"
  • C) "a"
  • D) "x"

Answer: B

62. What does the with statement do when opening files?

  • A) Automatically closes the file when done
  • B) Opens the file in read-only mode
  • C) Prevents the file from being deleted
  • D) Locks the file

Answer: A

63. What is the difference between read() and readline()?

  • A) read() reads binary; readline() reads text
  • B) read() reads one line; readline() reads all lines
  • C) read() reads the entire file; readline() reads one line
  • D) They are the same

Answer: C

64. What does the raise keyword do?

  • A) Catches an exception
  • B) Ignores an exception
  • C) Manually triggers an exception
  • D) Logs an exception

Answer: C

65. Which block is always executed regardless of whether an exception occurs?

  • A) try
  • B) except
  • C) else
  • D) finally

Answer: D

66. Which exception is raised when you try to divide by zero?

  • A) ValueError
  • B) IndexError
  • C) ZeroDivisionError
  • D) TypeError

Answer: C

67. What is the time complexity of linear search in the worst case?

  • A) O(n)
  • B) O(log n)
  • C) O(n²)
  • D) O(1)

Answer: A

68. What condition must be met for binary search to work?

  • A) The data must be unsorted
  • B) The data must be sorted
  • C) The data must contain only numbers
  • D) The data must have no duplicates

Answer: B

69. In bubble sort, after the first pass, which element is in its correct position?

  • A) The largest element
  • B) The smallest element
  • C) The first element
  • D) The middle element

Answer: A

70. Which of the following file modes would you use to append to an existing file?

  • A) "r+"
  • B) "w"
  • C) "a"
  • D) "x"

Answer: C


Phase 8: Pandas & Data

Covers: Pandas DataFrame, Series, read_csv, loc/iloc, head(), info(), describe(), data cleaning

71. What is the standard import alias for Pandas?

  • A) import pandas as pd
  • B) import pandas as p
  • C) import pandas as pan
  • D) import pandas

Answer: A

72. What does pd.Series([1, 2, 3]) create?

  • A) A DataFrame
  • B) A one-dimensional labeled array
  • C) A list
  • D) A dictionary

Answer: B

73. Which method reads a CSV file into a DataFrame?

  • A) pd.load_csv()
  • B) pd.open_csv()
  • C) pd.read_csv()
  • D) pd.import_csv()

Answer: C

74. By default, how many rows does head() display?

  • A) 3
  • B) 5
  • C) 10
  • D) All rows

Answer: B

75. What is the difference between loc and iloc?

  • A) loc works on DataFrames; iloc works on Series
  • B) loc uses labels; iloc uses integer positions
  • C) They are the same
  • D) loc is for columns; iloc is for rows

Answer: B

76. Which method provides a summary of a DataFrame including data types and non-null counts?

  • A) summary()
  • B) describe()
  • C) dtypes()
  • D) info()

Answer: D

77. Which method provides descriptive statistics of numeric columns?

  • A) info()
  • B) describe()
  • C) stats()
  • D) summary()

Answer: B

78. Which method is used to remove rows with missing values?

  • A) dropna()
  • B) fillna()
  • C) remove_na()
  • D) delete_na()

Answer: A

79. Which method replaces missing values with a specified value?

  • A) dropna()
  • B) fillna()
  • C) replace_na()
  • D) fix_na()

Answer: B

80. How do you select the column "age" from a DataFrame df?

  • A) df["age"]
  • B) df.age
  • C) Both A and B work
  • D) df["age"] and df.age both work

Answer: D