Python Programming Fundamentals

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 Themes
T
Themes
Community Contributor
Quizzes Created: 2709 | Total Attempts: 1,190,407
| Attempts: 16 | Questions: 31 | Updated: Sep 4, 2026
Please wait...
Question 1 / 32
🏆 Rank #--
0 %
0/100
Score 0/100

1. Which of the following best describes Python?

Explanation

Python is considered a high-level programming language because it abstracts complex details of the computer's hardware, allowing developers to focus on programming logic rather than low-level operations. It is interpreted, meaning code is executed line-by-line at runtime, which enhances flexibility and ease of debugging. Additionally, Python supports object-oriented programming, enabling the creation of reusable code through classes and objects, promoting better organization and modularity in software development. These characteristics make Python a popular choice for various applications, from web development to data analysis.

Submit
Please wait...
About This Quiz
Python Programming Fundamentals - Quiz

This assessment focuses on Python programming fundamentals, evaluating your understanding of key concepts like data types, functions, and object-oriented programming. It's a valuable resource for anyone looking to strengthen their Python skills and grasp essential programming principles.

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. Match each Python data type with its correct example.

Submit

3. Which file mode deletes all existing content before writing new data?

Explanation

The 'w' file mode opens a file for writing and automatically deletes any existing content, starting with a clean slate. This mode is useful when you want to overwrite a file completely with new data. In contrast, 'r' is for reading without modifying the file, 'a' appends new data to the end without deleting existing content, and 'x' creates a new file but fails if the file already exists. Thus, 'w' is the mode that ensures all previous data is removed before writing.

Submit

4. Python supports multiple programming paradigms including procedural and object-oriented.

Submit

5. In Python, the input() function automatically stores user input as an integer.

Submit

6. Strings in Python are mutable, meaning their characters can be changed after creation.

Submit

7. How many total keywords exist in Python 3.7?

Explanation

Python 3.7 includes a total of 33 keywords that are reserved words in the language, each serving a specific purpose in coding. These keywords cannot be used as identifiers (like variable names) and include terms such as `def`, `class`, `if`, `else`, and `import`. The number of keywords can change with different versions of Python, as new features are added or deprecated. In Python 3.7, these 33 keywords provide the foundational syntax and structure for writing Python programs effectively.

Submit

8. What is the difference between print() and return in Python functions?

Explanation

In Python, `print()` is a function that displays output directly to the console, primarily for user interaction or debugging. It does not store any value for further use in the program. In contrast, `return` is used within a function to send a value back to the caller, allowing that value to be stored in a variable or used in subsequent computations. This fundamental difference highlights that `print()` is for output, while `return` is for passing data.

Submit

9. The 'break' statement immediately exits the nearest enclosing loop in Python.

Submit

10. In Python's LEGB rule, what does 'E' stand for?

Explanation

In Python's LEGB rule, 'E' stands for Enclosing local functions. This refers to the scope of functions that are defined within other functions. When a variable is referenced, Python first checks the local scope, then the enclosing function's scope, followed by the global scope, and finally the built-in scope. Enclosing scopes allow inner functions to access variables from their outer functions, enabling closures and maintaining state across function calls. This hierarchy is essential for understanding variable resolution in nested functions.

Submit

11. What does the % operator do in Python?

Explanation

In Python, the % operator is used to calculate the remainder of a division operation. When you divide one number by another, the % operator yields the portion that remains after the division has been completed. For example, in the expression `7 % 3`, the result is 1, since 3 goes into 7 twice, leaving a remainder of 1. This operator is commonly referred to as the modulus operator, and it is useful in various programming scenarios, such as determining even or odd numbers or implementing cyclical behaviors.

Submit

12. What function is used to get input from the user in Python?

Explanation

In Python, the `input()` function is specifically designed to capture user input from the console. When called, it pauses program execution and waits for the user to type something and press Enter. The data entered is then returned as a string, allowing for further manipulation or processing within the program. This function is fundamental for interactive applications where user engagement is required. Other options like `get()`, `read()`, and `scan()` do not serve this purpose in standard Python usage.

Submit

13. What data type is the variable: name = "Roy"?

Explanation

The variable `name` is assigned the value "Roy", which is enclosed in quotation marks. In programming, any sequence of characters within quotes is considered a string. Strings are used to represent text data. Hence, the variable `name` is of the data type string, commonly abbreviated as `str`. Other options like int, float, and bool represent numerical and boolean values, which do not apply to the given value.

Submit

14. In Python, what is used instead of curly braces {} to define code blocks?

Explanation

In Python, code blocks are defined using indentation rather than curly braces, as seen in many other programming languages. This means that the level of indentation indicates the grouping of statements, making the code visually structured and easier to read. Consistent indentation is crucial; it not only helps in organizing the code but also affects how the code is executed, as Python relies on this formatting to determine the scope of loops, functions, and conditionals.

Submit

15. In Python, **kwargs stores keyword arguments as a dictionary.

Submit

16. Tuples in Python are mutable data structures that can be modified after creation.

Submit

17. Lambda expressions are ____, single-line functions created without using the def keyword.

Explanation

Lambda expressions are referred to as anonymous functions because they do not have a name associated with them. They allow for the creation of small, single-line functions in a concise manner without the need for the traditional function definition using the def keyword. This makes them particularly useful for short operations, especially in functional programming contexts where functions are often passed as arguments or returned from other functions. The term "anonymous" highlights that these functions are not bound to an identifier, making them versatile for quick, on-the-fly computations.

Submit

18. To use a global variable inside a function and modify it, you must use the ____ keyword.

Explanation

In Python, when you want to modify a global variable within a function, you need to declare it as global using the `global` keyword. This informs the interpreter that you are referring to the variable defined outside the function's scope, rather than creating a new local variable. By doing so, any changes made to the variable inside the function will affect the global variable, allowing for consistent data manipulation across different parts of the program.

Submit

19. Which Python keyword is used to declare a function?

Explanation

In Python, the keyword "def" is used to define a function. It signals the start of a function declaration, followed by the function name and parentheses that may include parameters. This keyword is essential for creating reusable blocks of code that can be called multiple times throughout a program, enhancing modularity and readability.

Submit

20. What is the result of 107 // 4 in Python?

Explanation

In Python, the operator `//` performs floor division, which divides two numbers and rounds down to the nearest whole number. When dividing 107 by 4, the result is 26.75. However, since floor division rounds down, the final result is 26, discarding the decimal part. This behavior distinguishes floor division from regular division, which would yield the full decimal result.

Submit

21. In Python, a class is a ____ while an object is an actual instance of that class.

Explanation

In Python, a class serves as a blueprint that defines the properties and behaviors (attributes and methods) that its objects will possess. While the class outlines the structure and functionality, an object is a concrete instantiation of that class, embodying the defined attributes and methods. This relationship allows multiple objects to be created from the same class blueprint, each with its own unique state while sharing the same behavior as defined by the class.

Submit

22. Match each LEGB scope level with its correct definition.

Submit

23. Match each file mode with its behavior.

Submit

24. What does the __init__ method do in a Python class?

Explanation

The __init__ method in a Python class is a special method known as the constructor. It is automatically invoked when a new instance of the class is created. This method is typically used to initialize the object's attributes and set up any necessary state, allowing for the customization of object creation. By defining the __init__ method, developers can ensure that objects are properly configured upon instantiation, enhancing the functionality and usability of the class.

Submit

25. Which of the following is a browser-based Python IDE mentioned in the course?

Explanation

Repl.it is a browser-based integrated development environment (IDE) that allows users to write, run, and share Python code directly from a web browser. Unlike Thonny and IDLE, which are desktop applications, and PyCharm, which is primarily used as a standalone software, Repl.it offers a convenient online platform that supports collaborative coding and instant execution of code snippets. This makes it accessible from any device with internet access, making it a popular choice for learning and experimenting with Python programming.

Submit

26. Match each Python concept with its correct description.

Submit

27. In Python, what does *args represent in a function definition?

Explanation

In Python, *args allows a function to accept an arbitrary number of positional arguments. When a function is defined with *args, any additional positional arguments passed to it are collected into a tuple. This enables flexibility in function calls, allowing for varying numbers of inputs without explicitly defining each parameter. For example, if a function is called with multiple arguments, *args captures them, making it easy to iterate over or manipulate them within the function.

Submit

28. Who created Python and when was it first released?

Explanation

Python was created by Guido van Rossum and was first released in 1991. Van Rossum aimed to develop a language that emphasized code readability and simplicity, making it accessible to beginners while still powerful enough for experts. The language has since evolved significantly, gaining widespread popularity in various fields such as web development, data analysis, and artificial intelligence, thanks to its versatility and extensive libraries.

Submit

29. The ____ function in Python removes and returns the last item from a list.

Explanation

The `pop()` function in Python is used to remove and return the last item from a list. When called, it modifies the original list by removing the element at the specified index, which defaults to the last item if no index is provided. This function is useful for managing dynamic lists where items need to be accessed and removed efficiently. If the list is empty, calling `pop()` will raise an `IndexError`, making it important to check the list's state before using this method.

Submit

30. Python is case-sensitive — all keywords are strictly lowercase except ____.

Explanation

Python is a case-sensitive language, meaning that it distinguishes between uppercase and lowercase letters. Most keywords in Python, such as `if`, `else`, and `while`, are written in lowercase. However, the special constants `True`, `False`, and `None` are exceptions to this rule; they are capitalized to signify their unique roles in the language. `True` and `False` represent boolean values, while `None` signifies the absence of a value or a null state, making them essential for logical operations and control flow in Python programming.

Submit

31. The ____ built-in function combines multiple lists element by element.

Submit
×
Saved
Thank you for your feedback!
View My Results
Cancel
  • All
    All (31)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
Which of the following best describes Python?
Match each Python data type with its correct example.
Which file mode deletes all existing content before writing new data?
Python supports multiple programming paradigms including procedural...
In Python, the input() function automatically stores user input as an...
Strings in Python are mutable, meaning their characters can be changed...
How many total keywords exist in Python 3.7?
What is the difference between print() and return in Python functions?
The 'break' statement immediately exits the nearest enclosing loop in...
In Python's LEGB rule, what does 'E' stand for?
What does the % operator do in Python?
What function is used to get input from the user in Python?
What data type is the variable: name = "Roy"?
In Python, what is used instead of curly braces {} to define code...
In Python, **kwargs stores keyword arguments as a dictionary.
Tuples in Python are mutable data structures that can be modified...
Lambda expressions are ____, single-line functions created without...
To use a global variable inside a function and modify it, you must use...
Which Python keyword is used to declare a function?
What is the result of 107 // 4 in Python?
In Python, a class is a ____ while an object is an actual instance of...
Match each LEGB scope level with its correct definition.
Match each file mode with its behavior.
What does the __init__ method do in a Python class?
Which of the following is a browser-based Python IDE mentioned in the...
Match each Python concept with its correct description.
In Python, what does *args represent in a function definition?
Who created Python and when was it first released?
The ____ function in Python removes and returns the last item from a...
Python is case-sensitive — all keywords are strictly lowercase...
The ____ built-in function combines multiple lists element by element.
play-Mute sad happy unanswered_answer up-hover down-hover success oval cancel Check box square blue
Alert!