1.使用while循环输入 1234568910
n = 1while n < 11:
if n == 7:
passelse:
print(n)
n = n + 1
print('----end----')
2、求1-100的所有数的和
n = 1
s = 0while n < 101:
s = s + n
n = n + 1
print(s)
3、输出 1-100 内的所有奇数
n = 1while n < 101:
if n%2 == 0:
passelse:
print(n)
n = n + 1
print('----end----')
4、输出 1-100 内的所有偶数
n = 1while n < 101:
if n%2 == 0:
print(n)
else:
pass
n = n + 1
print('----end----')
5、求1-2+3-4+5 ... 99的所有数的和
n = 1
s = 0while n < 100:
temp = n % 2if temp == 0:
s = s - n
else:
s = s + n
n = n + 1
print(s)
查看变量信息
a = 111print(a.bit_length()) 最少比特位数(输出:7)
a = "123"print(type(a),a) type函数查看类型(输出:str)
b = int(a)
print(type(b),b) int型
print(id(b)) 用 id 函数查看地址