Note: All printed stringsmust
match the above output. To otherwise deviate will cause the Gradescope autograder to deduct points.
Skeleton Code
from random import randrange
from lab_classes import PlayingCard
from math import sqrt
suit_size = 13 # Number of cards in a suit.
deck_size = 52 # Number of cards in a deck.
num_cards = 260 # Number of cards to create with random rank & suit values
def make_random_cards():
"""Generate num_cards number of random PlayingCard objects.
This function will generate num_cards RANDOM playing cards
using your PlayingCard class. That means you will have to choose a random
suit and rank for a card num_cards times.
Printing:
Nothing
Positional arguments:
None
Returns:
cards_list -- a list of PlayingCard objects.
"""
#
# REPLACE WITH YOUR CODE.
#
return cards_list
def freq_count(cards_list):
"""Count every suit-rank combination.
Returns a dictionary whose keys are the card suit-rank and value is the
count.
Printing:
Nothing
Positional arguments:
cards_list -- A list of PlayingCard objects.
Returns:
card_freqs -- A dictionary whose keys are the single letter in the set
'd', 'c', 'h', 's' representing each card suit. The value for each key
is a list containing the number of cards at each rank, using the index
position to represent the rank. For example, {'s': [0, 3, 4, 2, 5]}
says that the key 's', for 'spades' has three rank 1's (aces), four
rank 2's (twos), two rank 3's (threes) and 5 rank 4's (fours). Index
position 0 is 0 since no cards have a rank 0, so make note.
"""
# DO NOT REMOVE BELOW
if type(cards_list) != list or \
list(filter(lambda x: type(x) != PlayingCard, cards_list)):
raise TypeError("cards_list is required to be a list of PlayingCard \
objects.")
# DO NOT REMOVE ABOVE
#
# REPLACE WITH YOUR CODE.
#
return card_freqs
def std_dev(counts):
"""Calculate the standard deviation of a list of numbers.
Positional arguments:
counts -- A list of ints representing frequency counts.
Printing:
Nothing
Returns:
_stdev -- The standard deviation as a single float value.
"""
# DO NOT REMOVE BELOW
if type(counts) != list or \
list(filter(lambda x: type(x) != int, counts)):
raise TypeError("counts is required to be a list of int values.")
# DO NOT REMOVE ABOVE
(The image attached has the continued part of the code)