Introduction to Computer Programming with Python

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 Alfredhook3
A
Alfredhook3
Community Contributor
Quizzes Created: 5199 | Total Attempts: 3,128,428
| Questions: 8 | Updated: Sep 6, 2026
Please wait...
Question 1 / 9
🏆 Rank #--
0 %
0/100
Score 0/100

1. Which of the following is the correct way to declare a variable in Python?

Explanation

In Python, variables are declared by simply assigning a value to a name without specifying a type. The statement `x = 5` correctly assigns the integer value 5 to the variable `x`. Unlike some other programming languages, Python does not require explicit type declarations, allowing for a more straightforward and flexible syntax. The other options use syntax from different languages or incorrect keywords, making them invalid in Python.

Submit
Please wait...
About This Quiz
Introduction To Computer Programming With Python - Quiz

This assessment focuses on fundamental concepts of computer programming using Python. Key topics include variable declaration, data types, functions, loops, and data structures. It's designed to reinforce essential skills for beginners in Python programming, making it a valuable resource for learners aiming to build a solid foundation in coding.

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 the following Python code?print(type(3.14))

Explanation

In Python, the `type()` function is used to determine the data type of a given value. When the code `print(type(3.14))` is executed, it checks the type of the numeric literal `3.14`, which is a floating-point number. As a result, the output reflects that `3.14` is of the type `float`, represented as ``. This indicates that it is not an integer (`int`), string (`str`), or double (which is not a distinct type in Python).

Submit

3. Which Python keyword is used to define a function?

Explanation

In Python, the keyword "def" is used to define a function. This keyword signals the start of a function definition, followed by the function name and parentheses that may include parameters. Using "def" allows the programmer to create reusable blocks of code that can be executed when called, enabling better organization and modularity in programming. Other options like "function," "define," and "func" are not valid keywords in Python for defining functions, making "def" the correct choice.

Submit

4. What does the following Python code print?for i in range(3): print(i)

Explanation

The provided Python code uses a `for` loop to iterate over a range of numbers generated by `range(3)`. The `range(3)` function produces a sequence of numbers starting from 0 up to, but not including, 3. Therefore, the loop will execute three times, with the variable `i` taking the values 0, 1, and 2 in successive iterations. Each value of `i` is printed on the same line, resulting in the output "0 1 2".

Submit

5. In Python, which data structure stores key-value pairs?

Explanation

A dictionary in Python is a built-in data structure that stores data in key-value pairs, allowing for efficient retrieval and manipulation of data. Each key in a dictionary is unique and is used to access its corresponding value. This structure is particularly useful for scenarios where quick lookups, insertions, and deletions of data based on keys are necessary, making it a versatile choice for various programming tasks. In contrast, lists, tuples, and sets do not support key-value pair storage.

Submit

6. Python is an interpreted programming language.

Explanation

Python is considered an interpreted programming language because its code is executed line-by-line at runtime rather than being compiled into machine code beforehand. This allows for greater flexibility and ease of debugging, as developers can test and modify code on the fly. The Python interpreter reads the source code and translates it into bytecode, which is then executed by the Python virtual machine. This characteristic distinguishes Python from compiled languages, where the entire program is translated into machine code before execution.

Submit

7. In Python, a list is ______, meaning its elements can be changed after creation.

Explanation

In Python, a list is described as mutable because its contents can be modified after the list has been created. This means you can add, remove, or change elements within the list without needing to create a new list. This characteristic allows for greater flexibility when working with collections of data, as it enables dynamic updates and modifications to the list's structure and elements.

Submit

8. Match each Python concept with its correct description.

Submit
×
Saved
Thank you for your feedback!
View My Results
Cancel
  • All
    All (8)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
Which of the following is the correct way to declare a variable in...
What is the output of the following Python code?print(type(3.14))
Which Python keyword is used to define a function?
What does the following Python code print?for i in range(3): ...
In Python, which data structure stores key-value pairs?
Python is an interpreted programming language.
In Python, a list is ______, meaning its elements can be changed after...
Match each Python concept with its correct description.
play-Mute sad happy unanswered_answer up-hover down-hover success oval cancel Check box square blue
Alert!