小白入门_python菜鸟100题(1~5)

1#1,2,3,4,组成各不相同的三位数
for i in range(1, 5):
for j in range(1, 5):
for k in range(1, 5):
if(i != j) and (i != k) and (j != k):
s = 100i+10j+k
print(s)
print(i, j, k)

2# 企业利润
这个思想很重要,采用数轴的方式,而不是很蠢的用if else 语句来不断的判断
fund = int(input(“请输入本月的利润输入:”))
profit = [1000000, 600000, 400000, 200000, 100000, 0]
percent =[0.01, 0.015, 0.03, 0.05, 0.075, 0.1]
r = 0
for i in range(6):
if fund>profit[i]:
*r=r+(fund-profit[i])percent[i]
fund = profit[i]

print®

3#找出完全平方数
算法很重要,https://www.runoob.com/python/python-exercise-example3.html,说明了详细的推到过程
for i in range(1, 85):
if 168 % i == 0 and i % 2 == 0:
j = 168 / i
if i > j and (i+j) % 2 == 0 and (i-j) % 2 == 0:
m = (i+j)/2
n = (i-j)/2
x = n*n - 100
print(x)

4# 判断这一天是哪一天
monthList = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334]

youryear = int(input(“Enter your year number:”))
yourmonth = int(input(“Enter your month number:”))
yourday = int(input(“Enter your day number:”))

Cacul = 0
1# for i in range(yourmonth - 1):
1# Cacul += monthList[i]
Cacul = monthList[yourmonth-1] + yourday

leap = 0
if (youryear % 400 == 0) or ((youryear % 4 == 0) and (youryear % 100 != 0)):
leap = 1
if (leap == 1) and (yourmonth > 2):
Cacul += 1

5# 第五道题
循环读入input的数据
L = []
for i in range(3):
x = input(“enter a number:”)
L.append(x)
L.sort()
print(L)

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值