Case15. Play card cards are assigned sequential numbers: 1 - spades, 2 - clubs, 3 - diamonds, 4 - hearts. The dignity of the cards over ten, was assigned to the numbers: 11 - jack, 12 - lady, 13 - king, 14 - ace. Two integers are given: N is the rank of \((6 \leq N \leq 14)\) and M is the suit of the card \((1 \leq M \leq 4)\). Print out the name of the corresponding card such as "six diamonds", "queen of hearts", "ace of clubs", etc.

Solution in Python 3:

import random

_suit = {
1 : 'spade',
2 : 'club',
3 : 'diamond',
4 : 'heart'
}

_value = {
6 : 'six',
7 : 'seven',
8 : 'eight',
9 : 'nine',
10 : 'ten',
11 : 'jack',
12 : 'queen',
13 : 'king',
14 : 'ace'
}

try:
N = random.randrange(6,15)
print("Rank of card: ", N, "-", _value[N])
M = random.randrange(1,5)
print("Suit of card: ", M, "-", _suit[M])
print("Card: ", _value[N], _suit[M])

except KeyError as e:
print('Error')