7.23 每日学习作业总结

# 1. 求1-100的所有数的和
# count=1
# i=0
# while count<=100:
# i+=count
# count += 1
# print(i)

# count=1
# i=0
# while count<=100:
# i+=count
# count+=1
# print(i)


# 2. 输出 1-100 内的所有奇数
# count=1
# while count<=100:
# if count%2==1:
# print(count)
# count+=1
# count=1
# while count<=100:
# if count%2 ==1:
# print(count)
# count+=1
# 3. 输出 1-100 内的所有偶数
count=1
while count<=100:
if count%2 !=1:
print(count)
count+=1
# count=1
# while count<=100:
# if count%2==0:
# print(count)
# count+=1

# 5. 求1-2+3-4+5 ... 99的所有数的和
# count=1
# i=0
# while count<100:
# if count%2==1:
# i+=count
# count+=1
# else:
# i-=count
# count+=1
# print(i)
# count=1
# i=0
# while count<=100:
# if count%2 !=1:
# i-=count
# count += 1
# else:
# i+=count
# count+=1
# print(i)



# 1.打印出所有的1-1000中的 "水仙花数 ",所谓 "水仙花数 "是指一个三位数,
# 其各位数字立方和等于该数本身。例如153
# count=100
# while count<1000:
# a = count // 100
# b = count //10 % 10
# c = count % 10
# if count==a**3+b**3+c**3:
# print(count)
# count+=1

# count=100
# while count<1000:
# a=count//100
# b=count//10%10
# c=count%10
# if count==a**3+b**3+c**3:
# print(count)
# count+=1

# for i in range (100,1001):
# s=str(i)
# if int(s[0])**3+int(s[1])**3+int(s[2])**3==i:
# print(i)
# for i in range(100,1001):
# s=str(i)
# if int(s[0])**3+int(s[1])**3+int(s[2])**3==i:
# print(i)
# for i in range(100,1001):
# s=str(i)
# if int(s[0])**3+int(s[1])**3+int(s[2])**3:
# print(i)

# 2.每月存款500元 连续存款10年 年利率为 百分之5 请算出十年后本金和利息共多少
# 需要考虑复利就是第二年的本金是第一年的本金加第一年的利息






# 6. 用户登陆(三次机会重试)

# name='wwl'
# password='123'
# count=1
# while count<3:
# inp_name=input('用户名:').strip()
# inp_psw=input('密码:').strip()
# if inp_name==name and inp_psw==password:
# print('登录成功')
# break
# else:
# print('登录失败,请重试')
# count +=1
# break


# 7.打印99乘法表
# for i in range (1,10):
# for j in range (1,i+1):
# print('%s*%s=%s' %(i,j,i*j),end=(' '))
# print()
#
# for i in rang(1,10):
# for j in range(1,i+1):

# # 8.打印以下列图案
# 8.1
# * * * * *
# * * * *
# * * *
# * *
# *
# for i in range(1,6):
# for j in range(i):
# print(' ', end='')
# for j in range(6 - i):
# print('* ',end='')
# print()
# for i in range(1,6):
# for j in range(i):
# print(' ',end='')
# for j in range(6-i):
# print('* ',end='')
# print()

# 8.2
# *
# * *
# * * *
# * * * *
# * * * * *
for i in range(1,6):
for j in range(6-i):
print(' ', end='')
for j in range(i):
print('* ',end='')
print()

# 8.3

# * * * * *
# * * * *
# * * *
# * *
# *
#     *
# * *
# * * *
# * * * *
# * * * * *


# for i in range (1,11):
# if i<6:
# for j in range(i):
# print(' ', end='')
# for j in range(6 - i):
# print('* ',end='')
# else:
# for z in range(11-i):
# print(' ', end='')
# for z in range(i-5):
# print('* ',end='')
# print()


# 9.猜年龄游戏
# 要求:
# 允许用户最多尝试3次,3次都没猜对的话,就直接退出,如果猜对了,打印恭喜信息并退出
# age=22
# count=0
# while count<3:
# inp_age=int(input('age>>>:'))
# if inp_age==age:
# print('gongxigongxi')
# break
# count+=1

# 10.猜年龄游戏升级版 要求:
# 允许用户最多尝试3次 , 每尝试3次后,如果还没猜对,
# 就问用户是否还想继续玩,如果回答Y或y, 就继续让其猜3次,
# 以此往复,如果回答N或n,就退出程序, 如何猜对了,就直接退出
# age=22
# count=0
# while count<3:
# inp_age=int(input('age>>>:'))
# if inp_age==age:
# print('gongxigongxi')
# break
# count+=1
# if count==3:
# question=input('>>>>Y or N;')
# if question=='Y' or question=='y':
# count=0
# else:
# break

转载于:https://www.cnblogs.com/Maikes/p/9458828.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值