没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
# No.1
# Suppose there are a chickens and 35-a rabbits,
# each chicken has 2 legs while each rabbit has 4 legs
for a in range(1, 35):
# Use the number of chickens as the loop variable
legs = 2 * a + 4 * (35 - a)
if legs == 94:
print(f"There are {a} chickens and {35 - a} rabbits")
# another way
for b in range(2, 94, 2):
# Use the number of chicken legs as the loop variable
heads = b / 2 + (94 - b) / 4
if heads == 35:
print(f"There are {int(b / 2)} chickens and {int((94 - b) / 4)} rabbits")
# No.2
import itertools
a = [1, 2, 3]
for i in itertools.permutations(a, 3):
print(i)
# another way ( a little bit stupid )
for o in range(1, 4):
for p in range(1, 4):
if p != o:
for q in range(1, 4):
if q != p and q != o:
print(o,p,q)
# No.3
message = input("please enter a string:")
mess =[]
for i in list(message)[::2]:
mess.append(i)
资源评论
Qquarkk
- 粉丝: 1
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功