Python Programming Basics Quiz for Beginners

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Catherine Halcomb
Catherine Halcomb
Community Contributor
Quizzes Created: 2148 | Total Attempts: 6,845,174
| Questions: 29 | Updated: Apr 18, 2026
Please wait...
Question 1 / 30
🏆 Rank #--
0 %
0/100
Score 0/100

1. Who created Python?

Explanation

Guido van Rossum is recognized as the creator of Python, a high-level programming language he began developing in the late 1980s and released in 1991. His vision was to create a language that emphasized code readability and simplicity, making it accessible for beginners while powerful enough for experts. Van Rossum's contributions have significantly influenced the programming landscape, leading to Python's widespread adoption in various fields, including web development, data analysis, artificial intelligence, and more.

Submit
Please wait...
About This Quiz
Python Programming Basics Quiz For Beginners - Quiz

This assessment focuses on the fundamentals of Python programming, covering essential concepts such as data types, functions, and exception handling. It is designed for beginners to evaluate their understanding of key Python features and syntax, making it a valuable tool for anyone looking to strengthen their programming skills.

2.

What first name or nickname would you like us to use?

You may optionally provide this to label your report, leaderboard, or certificate.

2. What is the output of print('Hello, World!')?

Explanation

The output of the print function in Python is the string passed to it, displayed exactly as it is defined. In this case, 'Hello, World!' includes a comma and an exclamation mark, which are part of the string. Therefore, when executed, the print function outputs the exact text, maintaining the punctuation and spacing as specified.

Submit

3. Which of the following is a mutable data type in Python?

Explanation

A mutable data type in Python is one that allows modification of its elements after creation. Among the options given, a list is mutable, meaning you can change, add, or remove elements without creating a new list. In contrast, tuples and strings are immutable; once created, their contents cannot be altered. Sets are also mutable, but the question specifically asks for the most commonly recognized mutable type, which is the list, known for its versatility and ease of use in various programming scenarios.

Submit

4. What does the 'len()' function do?

Explanation

The 'len()' function in programming is used to determine the number of items in an object, such as a string, list, or tuple. When applied, it provides a count of elements or characters, allowing users to understand the size of the data structure they are working with. This function is essential for managing and manipulating collections of data, making it a fundamental tool in many programming tasks.

Submit

5. Which symbol is used for floor division in Python?

Explanation

In Python, the symbol for floor division is `//`. This operator divides two numbers and rounds down to the nearest whole number, effectively discarding any decimal portion. For example, using `5 // 2` would yield `2`, as it rounds down from `2.5`. This is particularly useful when you want to obtain an integer result from a division operation without needing to convert the result explicitly.

Submit

6. What is the correct way to define a function in Python?

Explanation

In Python, functions are defined using the keyword "def," which stands for "define." This keyword is followed by the function name and parentheses, which may include parameters. The correct syntax ensures that the function is properly recognized by the interpreter, allowing it to execute the code block that follows. Other options listed do not conform to Python's syntax for function definition, making them incorrect. Thus, "def greet():" is the proper way to define a function in Python.

Submit

7. Which of the following is NOT a valid variable name in Python?

Explanation

In Python, variable names must start with a letter (a-z, A-Z) or an underscore (_), and cannot begin with a digit. The name "2nd_variable" begins with the digit '2', making it an invalid variable name. In contrast, "my_variable," "_myVariable," and "myVariable" all start with valid characters, adhering to Python's naming conventions.

Submit

8. What will be the output of the following code: print(type(5))?

Explanation

In Python, the `type()` function is used to determine the data type of a given value. When the argument is the integer `5`, the function returns the type of that value. Since `5` is an integer, the output of `print(type(5))` will be ``, indicating that the value belongs to the integer class. This output confirms that the number is stored as an integer in Python's data type system.

Submit

9. Which of the following is used to handle exceptions in Python?

Explanation

In Python, exceptions are handled using the try-except block. The try block contains code that may potentially raise an exception, while the except block defines how to respond to that exception if it occurs. This structure allows for graceful error handling, enabling the program to continue running or to provide meaningful error messages, rather than crashing unexpectedly. The other options listed do not represent valid Python syntax for exception handling.

Submit

10. What is the output of the expression 3 ** 2?

Explanation

The expression 3 ** 2 represents exponentiation, where 3 is the base and 2 is the exponent. This means that 3 is multiplied by itself 2 times: 3 * 3. When you calculate this, you get 9. Therefore, the output of the expression is 9, which is the result of raising 3 to the power of 2.

Submit

11. Which method is used to add an element to the end of a list?

Explanation

The `append()` method is specifically designed to add a single element to the end of a list in Python. Unlike `insert()`, which can add an element at a specified position, or `extend()`, which merges another iterable into the list, `append()` focuses solely on adding one item at the list's tail. This makes it a straightforward and efficient choice for expanding a list by one element.

Submit

12. What will be the output of the following code: print('abc'.upper())?

Explanation

The code `print('abc'.upper())` calls the `upper()` method on the string `'abc'`. This method converts all lowercase letters in the string to uppercase. Therefore, the string `'abc'` is transformed into `'ABC'`, which is then printed as the output. This demonstrates the functionality of string methods in Python, specifically how they can alter the case of characters in a string.

Submit

13. Which of the following is a key-value pair in a dictionary?

Explanation

In programming, a dictionary is a collection of key-value pairs where each key is unique and is used to retrieve its corresponding value. The format {'key': 'value'} clearly represents this structure, as seen in {'name': 'John'}, where 'name' is the key and 'John' is the associated value. The other options do not follow this syntax: the first is a list, the third is a tuple, and the fourth is an incorrect representation of a dictionary.

Submit

14. What does the 'pop()' method do in a list?

Explanation

The 'pop()' method in a list is designed to remove and return the last element by default. This method can also take an index as an argument to remove an element at a specific position, but when no index is provided, it specifically targets the last item. This functionality is useful for managing collections, allowing for efficient removal of elements from the end of the list.

Submit

15. Which of the following is used to create a set in Python?

Explanation

In Python, sets are created using curly braces `{}`. A set is an unordered collection of unique items, and using `{}` allows you to define a set directly. For example, writing `{1, 2, 3}` creates a set containing the numbers 1, 2, and 3. In contrast, square brackets `[]` are used for lists, parentheses `()` for tuples, and angle brackets `` are not used for creating collections in Python. Thus, `{}` is the correct syntax for creating a set.

Submit

16. What is the result of the expression 'Hello'.replace('l', 'p')?

Explanation

The expression 'Hello'.replace('l', 'p') replaces all occurrences of the letter 'l' in the string "Hello" with the letter 'p'. In this case, there are two 'l's in "Hello". When both are replaced, the string transforms into "Heppo", where the first 'l' is replaced by 'p', and the second 'l' is also replaced by 'p'. Therefore, the final result of the expression is "Heppo".

Submit

17. Which of the following is a valid list comprehension?

Explanation

The valid list comprehension, `[x for x in range(5)]`, creates a list by iterating over each element `x` in the range from 0 to 4. This syntax generates a new list containing the values 0, 1, 2, 3, and 4. In contrast, the other options represent different data structures or incorrect syntax: `{}` denotes a set comprehension, `()` denotes a generator expression, and `[x in range(5)]` incorrectly attempts to create a list based on a boolean expression.

Submit

18. What will be the output of the following code: print(5 == 5)?

Explanation

In Python, the expression `5 == 5` is a comparison operation that checks if the value on the left (5) is equal to the value on the right (5). Since both values are indeed equal, the expression evaluates to `True`. The `print` function then outputs this boolean value, resulting in the output being `True`.

Submit

19. Which keyword is used to define a function in Python?

Explanation

In Python, the keyword "def" is used to define a function. This keyword signals the start of a function declaration, followed by the function name and parentheses. It is essential for creating reusable blocks of code that perform specific tasks. Using "def" allows programmers to encapsulate logic and improve code organization, making it easier to read and maintain. Other options like "function," "define," and "func" are not valid keywords in Python for defining functions.

Submit

20. What is the output of the expression 'abc' + 'def'?

Explanation

When two strings are concatenated using the '+' operator in Python, they are combined end-to-end without any spaces or additional characters. In this case, the strings 'abc' and 'def' are joined together, resulting in 'abcdef'. This operation does not produce any errors or insert spaces, leading to a straightforward concatenation of the two input strings.

Submit

21. Which of the following is a valid way to import a module?

Submit

22. What is the purpose of the 'return' statement in a function?

Submit

23. Which of the following is used to check if a value is in a list?

Submit

24. What will be the output of the following code: print(10 // 3)?

Submit

25. Which of the following is a valid tuple?

Submit

26. What is the output of the expression 'Hello'.find('e')?

Submit

27. Which of the following is used to create a new dictionary?

Submit

28. What will be the output of the following code: print([1, 2, 3] + [4, 5])?

Submit

29. Which of the following is a valid way to create a set?

Submit
×
Saved
Thank you for your feedback!
View My Results
Cancel
  • All
    All (29)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
Who created Python?
What is the output of print('Hello, World!')?
Which of the following is a mutable data type in Python?
What does the 'len()' function do?
Which symbol is used for floor division in Python?
What is the correct way to define a function in Python?
Which of the following is NOT a valid variable name in Python?
What will be the output of the following code: print(type(5))?
Which of the following is used to handle exceptions in Python?
What is the output of the expression 3 ** 2?
Which method is used to add an element to the end of a list?
What will be the output of the following code: print('abc'.upper())?
Which of the following is a key-value pair in a dictionary?
What does the 'pop()' method do in a list?
Which of the following is used to create a set in Python?
What is the result of the expression 'Hello'.replace('l', 'p')?
Which of the following is a valid list comprehension?
What will be the output of the following code: print(5 == 5)?
Which keyword is used to define a function in Python?
What is the output of the expression 'abc' + 'def'?
Which of the following is a valid way to import a module?
What is the purpose of the 'return' statement in a function?
Which of the following is used to check if a value is in a list?
What will be the output of the following code: print(10 // 3)?
Which of the following is a valid tuple?
What is the output of the expression 'Hello'.find('e')?
Which of the following is used to create a new dictionary?
What will be the output of the following code: print([1, 2, 3] + [4,...
Which of the following is a valid way to create a set?
play-Mute sad happy unanswered_answer up-hover down-hover success oval cancel Check box square blue
Alert!