'''
1 .if else 循环语句
x = int(input('输入学员分数:'))
if x >90:
print('A')
elif x >=80:
print('B')
elif x >=60:
print('C')
else:
print('不合格')
2. 逻辑判断语句
a = 19
if a >=0 and a <= 15:
print('yes')
b = 20
if b < 0 or b< 10:
print('yes')
elif b>50:
print('hhh')
else:
print('no')
3.连续判断 设定条件
x = int (input("输入学员分数:"))
if x > 0 and x <=100:
if x > 90:
print('A')
elif x >=80:
print('B')
elif x >= 60:
print('C')
else:
print('D')
else:
print('您的输入有误')
4.判断语句
第一题
x = int (input("请输入数字1-7"))
if x == 1:
print('今天是星期一')
elif x == 2:
print('今天是星期二')
elif x == 3:
print('今天是星期三')
elif x == 4:
print('今天是星期四')
elif x == 5:
print('今天是星期五')
elif x == 6:
print('今天是星期6')
else :
print('今天是星期日')
第二题
a = int(input('请输入一个数字'))
b = int(input('请输入二个数字'))
if a>b:
print('a比b大')
else:
print('a比b小')
第三题
x = int(input('请输入一个年份'))
if x % 400 == 0:
print('闰年')
elif x % 4 == 0 and x % 100 !=0:
print('闰年')
else:
print('不是闰年')
第四题
xx = input('请输入用户名')
xy = int(input('请输入密码'))
if xx == 'rongda' and xy == 123:
print('登陆成功')
else:
print("登陆失败")
第五题
x = int(input('请输入三位数'))
a = x//100
b = (x//10-x//100*10)
c = (x - x//10*10)
if a**3+b**3+c**3 == x:
print('水仙花数字')
else:
print('非理想数字')
循环语句
count = 0
while count <= 10:
print('这个数字是:', count)
count = count +1
print(count)
a = 0
while a < 5:
print(a,'小于5')
a = a + 1
else:
print(a,'小于5')
b = 1
while b < 5:print(b+1,'b小于5') ??
a=0
s = 0
while a < 100 :
a=a+1
s+=a
print(s)
a = 1
while a <100:
if a %2 ==1:
print(a,end=',')
a += 1 #第二行也今可以换但是不一样了?
For循环!!!
for i in '成为像最好的':
print(i)
lt = ['贵州茅台','五粮液','沱牌舍得']
for i in lt:
print(i)
lt = ['清华','北大青鸟','蓝翔','新东方']
for i in range(len(lt)):
print(lt[i])
lt = (1,3,'学校',[8,9,1])
for i in range(len(lt)): #len()后面是圆括号
print(lt[i])
d = {'name':'张三','age':'30','habby':'学习','dream':'没有'}
for x ,y in d.items():
print(x,y)
for i in range(0,101,2):
print(i,end=' ')
x={}
for a,b in x.items():
print(a,b)
第一种做法
a = 1
b = 0
while a<100 :
b += a
a =a+2
# print(b)
c = 0
d = 0
while c<100 :
d += c
c =c+2
s=b-d
print(s)
第二种做法
x =0
y=0
for i1 in range(1,100,2):
x+=i1
for i2 in range(2, 100, 2):
y+=i2
s=x-y
print(s)
13亿人口多少年后到达26亿?
a =13
year =0
while a<=26:
a*=1.008
year+=1
else:
print('%d年后到达26亿'%year)
试验: while循环 等等
a = 0
while a <100:
if a %2 ==0:
print(a, end=',')
a = 1
while a <10:
if a %2 ==1:
a += 1
print(a, end=',') 第二行也今可以换但是不一样了?
显示 错误:IndentationError: expected an indented block
持续卡机 无法验证 字符逻辑
'''
result =0
m =0
b =3
while m <99:#会加一个数字所以提前减去一个数 且 m是不是符合实际情况?
m +=1
if m%2==1:
result += m
else:
result -= m
print(result)
网友评论