1.
num = 21
if num % 21 == 0:
print('这个数可以同时被3和7整除')
else:
print('这个数不能同时被3和7整除')
2.
num = 7
if num % 3 == 0 or num % 7 ==0:
if num % 21 != 0:
print('这个数能够被3或者7整除,但是不能同时被3和7整除')
else:
print('这个数能被3或者7整除,且能同时被3和7整除')
3.
value = input('请输入年:')
year = int(value)
if year % 400 == 0 or (year % 4 == 0 and year % 100 != 0):
print('闰年')
else:
print('不是闰年')
4.
value = input('请输入今天讲了多少时间的课:')
time = int(value)
hour = time // 3600
minute = (time % 3600) // 60
second = time - 3600 * hour - 60 * minute
print(hour, '时', minute, '分', second, '秒')
5.
x = input('请输入你的身高(米):')
y = input('请输入你的体重(公斤):')
h = float(x)
w = float(y)
if 18.5 <= w / h ** 2 <= 24.9:
print('你的身材正常')
else:
print('你的身材不正常')
6.
1)表达式0x13 & 0x17的值(19)
0x13 = 00010011
0x17 = 00010111
0x13 & 0x17 = 00010011 = 19
2)表达式0x13 | 0x17的值 (23)
0x13 = 00010011
0x17 = 00010111
0x13 | 0x17 = 00010111 = 23
3)表达式0x13 ^ 0x17的值 (4)
0x13 = 00010011
0x17 = 00010111
0x13 ^ 0x17 = 00000100 = 4
4)若x=12,y=13 则x&y的结果是(12)
12 = 00001100
13 = 00001101
12 & 13 = 00001100 = 12
5)在位运算中,操作数每右移一位,其结果相当于(B:操作数除以2)
6)设x是一个整数(16bit).若要通过x|y使x低度8位置1,高8位不变,则y的二进制数是(0000000011111111)