zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    1、C# 数组是值类型还是引用类型,对数组有什么更深层次的理解?
    面试:TCP协议经典十五连问!
    看八股408数据结构中平衡树有感而发,直接手撸了10h Splay终于撸出来了
    关于个人感觉冷门的介值定理的记录
    对泰勒公式又有了新的认识
    mac配置java环境
    Kubernetes kubectl常用命令
    .ssh/config line 4: garbage at end of line; "Enterprise"
    maven修改项目版本号命令
    JenKins持续集成
  • 原文地址:https://www.cnblogs.com/Maikes/p/9458828.html
Copyright © 2011-2022 走看看