티스토리 뷰

IT/Python: Codecademy

Sec10: bit calculator

Last72 2018. 3. 8. 19:31

print 5 >> 4  # Right Shift #0

print 5 << 1  # Left Shift #10

print 8 & 5   # Bitwise AND #0

print 9 | 4   # Bitwise OR #13

print 12 ^ 42 # Bitwise XOR #38

print ~88     # Bitwise NOT # -89


shift_right = 0b1100

shift_left = 0b1

 

# Your code here!

shift_right = shift_right >> 2

shift_left = shift_left << 2

 

print bin(shift_right) #3

print bin(shift_left) #4


'IT > Python: Codecademy' 카테고리의 다른 글

12 File Input and Output and Finish course  (0) 2018.03.19
11 Introduction to Classes  (0) 2018.03.10
10 Advanced Topics in Python  (0) 2018.03.07
9 Exam Statistics  (0) 2018.03.06
8 Loop  (0) 2018.02.28
댓글
Announcement
Recent Posts
Recent Comments
Total
Today
Yesterday
Link
TAG
more
«   2024/12   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
Search by month