-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode04-03.py
More file actions
39 lines (39 loc) · 1.1 KB
/
Copy pathcode04-03.py
File metadata and controls
39 lines (39 loc) · 1.1 KB
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
32
33
34
35
36
37
38
39
Python 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 22:20:52) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> a=ord('A')
>>> mask=0x0F
>>>
>>> print("%x & %x = %x" % (a, mask, a & mask))
41 & f = 1
>>> print("%X & %X = %X" % (a, mask, a mask))
SyntaxError: invalid syntax
>>> print("%X & %X = %X" % (a, mask, a | mask))
41 & F = 4F
>>>
>>> mask=ord('a') - ard('A')
Traceback (most recent call last):
File "<pyshell#7>", line 1, in <module>
mask=ord('a') - ard('A')
NameError: name 'ard' is not defined
>>> mask = ord('a') - ard('A')
Traceback (most recent call last):
File "<pyshell#8>", line 1, in <module>
mask = ord('a') - ard('A')
NameError: name 'ard' is not defined
>>> a = ord('A')
>>> mask = 0x0F
>>>
>>> print("%x & %x = %x" % (a, mask, a & mask))
41 & f = 1
>>> print("%X & %X = %X" % (a, mask, a | mask))
41 & F = 4F
>>>
>>> mask = ord('a')-ord('A')
>>>
>>> b = a^mask
>>> print("%c ^ %d = %c" % (a, mask, b))
A ^ 32 = a
>>> a = b^mask
>>> print("%c ^ %d = %c" % (b, mask, a))
a ^ 32 = A
>>>