00.python每日练习题(持续添加)

目标:以后每天写两个python练习程序。(2020年04月12日)

题目1:有 1、2、3、4 个数字,能组成多少个互不相同且无重复数字的三位数?都是多 少?

答:2020年4月12日

list1 = []
# k = 0

for i in (1,2,3,4):
    for a in (1,2,3,4):
        if a == i:
            continue
        for s in (1,2,3,4):
            if s == a or s == i:
                continue
            k = i * 100 + a * 10 +s
            list1.append(k)

length = len(list1)
print("一共有 %d" % length)

for l in list1:
    print(l)

题目2:企业发放的奖金根据利润提成。利润 (I) :

低于或等于 10 万元时,奖金可提 10%;

高于 10 万元,低于 20 万元时,低于 10 万元的部分按 10%提成,高于 10万元的部分,可提成 7.5%;

20 万到 40 万之间时,高于20万的部分可提5%;

40 万到 60 万之间时,高于40万的部分可提3%;

60 万到 100 万之间时,高于60万的部分可提1.5%;

高于 100万元时,超过 100 万元的部分按 1%提成, 从键盘输入当月利润 I ,求应发放奖金总数?

答:2020年4月12日

profit = int(input("请输入今年的利润(单位:万元):"))

if profit <= 10:
    wonder = profit * 0.1
    print("发放的奖金是%.4f 万元" % wonder)
elif profit > 10 and profit <= 20:
    wonder = 10 * 0.1 + (profit - 10) * 0.075
    print("发放的奖金是%.4f 万元" % wonder)
elif profit > 20 and profit <= 40:
    wonder = 10 * 0.1 + 10 * 0.075 + (profit - 20) * 0.05
    print("发放的奖金是%.4f 万元" % wonder)
elif profit > 40 and profit <= 60:
    wonder = 10 * 0.1 + 10 * 0.075 + 20 * 0.05 + (profit - 40) * 0.03
    print("发放的奖金是%.4f 万元" % wonder)
elif profit > 60 and profit <= 100:
    wonder = 10 * 0.1 + 10 * 0.075 + 20 * 0.05 + 20 * 0.03 + (profit - 60) * 0.015
    print("发放的奖金是%.4f 万元" % wonder)
else:
    wonder = 10 * 0.1 + 10 * 0.075 + 20 * 0.05 + 20 * 0.03 + 20 * 0.015 + (profit - 100) * 0.01
    print("发放的奖金是%.4f 万元" % wonder)

 题目3:题目:一个整数,它加上 100 后是一个完全平方数,再加上 168 又是一个完全平方数,请问该数是多少?

答:2020年4月13日

import math
i =1
result=[]
while i >0 and i <10000:
    if int(math.sqrt(i+100))== math.sqrt(i+100) and int(math.sqrt(i+268))==math.sqrt(i+268):
        print("整数是 %d"%i)
        result.append(i)

    i += 1

题目4:输入某年某月某日,判断这一天是这一年的第几天?

答:2020年4月13日

date = input('请输入某年某月某日,格式为 yyyy-mm-dd :')
y = int(date[0:4])  #获取年份
m = int(date[5:7])  #获取月份
d = int(date[8:])  #获取日

ly = False

if y%100 == 0:  #若年份能被100整除
    if y%400 == 0:  #且能被400整除
        ly = True  #则是闰年
    else:
        ly = False
elif y%4 == 0:  #其它情况下,若能被4整除
    ly = True  #则为闰年
else:
    ly = False

if ly == True:  #若为闰年,则2月份有29天
    ms = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
else:
    ms = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

days = 0
for i in range(1, 13):  #从1到12逐一判断,以确定月份
    if i == m:
        for j in range(i-1):  #确定月份i之后,则将ms列表中的前i-1项相加
            days += ms[j]
        print('%s是该年份的第%s天。' % (date, (days + d)))

 题目5:输入三个整数 x, y, z,请把这三个数由小到大输出。

答:2020年4月14日

x = int(input("输入一个整数:"))
y = int(input("输入一个整数:"))
z = int(input("输入一个整数:"))

min_value = min(x,y,z)
max_value = max(x,y,z)

if x not in (min_value,max_value):
    print("最小值为%d,中间值为%d,最大值为%d"%(min_value,x,max_value))
elif y not in (min_value,max_value):
    print("最小值为%d,中间值为%d,最大值为%d" % (min_value, y, max_value))
else:
    print("最小值为%d,中间值为%d,最大值为%d" % (min_value, z, max_value))

题目6:用 * 号输出字母 C 的图案。

答:2020年4月14日

print(' '*5,'*'*7)
print(' '*2,'*'*3,' '*6,'*'*2)
print('*'*2)
print('*'*2)
print(' '*2,'*'*3,' '*6,'*'*2)
print(' '*5,'*'*7)

 题目7:输出特殊图案。

答:2020年4月15日

# a = 176
# b = 219
a = 305
b = 404

print("%c%c%c%c%c" % (b, a, a, a, b))
print("%c%c%c%c%c" % (a, b, a, b, a))
print("%c%c%c%c%c" % (a, a, b, a, a))
print("%c%c%c%c%c" % (a, b, a, b, a))
print("%c%c%c%c%c" % (b, a, a, a, b))

题目8:输出99乘法口诀

答: 2020年4月15日

row = 1
while row <= 9:
    col = 1
    while col <= row:
        print("%d * %d = %d"%(col,row,col*row),end ="	")
        col += 1
    print("")
    row += 1
原文地址:https://www.cnblogs.com/hongchenlianxinlu/p/12686842.html