CMSC 201 Python & Linux Programming Concepts

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: 3029 | Total Attempts: 1,231,654
| Questions: 15 | Updated: Oct 4, 2026
Please wait...
Question 1 / 16
🏆 Rank #-- ▾
0 %
0/100
Score 0/100

1. To check if an integer x is odd, you would use:

Explanation

To determine if an integer \( x \) is odd, we check the remainder when \( x \) is divided by 2. If \( x \) leaves a remainder of 1, it means \( x \) is not divisible by 2, confirming that it is odd. The expression \( x \% 2 == 1 \) specifically tests this condition, while \( x \% 2 == 0 \) would indicate that \( x \) is even. The other options involving 3 are irrelevant to determining the oddness of \( x \).

Submit
Please wait...
About This Quiz
Cmsc 201 Python & Linux Programming Concepts - Quiz

This assessment focuses on essential Python and Linux programming concepts. It evaluates your understanding of loops, conditionals, data types, and list manipulation. Mastering these skills is crucial for effective programming and problem-solving in Python. This resource is beneficial for learners looking to strengthen their coding proficiency in these areas.

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 difference between // and % in Python?

Explanation

In Python, the `//` operator performs integer (floor) division, which divides two numbers and rounds down to the nearest whole number. For example, `5 // 2` results in `2`. On the other hand, the `%` operator calculates the remainder of a division operation. For instance, `5 % 2` yields `1`, since 2 goes into 5 two times with a remainder of 1. Thus, while `//` provides the quotient, `%` provides the leftover value after division.

Submit

3. If you don't know how many times you want to iterate, which loop will you most likely use?

Explanation

A while loop is ideal when the number of iterations is unknown at the start. It continues to execute as long as a specified condition remains true, allowing for flexibility in scenarios where the end condition is determined by dynamic factors, such as user input or data availability. This adaptability makes the while loop a suitable choice for situations where the iteration count cannot be predetermined.

Submit

4. How many times will this loop execute: for x in range(7, 25, 3)?

Explanation

The loop `for x in range(7, 25, 3)` starts at 7 and increments by 3 until it reaches or exceeds 25. The sequence of values generated will be 7, 10, 13, 16, 19, and 22. Each of these values is within the specified range, resulting in a total of 6 iterations before the loop stops, as the next value (25) is not included in the range. Thus, the loop executes 6 times.

Submit

5. Which statement evaluates to True?

Explanation

The statement "False or (True and not False)" evaluates to True because the inner expression "True and not False" simplifies to True (since not False is True). Therefore, the overall expression becomes "False or True," which evaluates to True. In contrast, the other options either evaluate to False or do not yield a True result, making this statement the only one that evaluates to True.

Submit

6. Which loop can be used to modify an element of a list?

Explanation

Both the `for-i` loop and the `while` loop can be used to modify an element of a list. The `for-i` loop iterates over the indices of the list, allowing access to each element for modification. Similarly, the `while` loop can continue until a specified condition is met, providing the flexibility to change elements at specific indices. The `for-each` loop, however, does not allow direct modification of the list elements since it iterates over the values rather than their indices. Thus, options b and c are suitable for modifying list elements.

Submit

7. Which variable name is legal in Python (will not cause a syntax error)?

Explanation

In Python, variable names must start with a letter (a-z, A-Z) or an underscore (_) and can be followed by letters, digits (0-9), or underscores. The name "xy" adheres to these rules, beginning with a letter and containing only letters. In contrast, "1234x" starts with a digit, "isit?" includes an invalid character (?), and "$dollarmoney" begins with a special character ($), all of which are not allowed in Python variable naming conventions.

Submit

8. When running a while loop, in order to avoid an infinite loop you must:

Explanation

To prevent an infinite loop in a while loop, it is essential to ensure that the condition evaluated remains dynamic. This can be achieved by altering a variable within the loop or obtaining user input, which can potentially modify the condition that determines whether the loop continues to execute. If the condition never changes to false, the loop will run indefinitely, hence the need for an update mechanism to break the cycle.

Submit

9. Which of the following expressions is True?

Explanation

The expression 'the' in 'theory' evaluates to True because the substring 'the' exists within the string 'theory'. In Python, the 'in' keyword checks for the presence of one string within another, and since 'the' is indeed a part of 'theory', this expression is valid. The other options either check for membership in lists or substrings that do not exist, resulting in False evaluations.

Submit

10. Why is there no output when this code is executed?for x in range(100, 3, 6): print(x)

Explanation

In Python, the `range()` function generates a sequence of numbers starting from the first argument up to, but not including, the second argument. In this case, the starting value is 100 and the stopping value is 3. Since the start value is greater than the stop value, the sequence is empty, leading to no iterations of the loop. As a result, the `print()` statement inside the loop is never reached, and thus, there is no output when the code is executed.

Submit

11. What is the result of evaluating: (False and not True) or (True and not False)?

Explanation

To evaluate the expression (False and not True) or (True and not False), we start with the first part: False and not True evaluates to False since anything ANDed with False is False. The second part, True and not False, evaluates to True because not False is True, and True AND True is True. Combining both parts with OR, we have False or True, which results in True. Thus, the overall expression evaluates to True.

Submit

12. Convert the binary number 0110 1111 to decimal.

Explanation

To convert the binary number 0110 1111 to decimal, we analyze each bit from right to left, assigning powers of 2. Starting from the right, the bits represent 2^0, 2^1, 2^2, and so on. For 0110 1111, the bits are 0 (2^7), 1 (2^6), 1 (2^5), 0 (2^4), 1 (2^3), 1 (2^2), 1 (2^1), and 1 (2^0). Calculating the values gives us 0 + 64 + 32 + 0 + 8 + 4 + 2 + 1 = 107. Thus, the decimal equivalent of the binary number is 107.

Submit

13. Match each Linux command concept to its correct description.

Submit

14. Given the list: romans = ["varro", "caesar", "pompey", "sulla", "cincinnatus", "marius", "fabius"]What is the output of: print(romans[1], romans[len(romans) - 4])?

Explanation

In the list `romans`, the element at index 1 is "caesar". The expression `len(romans) - 4` calculates the index of the fourth element from the end, which is index 3, corresponding to "sulla". Therefore, the output of the print statement combines these two values, resulting in "caesar" followed by "sulla".

Submit

15. In Python, when casting the string "0.0" to int and float respectively, what happens?

Explanation

When the string "0.0" is cast to an integer in Python, it raises a ValueError because the string format is not directly convertible to an integer. However, when casting to a float, Python successfully interprets "0.0" as a floating-point number, resulting in 0.0. This behavior highlights how Python differentiates between types and handles string representations of numbers, allowing for float conversion while rejecting integer conversion due to the presence of the decimal point.

Submit
×
Saved
Thank you for your feedback!
View My Results
Cancel
  • All
    All (15)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
To check if an integer x is odd, you would use:
What is the difference between // and % in Python?
If you don't know how many times you want to iterate, which loop will...
How many times will this loop execute: for x in range(7, 25, 3)?
Which statement evaluates to True?
Which loop can be used to modify an element of a list?
Which variable name is legal in Python (will not cause a syntax...
When running a while loop, in order to avoid an infinite loop you...
Which of the following expressions is True?
Why is there no output when this code is executed?for x in range(100,...
What is the result of evaluating: (False and not True) or (True and...
Convert the binary number 0110 1111 to decimal.
Match each Linux command concept to its correct description.
Given the list: romans = ["varro", "caesar", "pompey", "sulla",...
In Python, when casting the string "0.0" to int and float...
play-Mute sad happy unanswered_answer up-hover down-hover success oval cancel Check box square blue
Alert!