GPYC practice question 8 of 15
An operator able to perform bitwise shifts is coded as (select two answers)
Full set: 75 questionsIn Python, bitwise operators work on integers at the binary level. The <> (right shift) operators are used to perform bitwise shifts. The left shift operator (<>) shifts the bits to the right. These operations are equivalent to multiplication and integer division by powers of two, respectively.
A. --: This is not a valid operator in Python. To decrement a variable, one would use the statement x -= 1.
B. ++: This is not a valid operator in Python. To increment a variable, one would use the statement x += 1.
1. Python Software Foundation. (2024). The Python Language Reference (Version 3.12.3). Section 6.7, "Shifting Operations". Retrieved from https://docs.python.org/3/reference/expressions.html#shifting-operations. This section explicitly defines <> as the left and right bitwise shift operators.
2. Guttag, J. V. (2016). 6.0001 Introduction to Computer Science and Programming in Python, Fall 2016. Massachusetts Institute of Technology: MIT OpenCourseWare. Lecture 3 Code and Notes, "Operators". The course materials list <> as Python's bitwise shift operators. Retrieved from https://ocw.mit.edu/courses/6-0001-introduction-to-computer-science-and-programming-in-python-fall-2016/pages/lecture-3-string-manipulation-guess-and-check-approximations-bisection/
3. Van Rossum, G. (2024). The Python Tutorial (Version 3.12.3). Python Software Foundation. Section 14.1, "Floating Point Arithmetic: Issues and Limitations" (Note). While discussing binary fractions, the tutorial implicitly references the concept of bit shifting as a fundamental operation on binary representations. The main definition resides in the Language Reference.
Keep practicing
Take the free GPYC practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other GPYC practice questions
- Question 1What will the contents of the "__name__" variable be if the program "gpyc.py" is run as a…
- Question 3With a requests session object named "browser", how can the expiration attribute of a coo…
- Question 4What does the attacker do in a SQL Injection attack?
- Question 6What will be the value of the i variable when the while loop finishes its execution0 i = …
- Question 9Third-party Python modules like Scapy and Beautiful Soup are used for what purpose?
- Question 13After calling a subprocess in a Python program, the program returns an error code of "0".…
