Python 练习实例22

简介: Python 练习实例22

题目:两个乒乓球队进行比赛,各出三人。甲队为a,b,c三人,乙队为x,y,z三人。已抽签决定比赛名单。有人向队员打听比赛的名单。a说他不和x比,c说他不和x,z比,请编程序找出三队赛手的名单。

程序源代码:

实例

#!/usr/bin/python# -*- coding: UTF-8 -*- for i in range(ord('x'),ord('z') + 1):     for j in range(ord('x'),ord('z') + 1):         if i != j:             for k in range(ord('x'),ord('z') + 1):                 if (i != k) and (j != k):                     if (i != ord('x')) and (k != ord('x')) and (k != ord('z')):                         print ('order is a -- %s\t b -- %s\tc--%s' % (chr(i),chr(j),chr(k)))

以上实例输出结果为:

order is a -- z     b -- x    c--y

相关文章
|
1天前
|
Python
Python 练习实例30
Python 练习实例30
|
1天前
|
Python
Python 练习实例29
Python 练习实例29
|
2天前
|
Python
Python 练习实例27
Python 练习实例27
|
2天前
|
Python
Python 练习实例26
Python 练习实例26
|
2天前
|
Python
Python 练习实例25
Python 练习实例25
|
1天前
|
Python
Python 练习实例28
Python 练习实例28
|
3天前
|
数据安全/隐私保护 Python
经验大分享:python练习:从番号到封面
经验大分享:python练习:从番号到封面
|
3天前
|
数据安全/隐私保护 Python
经验大分享:python练习:从番号到封面
经验大分享:python练习:从番号到封面