A collection of exercises for Python beginners(Q2.Method of borrowing)

A collection of exercises for Python beginners(Q2)

As a Python beginner, I’ve done a lot of practice. Most of these exercises are very interesting. In order for the other beginners to get to learn the basic usage of the language faster, I have compiled the results of my exercises for your reference. As I am a foreign student, this exercise is written in English. Most of the exercises come from 《C语言初学者趣味编程100例》(贾蓓/郭强/刘占敏). A small number of cases come from the Internet. If any case violates your rights, please tell me, and I will delete it as soon as possible.

Q2.Method of borrowing

Question:
Emma has 5 books to lend to Amy, Bob and Celina. If each person can only borrow one book at a time, then how many kinds of borrowing can there be?
Python Code:

a=0
for i in range(1,6):
   for j in range(1,6):
      for k in range(1,6):
         if i!=j and j!=k and i!=k:
            a=a+1
            print('A:',i,'B:',j,'C:',k)
print('Total:',a)

Running Results:
A: 1 B: 2 C: 3
A: 1 B: 2 C: 4
A: 1 B: 2 C: 5
A: 1 B: 3 C: 2
A: 1 B: 3 C: 4
A: 1 B: 3 C: 5
A: 1 B: 4 C: 2
A: 1 B: 4 C: 3
A: 1 B: 4 C: 5
A: 1 B: 5 C: 2
A: 1 B: 5 C: 3
A: 1 B: 5 C: 4
A: 2 B: 1 C: 3
A: 2 B: 1 C: 4
A: 2 B: 1 C: 5
A: 2 B: 3 C: 1
A: 2 B: 3 C: 4
A: 2 B: 3 C: 5
A: 2 B: 4 C: 1
A: 2 B: 4 C: 3
A: 2 B: 4 C: 5
A: 2 B: 5 C: 1
A: 2 B: 5 C: 3
A: 2 B: 5 C: 4
A: 3 B: 1 C: 2
A: 3 B: 1 C: 4
A: 3 B: 1 C: 5
A: 3 B: 2 C: 1
A: 3 B: 2 C: 4
A: 3 B: 2 C: 5
A: 3 B: 4 C: 1
A: 3 B: 4 C: 2
A: 3 B: 4 C: 5
A: 3 B: 5 C: 1
A: 3 B: 5 C: 2
A: 3 B: 5 C: 4
A: 4 B: 1 C: 2
A: 4 B: 1 C: 3
A: 4 B: 1 C: 5
A: 4 B: 2 C: 1
A: 4 B: 2 C: 3
A: 4 B: 2 C: 5
A: 4 B: 3 C: 1
A: 4 B: 3 C: 2
A: 4 B: 3 C: 5
A: 4 B: 5 C: 1
A: 4 B: 5 C: 2
A: 4 B: 5 C: 3
A: 5 B: 1 C: 2
A: 5 B: 1 C: 3
A: 5 B: 1 C: 4
A: 5 B: 2 C: 1
A: 5 B: 2 C: 3
A: 5 B: 2 C: 4
A: 5 B: 3 C: 1
A: 5 B: 3 C: 2
A: 5 B: 3 C: 4
A: 5 B: 4 C: 1
A: 5 B: 4 C: 2
A: 5 B: 4 C: 3
Total: 60

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值