编写程序,生成一副扑克牌,有4个花色,每个花色有13张牌 【参考代码】: ranks=["2","3","4","5","6","7","8","9","10","J","Q","K","A"] suits=["黑桃","红桃","方块","梅花",] ____________: ____________: print(suit+rank,end=" ") print()
时间: 2023-06-29 12:14:20 浏览: 268
用matlab实现的一个简单的洗扑克牌算法
下面是生成一副扑克牌的Python代码:
```python
ranks = ["2","3","4","5","6","7","8","9","10","J","Q","K","A"]
suits = ["黑桃","红桃","方块","梅花"]
for suit in suits:
for rank in ranks:
print(suit+rank,end=" ")
print()
```
输出结果如下:
```
黑桃2 黑桃3 黑桃4 黑桃5 黑桃6 黑桃7 黑桃8 黑桃9 黑桃10 黑桃J 黑桃Q 黑桃K 黑桃A
红桃2 红桃3 红桃4 红桃5 红桃6 红桃7 红桃8 红桃9 红桃10 红桃J 红桃Q 红桃K 红桃A
方块2 方块3 方块4 方块5 方块6 方块7 方块8 方块9 方块10 方块J 方块Q 方块K 方块A
梅花2 梅花3 梅花4 梅花5 梅花6 梅花7 梅花8 梅花9 梅花10 梅花J 梅花Q 梅花K 梅花A
```
阅读全文