From 5dcffa4db36f1a994478ece4523b303e6328ac2d Mon Sep 17 00:00:00 2001 From: JohnathanAndres <71150620+JohnathanAndres@users.noreply.github.com> Date: Mon, 14 Feb 2022 13:10:04 -0600 Subject: [PATCH 1/2] Add files via upload --- Lectures/Quiz 2.ipynb | 61 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 Lectures/Quiz 2.ipynb diff --git a/Lectures/Quiz 2.ipynb b/Lectures/Quiz 2.ipynb new file mode 100644 index 0000000..8259f94 --- /dev/null +++ b/Lectures/Quiz 2.ipynb @@ -0,0 +1,61 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 12, + "id": "481a3da8", + "metadata": {}, + "outputs": [], + "source": [ + "def make_deck():\n", + " Suits=['C','H','S','D']\n", + " Values=['A',2,3,4,5,6,7,8,9,10,'J','Q','K']\n", + " Deck=list()\n", + " for i in range(len(Values)):\n", + " for j in range(len(Suits)):\n", + " Deck.append((Suits[j],Values[i]))\n", + " return Deck" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "a5b1f84c", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[('C', 'A'), ('H', 'A'), ('S', 'A'), ('D', 'A'), ('C', 2), ('H', 2), ('S', 2), ('D', 2), ('C', 3), ('H', 3), ('S', 3), ('D', 3), ('C', 4), ('H', 4), ('S', 4), ('D', 4), ('C', 5), ('H', 5), ('S', 5), ('D', 5), ('C', 6), ('H', 6), ('S', 6), ('D', 6), ('C', 7), ('H', 7), ('S', 7), ('D', 7), ('C', 8), ('H', 8), ('S', 8), ('D', 8), ('C', 9), ('H', 9), ('S', 9), ('D', 9), ('C', 10), ('H', 10), ('S', 10), ('D', 10), ('C', 'J'), ('H', 'J'), ('S', 'J'), ('D', 'J'), ('C', 'Q'), ('H', 'Q'), ('S', 'Q'), ('D', 'Q'), ('C', 'K'), ('H', 'K'), ('S', 'K'), ('D', 'K')]\n" + ] + } + ], + "source": [ + "test=make_deck()\n", + "print(test)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.9" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} From 62543899e65c8e868ad6fdd43ebdcfc64acf5a5a Mon Sep 17 00:00:00 2001 From: JohnathanAndres <71150620+JohnathanAndres@users.noreply.github.com> Date: Fri, 25 Feb 2022 10:10:33 -0600 Subject: [PATCH 2/2] Add files via upload --- Lectures/Quiz 3 .ipynb | 1121 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1121 insertions(+) create mode 100644 Lectures/Quiz 3 .ipynb diff --git a/Lectures/Quiz 3 .ipynb b/Lectures/Quiz 3 .ipynb new file mode 100644 index 0000000..86327a1 --- /dev/null +++ b/Lectures/Quiz 3 .ipynb @@ -0,0 +1,1121 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "adefe073", + "metadata": {}, + "source": [ + "## Quiz\n", + "\n", + "Create Quiz 3 notebook and copy you Deck (and possibly Card) class from you current lab into the notebook. Instantiate a 6-card deck. Shuffle the cards. Pickle the deck into a file. Reload the deck into memory as another instance (i.e. give it a different name). Write a quick test that demonstrates original and reloaded instances of the deck have the exact same card order.\n", + "\n", + "Due: START OF LAB on Friday." + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "ac0537b3", + "metadata": {}, + "outputs": [], + "source": [ + "import random as ran\n", + "class deck:\n", + " \n", + " def __init__(self,deck_number=6,deck=False):\n", + " self.__deck_number=deck_number\n", + " \n", + " if deck:\n", + " self.__deck=deck\n", + " else:\n", + " self.__deck=list()\n", + " Suits=['Clubs','Diamonds','Hearts','Clovers']\n", + " Value=['Ace',2,3,4,5,6,7,8,9,10,'Jack','Queen','King']\n", + " for number in range(self.__deck_number):\n", + " for i in range(len(Value)):\n", + " for j in range(len(Suits)):\n", + " self.__deck.append((Suits[j],Value[i]))\n", + " self.__deck.append('plastic')\n", + " \n", + " \n", + " def deck_view(self):\n", + " return self.__deck\n", + " \n", + " def shuffle(self):\n", + " ran.shuffle(self.__deck) \n", + " return self.__deck \n", + " \n", + " def draw_card(self):\n", + " card=deck[0]\n", + " del deck[0]\n", + " return card" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "id": "d0699b43", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[('Clubs', 'Ace'),\n", + " ('Diamonds', 'Ace'),\n", + " ('Hearts', 'Ace'),\n", + " ('Clovers', 'Ace'),\n", + " ('Clubs', 2),\n", + " ('Diamonds', 2),\n", + " ('Hearts', 2),\n", + " ('Clovers', 2),\n", + " ('Clubs', 3),\n", + " ('Diamonds', 3),\n", + " ('Hearts', 3),\n", + " ('Clovers', 3),\n", + " ('Clubs', 4),\n", + " ('Diamonds', 4),\n", + " ('Hearts', 4),\n", + " ('Clovers', 4),\n", + " ('Clubs', 5),\n", + " ('Diamonds', 5),\n", + " ('Hearts', 5),\n", + " ('Clovers', 5),\n", + " ('Clubs', 6),\n", + " ('Diamonds', 6),\n", + " ('Hearts', 6),\n", + " ('Clovers', 6),\n", + " ('Clubs', 7),\n", + " ('Diamonds', 7),\n", + " ('Hearts', 7),\n", + " ('Clovers', 7),\n", + " ('Clubs', 8),\n", + " ('Diamonds', 8),\n", + " ('Hearts', 8),\n", + " ('Clovers', 8),\n", + " ('Clubs', 9),\n", + " ('Diamonds', 9),\n", + " ('Hearts', 9),\n", + " ('Clovers', 9),\n", + " ('Clubs', 10),\n", + " ('Diamonds', 10),\n", + " ('Hearts', 10),\n", + " ('Clovers', 10),\n", + " ('Clubs', 'Jack'),\n", + " ('Diamonds', 'Jack'),\n", + " ('Hearts', 'Jack'),\n", + " ('Clovers', 'Jack'),\n", + " ('Clubs', 'Queen'),\n", + " ('Diamonds', 'Queen'),\n", + " ('Hearts', 'Queen'),\n", + " ('Clovers', 'Queen'),\n", + " ('Clubs', 'King'),\n", + " ('Diamonds', 'King'),\n", + " ('Hearts', 'King'),\n", + " ('Clovers', 'King'),\n", + " ('Clubs', 'Ace'),\n", + " ('Diamonds', 'Ace'),\n", + " ('Hearts', 'Ace'),\n", + " ('Clovers', 'Ace'),\n", + " ('Clubs', 2),\n", + " ('Diamonds', 2),\n", + " ('Hearts', 2),\n", + " ('Clovers', 2),\n", + " ('Clubs', 3),\n", + " ('Diamonds', 3),\n", + " ('Hearts', 3),\n", + " ('Clovers', 3),\n", + " ('Clubs', 4),\n", + " ('Diamonds', 4),\n", + " ('Hearts', 4),\n", + " ('Clovers', 4),\n", + " ('Clubs', 5),\n", + " ('Diamonds', 5),\n", + " ('Hearts', 5),\n", + " ('Clovers', 5),\n", + " ('Clubs', 6),\n", + " ('Diamonds', 6),\n", + " ('Hearts', 6),\n", + " ('Clovers', 6),\n", + " ('Clubs', 7),\n", + " ('Diamonds', 7),\n", + " ('Hearts', 7),\n", + " ('Clovers', 7),\n", + " ('Clubs', 8),\n", + " ('Diamonds', 8),\n", + " ('Hearts', 8),\n", + " ('Clovers', 8),\n", + " ('Clubs', 9),\n", + " ('Diamonds', 9),\n", + " ('Hearts', 9),\n", + " ('Clovers', 9),\n", + " ('Clubs', 10),\n", + " ('Diamonds', 10),\n", + " ('Hearts', 10),\n", + " ('Clovers', 10),\n", + " ('Clubs', 'Jack'),\n", + " ('Diamonds', 'Jack'),\n", + " ('Hearts', 'Jack'),\n", + " ('Clovers', 'Jack'),\n", + " ('Clubs', 'Queen'),\n", + " ('Diamonds', 'Queen'),\n", + " ('Hearts', 'Queen'),\n", + " ('Clovers', 'Queen'),\n", + " ('Clubs', 'King'),\n", + " ('Diamonds', 'King'),\n", + " ('Hearts', 'King'),\n", + " ('Clovers', 'King'),\n", + " ('Clubs', 'Ace'),\n", + " ('Diamonds', 'Ace'),\n", + " ('Hearts', 'Ace'),\n", + " ('Clovers', 'Ace'),\n", + " ('Clubs', 2),\n", + " ('Diamonds', 2),\n", + " ('Hearts', 2),\n", + " ('Clovers', 2),\n", + " ('Clubs', 3),\n", + " ('Diamonds', 3),\n", + " ('Hearts', 3),\n", + " ('Clovers', 3),\n", + " ('Clubs', 4),\n", + " ('Diamonds', 4),\n", + " ('Hearts', 4),\n", + " ('Clovers', 4),\n", + " ('Clubs', 5),\n", + " ('Diamonds', 5),\n", + " ('Hearts', 5),\n", + " ('Clovers', 5),\n", + " ('Clubs', 6),\n", + " ('Diamonds', 6),\n", + " ('Hearts', 6),\n", + " ('Clovers', 6),\n", + " ('Clubs', 7),\n", + " ('Diamonds', 7),\n", + " ('Hearts', 7),\n", + " ('Clovers', 7),\n", + " ('Clubs', 8),\n", + " ('Diamonds', 8),\n", + " ('Hearts', 8),\n", + " ('Clovers', 8),\n", + " ('Clubs', 9),\n", + " ('Diamonds', 9),\n", + " ('Hearts', 9),\n", + " ('Clovers', 9),\n", + " ('Clubs', 10),\n", + " ('Diamonds', 10),\n", + " ('Hearts', 10),\n", + " ('Clovers', 10),\n", + " ('Clubs', 'Jack'),\n", + " ('Diamonds', 'Jack'),\n", + " ('Hearts', 'Jack'),\n", + " ('Clovers', 'Jack'),\n", + " ('Clubs', 'Queen'),\n", + " ('Diamonds', 'Queen'),\n", + " ('Hearts', 'Queen'),\n", + " ('Clovers', 'Queen'),\n", + " ('Clubs', 'King'),\n", + " ('Diamonds', 'King'),\n", + " ('Hearts', 'King'),\n", + " ('Clovers', 'King'),\n", + " ('Clubs', 'Ace'),\n", + " ('Diamonds', 'Ace'),\n", + " ('Hearts', 'Ace'),\n", + " ('Clovers', 'Ace'),\n", + " ('Clubs', 2),\n", + " ('Diamonds', 2),\n", + " ('Hearts', 2),\n", + " ('Clovers', 2),\n", + " ('Clubs', 3),\n", + " ('Diamonds', 3),\n", + " ('Hearts', 3),\n", + " ('Clovers', 3),\n", + " ('Clubs', 4),\n", + " ('Diamonds', 4),\n", + " ('Hearts', 4),\n", + " ('Clovers', 4),\n", + " ('Clubs', 5),\n", + " ('Diamonds', 5),\n", + " ('Hearts', 5),\n", + " ('Clovers', 5),\n", + " ('Clubs', 6),\n", + " ('Diamonds', 6),\n", + " ('Hearts', 6),\n", + " ('Clovers', 6),\n", + " ('Clubs', 7),\n", + " ('Diamonds', 7),\n", + " ('Hearts', 7),\n", + " ('Clovers', 7),\n", + " ('Clubs', 8),\n", + " ('Diamonds', 8),\n", + " ('Hearts', 8),\n", + " ('Clovers', 8),\n", + " ('Clubs', 9),\n", + " ('Diamonds', 9),\n", + " ('Hearts', 9),\n", + " ('Clovers', 9),\n", + " ('Clubs', 10),\n", + " ('Diamonds', 10),\n", + " ('Hearts', 10),\n", + " ('Clovers', 10),\n", + " ('Clubs', 'Jack'),\n", + " ('Diamonds', 'Jack'),\n", + " ('Hearts', 'Jack'),\n", + " ('Clovers', 'Jack'),\n", + " ('Clubs', 'Queen'),\n", + " ('Diamonds', 'Queen'),\n", + " ('Hearts', 'Queen'),\n", + " ('Clovers', 'Queen'),\n", + " ('Clubs', 'King'),\n", + " ('Diamonds', 'King'),\n", + " ('Hearts', 'King'),\n", + " ('Clovers', 'King'),\n", + " ('Clubs', 'Ace'),\n", + " ('Diamonds', 'Ace'),\n", + " ('Hearts', 'Ace'),\n", + " ('Clovers', 'Ace'),\n", + " ('Clubs', 2),\n", + " ('Diamonds', 2),\n", + " ('Hearts', 2),\n", + " ('Clovers', 2),\n", + " ('Clubs', 3),\n", + " ('Diamonds', 3),\n", + " ('Hearts', 3),\n", + " ('Clovers', 3),\n", + " ('Clubs', 4),\n", + " ('Diamonds', 4),\n", + " ('Hearts', 4),\n", + " ('Clovers', 4),\n", + " ('Clubs', 5),\n", + " ('Diamonds', 5),\n", + " ('Hearts', 5),\n", + " ('Clovers', 5),\n", + " ('Clubs', 6),\n", + " ('Diamonds', 6),\n", + " ('Hearts', 6),\n", + " ('Clovers', 6),\n", + " ('Clubs', 7),\n", + " ('Diamonds', 7),\n", + " ('Hearts', 7),\n", + " ('Clovers', 7),\n", + " ('Clubs', 8),\n", + " ('Diamonds', 8),\n", + " ('Hearts', 8),\n", + " ('Clovers', 8),\n", + " ('Clubs', 9),\n", + " ('Diamonds', 9),\n", + " ('Hearts', 9),\n", + " ('Clovers', 9),\n", + " ('Clubs', 10),\n", + " ('Diamonds', 10),\n", + " ('Hearts', 10),\n", + " ('Clovers', 10),\n", + " ('Clubs', 'Jack'),\n", + " ('Diamonds', 'Jack'),\n", + " ('Hearts', 'Jack'),\n", + " ('Clovers', 'Jack'),\n", + " ('Clubs', 'Queen'),\n", + " ('Diamonds', 'Queen'),\n", + " ('Hearts', 'Queen'),\n", + " ('Clovers', 'Queen'),\n", + " ('Clubs', 'King'),\n", + " ('Diamonds', 'King'),\n", + " ('Hearts', 'King'),\n", + " ('Clovers', 'King'),\n", + " ('Clubs', 'Ace'),\n", + " ('Diamonds', 'Ace'),\n", + " ('Hearts', 'Ace'),\n", + " ('Clovers', 'Ace'),\n", + " ('Clubs', 2),\n", + " ('Diamonds', 2),\n", + " ('Hearts', 2),\n", + " ('Clovers', 2),\n", + " ('Clubs', 3),\n", + " ('Diamonds', 3),\n", + " ('Hearts', 3),\n", + " ('Clovers', 3),\n", + " ('Clubs', 4),\n", + " ('Diamonds', 4),\n", + " ('Hearts', 4),\n", + " ('Clovers', 4),\n", + " ('Clubs', 5),\n", + " ('Diamonds', 5),\n", + " ('Hearts', 5),\n", + " ('Clovers', 5),\n", + " ('Clubs', 6),\n", + " ('Diamonds', 6),\n", + " ('Hearts', 6),\n", + " ('Clovers', 6),\n", + " ('Clubs', 7),\n", + " ('Diamonds', 7),\n", + " ('Hearts', 7),\n", + " ('Clovers', 7),\n", + " ('Clubs', 8),\n", + " ('Diamonds', 8),\n", + " ('Hearts', 8),\n", + " ('Clovers', 8),\n", + " ('Clubs', 9),\n", + " ('Diamonds', 9),\n", + " ('Hearts', 9),\n", + " ('Clovers', 9),\n", + " ('Clubs', 10),\n", + " ('Diamonds', 10),\n", + " ('Hearts', 10),\n", + " ('Clovers', 10),\n", + " ('Clubs', 'Jack'),\n", + " ('Diamonds', 'Jack'),\n", + " ('Hearts', 'Jack'),\n", + " ('Clovers', 'Jack'),\n", + " ('Clubs', 'Queen'),\n", + " ('Diamonds', 'Queen'),\n", + " ('Hearts', 'Queen'),\n", + " ('Clovers', 'Queen'),\n", + " ('Clubs', 'King'),\n", + " ('Diamonds', 'King'),\n", + " ('Hearts', 'King'),\n", + " ('Clovers', 'King'),\n", + " 'plastic']" + ] + }, + "execution_count": 26, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "play_deck=deck()\n", + "play_deck.deck_view()" + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "id": "81f3b03c", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[('Clovers', 2),\n", + " ('Diamonds', 10),\n", + " ('Diamonds', 'Jack'),\n", + " ('Diamonds', 'Jack'),\n", + " ('Clubs', 2),\n", + " ('Clovers', 4),\n", + " ('Clovers', 'Queen'),\n", + " ('Clovers', 'Jack'),\n", + " ('Hearts', 6),\n", + " ('Hearts', 7),\n", + " ('Clubs', 7),\n", + " ('Diamonds', 9),\n", + " ('Diamonds', 'Queen'),\n", + " ('Diamonds', 'Ace'),\n", + " ('Hearts', 'Queen'),\n", + " ('Diamonds', 5),\n", + " ('Clubs', 'Queen'),\n", + " ('Diamonds', 'Jack'),\n", + " ('Diamonds', 'Queen'),\n", + " ('Hearts', 3),\n", + " ('Clubs', 2),\n", + " ('Clubs', 5),\n", + " ('Clovers', 10),\n", + " ('Diamonds', 8),\n", + " ('Clubs', 'King'),\n", + " ('Diamonds', 6),\n", + " ('Clovers', 3),\n", + " ('Clovers', 'Jack'),\n", + " ('Clubs', 'Ace'),\n", + " ('Hearts', 4),\n", + " ('Diamonds', 8),\n", + " ('Hearts', 'Jack'),\n", + " ('Diamonds', 3),\n", + " ('Hearts', 2),\n", + " ('Clubs', 'King'),\n", + " ('Hearts', 'Jack'),\n", + " ('Hearts', 10),\n", + " ('Clovers', 5),\n", + " ('Clovers', 7),\n", + " ('Diamonds', 'King'),\n", + " ('Hearts', 9),\n", + " ('Clubs', 4),\n", + " ('Clovers', 2),\n", + " ('Clovers', 'Queen'),\n", + " ('Clovers', 'King'),\n", + " ('Clubs', 5),\n", + " ('Clubs', 'Jack'),\n", + " ('Clovers', 'Ace'),\n", + " ('Clubs', 6),\n", + " ('Clovers', 'Ace'),\n", + " ('Clubs', 9),\n", + " ('Diamonds', 10),\n", + " ('Clovers', 'Queen'),\n", + " ('Clubs', 10),\n", + " ('Clovers', 3),\n", + " ('Clubs', 3),\n", + " ('Diamonds', 'King'),\n", + " ('Clubs', 7),\n", + " ('Clubs', 2),\n", + " ('Hearts', 'Ace'),\n", + " ('Hearts', 'King'),\n", + " ('Hearts', 'King'),\n", + " ('Clovers', 4),\n", + " ('Clovers', 'Queen'),\n", + " ('Clubs', 3),\n", + " ('Clovers', 4),\n", + " ('Hearts', 4),\n", + " ('Diamonds', 'Jack'),\n", + " ('Clovers', 9),\n", + " ('Clovers', 'King'),\n", + " ('Diamonds', 6),\n", + " ('Hearts', 10),\n", + " ('Clubs', 3),\n", + " ('Clubs', 3),\n", + " ('Hearts', 8),\n", + " ('Clubs', 9),\n", + " ('Clovers', 6),\n", + " ('Hearts', 3),\n", + " ('Clovers', 10),\n", + " ('Diamonds', 'King'),\n", + " ('Hearts', 'Queen'),\n", + " ('Clubs', 8),\n", + " ('Clubs', 'Ace'),\n", + " ('Diamonds', 7),\n", + " ('Clovers', 5),\n", + " ('Clovers', 'Jack'),\n", + " ('Diamonds', 3),\n", + " ('Hearts', 8),\n", + " ('Clovers', 'King'),\n", + " ('Clubs', 9),\n", + " ('Clovers', 3),\n", + " ('Hearts', 'Queen'),\n", + " ('Diamonds', 2),\n", + " ('Clovers', 'Jack'),\n", + " ('Clubs', 'Queen'),\n", + " ('Hearts', 8),\n", + " ('Clovers', 6),\n", + " ('Hearts', 7),\n", + " ('Diamonds', 2),\n", + " ('Clubs', 7),\n", + " ('Hearts', 6),\n", + " ('Clubs', 4),\n", + " ('Hearts', 7),\n", + " ('Clubs', 4),\n", + " ('Diamonds', 5),\n", + " ('Diamonds', 5),\n", + " ('Clovers', 'King'),\n", + " ('Clubs', 4),\n", + " ('Clubs', 'King'),\n", + " ('Hearts', 4),\n", + " ('Hearts', 'Queen'),\n", + " ('Hearts', 7),\n", + " ('Clovers', 5),\n", + " ('Hearts', 3),\n", + " ('Hearts', 2),\n", + " ('Clovers', 7),\n", + " ('Diamonds', 4),\n", + " ('Clovers', 8),\n", + " ('Clubs', 10),\n", + " ('Hearts', 8),\n", + " ('Clubs', 9),\n", + " ('Diamonds', 2),\n", + " ('Hearts', 2),\n", + " ('Clovers', 'Ace'),\n", + " ('Clovers', 'Ace'),\n", + " ('Clovers', 8),\n", + " ('Diamonds', 5),\n", + " ('Diamonds', 'Ace'),\n", + " ('Hearts', 6),\n", + " ('Clubs', 'Ace'),\n", + " ('Hearts', 4),\n", + " ('Diamonds', 6),\n", + " ('Clubs', 8),\n", + " ('Clubs', 'Jack'),\n", + " ('Hearts', 5),\n", + " ('Diamonds', 7),\n", + " ('Hearts', 6),\n", + " ('Hearts', 'Jack'),\n", + " ('Clubs', 8),\n", + " ('Diamonds', 4),\n", + " ('Diamonds', 8),\n", + " ('Clovers', 3),\n", + " ('Clovers', 2),\n", + " ('Clovers', 10),\n", + " ('Hearts', 4),\n", + " ('Diamonds', 2),\n", + " ('Diamonds', 'Queen'),\n", + " ('Clovers', 9),\n", + " ('Hearts', 7),\n", + " ('Diamonds', 5),\n", + " ('Diamonds', 4),\n", + " ('Clovers', 6),\n", + " ('Clovers', 3),\n", + " ('Clubs', 'Queen'),\n", + " ('Diamonds', 7),\n", + " ('Clovers', 10),\n", + " ('Clovers', 4),\n", + " ('Clubs', 2),\n", + " ('Clovers', 'King'),\n", + " ('Diamonds', 9),\n", + " ('Clubs', 2),\n", + " ('Hearts', 'King'),\n", + " ('Clubs', 5),\n", + " ('Hearts', 2),\n", + " ('Hearts', 'King'),\n", + " ('Diamonds', 3),\n", + " ('Clovers', 5),\n", + " ('Clovers', 9),\n", + " ('Diamonds', 'King'),\n", + " ('Clovers', 6),\n", + " ('Diamonds', 'Ace'),\n", + " ('Clovers', 2),\n", + " ('Diamonds', 'Ace'),\n", + " ('Clovers', 'Jack'),\n", + " ('Hearts', 'Ace'),\n", + " ('Diamonds', 8),\n", + " ('Hearts', 5),\n", + " ('Diamonds', 3),\n", + " ('Clovers', 10),\n", + " ('Clubs', 'King'),\n", + " ('Diamonds', 'Ace'),\n", + " ('Clovers', 8),\n", + " ('Hearts', 4),\n", + " ('Clubs', 7),\n", + " ('Clubs', 'Jack'),\n", + " ('Diamonds', 2),\n", + " ('Diamonds', 10),\n", + " ('Diamonds', 6),\n", + " ('Clubs', 'Queen'),\n", + " ('Hearts', 7),\n", + " ('Hearts', 9),\n", + " ('Clovers', 4),\n", + " ('Clubs', 'Jack'),\n", + " ('Clovers', 7),\n", + " ('Diamonds', 2),\n", + " ('Hearts', 5),\n", + " ('Clubs', 'Jack'),\n", + " ('Hearts', 8),\n", + " ('Clubs', 10),\n", + " ('Clubs', 10),\n", + " ('Diamonds', 4),\n", + " ('Clubs', 8),\n", + " ('Diamonds', 'Jack'),\n", + " ('Hearts', 'Ace'),\n", + " ('Clovers', 8),\n", + " ('Clovers', 8),\n", + " ('Clovers', 6),\n", + " ('Clubs', 5),\n", + " ('Diamonds', 9),\n", + " ('Diamonds', 6),\n", + " ('Diamonds', 'Queen'),\n", + " ('Hearts', 3),\n", + " ('Diamonds', 6),\n", + " ('Diamonds', 8),\n", + " ('Clovers', 5),\n", + " ('Diamonds', 10),\n", + " 'plastic',\n", + " ('Clubs', 'Ace'),\n", + " ('Clovers', 2),\n", + " ('Clubs', 'Ace'),\n", + " ('Clovers', 5),\n", + " ('Clubs', 5),\n", + " ('Diamonds', 'Queen'),\n", + " ('Hearts', 9),\n", + " ('Diamonds', 9),\n", + " ('Clovers', 9),\n", + " ('Clovers', 9),\n", + " ('Clubs', 'King'),\n", + " ('Diamonds', 8),\n", + " ('Clovers', 'King'),\n", + " ('Diamonds', 7),\n", + " ('Clovers', 'Queen'),\n", + " ('Hearts', 6),\n", + " ('Diamonds', 10),\n", + " ('Clubs', 'Ace'),\n", + " ('Hearts', 2),\n", + " ('Diamonds', 7),\n", + " ('Hearts', 10),\n", + " ('Clubs', 9),\n", + " ('Clubs', 7),\n", + " ('Hearts', 9),\n", + " ('Diamonds', 4),\n", + " ('Diamonds', 9),\n", + " ('Clovers', 2),\n", + " ('Clubs', 8),\n", + " ('Clovers', 8),\n", + " ('Clovers', 7),\n", + " ('Clubs', 4),\n", + " ('Hearts', 8),\n", + " ('Hearts', 'Ace'),\n", + " ('Clovers', 'Jack'),\n", + " ('Diamonds', 4),\n", + " ('Clovers', 'Queen'),\n", + " ('Clovers', 10),\n", + " ('Diamonds', 10),\n", + " ('Clubs', 'Jack'),\n", + " ('Clubs', 8),\n", + " ('Hearts', 10),\n", + " ('Hearts', 'Jack'),\n", + " ('Hearts', 6),\n", + " ('Clovers', 6),\n", + " ('Diamonds', 'King'),\n", + " ('Clubs', 10),\n", + " ('Clubs', 'Queen'),\n", + " ('Clovers', 'Ace'),\n", + " ('Clubs', 3),\n", + " ('Hearts', 9),\n", + " ('Hearts', 3),\n", + " ('Hearts', 10),\n", + " ('Diamonds', 9),\n", + " ('Clubs', 2),\n", + " ('Hearts', 'King'),\n", + " ('Clovers', 'Ace'),\n", + " ('Hearts', 'Jack'),\n", + " ('Hearts', 9),\n", + " ('Diamonds', 'King'),\n", + " ('Hearts', 'Queen'),\n", + " ('Clovers', 9),\n", + " ('Diamonds', 'Jack'),\n", + " ('Hearts', 10),\n", + " ('Diamonds', 3),\n", + " ('Clubs', 'Queen'),\n", + " ('Clubs', 3),\n", + " ('Clubs', 10),\n", + " ('Diamonds', 'Queen'),\n", + " ('Hearts', 5),\n", + " ('Clovers', 4),\n", + " ('Clubs', 6),\n", + " ('Clubs', 4),\n", + " ('Hearts', 3),\n", + " ('Clubs', 6),\n", + " ('Clovers', 7),\n", + " ('Hearts', 'Jack'),\n", + " ('Diamonds', 'Ace'),\n", + " ('Hearts', 'King'),\n", + " ('Clubs', 9),\n", + " ('Hearts', 2),\n", + " ('Hearts', 5),\n", + " ('Diamonds', 3),\n", + " ('Hearts', 'Ace'),\n", + " ('Clovers', 3),\n", + " ('Clubs', 7),\n", + " ('Clubs', 5),\n", + " ('Clubs', 'King'),\n", + " ('Clovers', 7),\n", + " ('Clubs', 6),\n", + " ('Hearts', 5),\n", + " ('Diamonds', 7),\n", + " ('Clubs', 6),\n", + " ('Diamonds', 5),\n", + " ('Clubs', 6),\n", + " ('Hearts', 'Ace'),\n", + " ('Hearts', 'Queen')]" + ] + }, + "execution_count": 27, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "play_deck.shuffle()" + ] + }, + { + "cell_type": "code", + "execution_count": 38, + "id": "b5113981", + "metadata": {}, + "outputs": [], + "source": [ + "#File Write\n", + "import pickle\n", + "with open('file.pickle',\"wb\") as f: \n", + " pickle.dump(play_deck,f)" + ] + }, + { + "cell_type": "code", + "execution_count": 39, + "id": "90a8e240", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[('Clovers', 2),\n", + " ('Diamonds', 10),\n", + " ('Diamonds', 'Jack'),\n", + " ('Diamonds', 'Jack'),\n", + " ('Clubs', 2),\n", + " ('Clovers', 4),\n", + " ('Clovers', 'Queen'),\n", + " ('Clovers', 'Jack'),\n", + " ('Hearts', 6),\n", + " ('Hearts', 7),\n", + " ('Clubs', 7),\n", + " ('Diamonds', 9),\n", + " ('Diamonds', 'Queen'),\n", + " ('Diamonds', 'Ace'),\n", + " ('Hearts', 'Queen'),\n", + " ('Diamonds', 5),\n", + " ('Clubs', 'Queen'),\n", + " ('Diamonds', 'Jack'),\n", + " ('Diamonds', 'Queen'),\n", + " ('Hearts', 3),\n", + " ('Clubs', 2),\n", + " ('Clubs', 5),\n", + " ('Clovers', 10),\n", + " ('Diamonds', 8),\n", + " ('Clubs', 'King'),\n", + " ('Diamonds', 6),\n", + " ('Clovers', 3),\n", + " ('Clovers', 'Jack'),\n", + " ('Clubs', 'Ace'),\n", + " ('Hearts', 4),\n", + " ('Diamonds', 8),\n", + " ('Hearts', 'Jack'),\n", + " ('Diamonds', 3),\n", + " ('Hearts', 2),\n", + " ('Clubs', 'King'),\n", + " ('Hearts', 'Jack'),\n", + " ('Hearts', 10),\n", + " ('Clovers', 5),\n", + " ('Clovers', 7),\n", + " ('Diamonds', 'King'),\n", + " ('Hearts', 9),\n", + " ('Clubs', 4),\n", + " ('Clovers', 2),\n", + " ('Clovers', 'Queen'),\n", + " ('Clovers', 'King'),\n", + " ('Clubs', 5),\n", + " ('Clubs', 'Jack'),\n", + " ('Clovers', 'Ace'),\n", + " ('Clubs', 6),\n", + " ('Clovers', 'Ace'),\n", + " ('Clubs', 9),\n", + " ('Diamonds', 10),\n", + " ('Clovers', 'Queen'),\n", + " ('Clubs', 10),\n", + " ('Clovers', 3),\n", + " ('Clubs', 3),\n", + " ('Diamonds', 'King'),\n", + " ('Clubs', 7),\n", + " ('Clubs', 2),\n", + " ('Hearts', 'Ace'),\n", + " ('Hearts', 'King'),\n", + " ('Hearts', 'King'),\n", + " ('Clovers', 4),\n", + " ('Clovers', 'Queen'),\n", + " ('Clubs', 3),\n", + " ('Clovers', 4),\n", + " ('Hearts', 4),\n", + " ('Diamonds', 'Jack'),\n", + " ('Clovers', 9),\n", + " ('Clovers', 'King'),\n", + " ('Diamonds', 6),\n", + " ('Hearts', 10),\n", + " ('Clubs', 3),\n", + " ('Clubs', 3),\n", + " ('Hearts', 8),\n", + " ('Clubs', 9),\n", + " ('Clovers', 6),\n", + " ('Hearts', 3),\n", + " ('Clovers', 10),\n", + " ('Diamonds', 'King'),\n", + " ('Hearts', 'Queen'),\n", + " ('Clubs', 8),\n", + " ('Clubs', 'Ace'),\n", + " ('Diamonds', 7),\n", + " ('Clovers', 5),\n", + " ('Clovers', 'Jack'),\n", + " ('Diamonds', 3),\n", + " ('Hearts', 8),\n", + " ('Clovers', 'King'),\n", + " ('Clubs', 9),\n", + " ('Clovers', 3),\n", + " ('Hearts', 'Queen'),\n", + " ('Diamonds', 2),\n", + " ('Clovers', 'Jack'),\n", + " ('Clubs', 'Queen'),\n", + " ('Hearts', 8),\n", + " ('Clovers', 6),\n", + " ('Hearts', 7),\n", + " ('Diamonds', 2),\n", + " ('Clubs', 7),\n", + " ('Hearts', 6),\n", + " ('Clubs', 4),\n", + " ('Hearts', 7),\n", + " ('Clubs', 4),\n", + " ('Diamonds', 5),\n", + " ('Diamonds', 5),\n", + " ('Clovers', 'King'),\n", + " ('Clubs', 4),\n", + " ('Clubs', 'King'),\n", + " ('Hearts', 4),\n", + " ('Hearts', 'Queen'),\n", + " ('Hearts', 7),\n", + " ('Clovers', 5),\n", + " ('Hearts', 3),\n", + " ('Hearts', 2),\n", + " ('Clovers', 7),\n", + " ('Diamonds', 4),\n", + " ('Clovers', 8),\n", + " ('Clubs', 10),\n", + " ('Hearts', 8),\n", + " ('Clubs', 9),\n", + " ('Diamonds', 2),\n", + " ('Hearts', 2),\n", + " ('Clovers', 'Ace'),\n", + " ('Clovers', 'Ace'),\n", + " ('Clovers', 8),\n", + " ('Diamonds', 5),\n", + " ('Diamonds', 'Ace'),\n", + " ('Hearts', 6),\n", + " ('Clubs', 'Ace'),\n", + " ('Hearts', 4),\n", + " ('Diamonds', 6),\n", + " ('Clubs', 8),\n", + " ('Clubs', 'Jack'),\n", + " ('Hearts', 5),\n", + " ('Diamonds', 7),\n", + " ('Hearts', 6),\n", + " ('Hearts', 'Jack'),\n", + " ('Clubs', 8),\n", + " ('Diamonds', 4),\n", + " ('Diamonds', 8),\n", + " ('Clovers', 3),\n", + " ('Clovers', 2),\n", + " ('Clovers', 10),\n", + " ('Hearts', 4),\n", + " ('Diamonds', 2),\n", + " ('Diamonds', 'Queen'),\n", + " ('Clovers', 9),\n", + " ('Hearts', 7),\n", + " ('Diamonds', 5),\n", + " ('Diamonds', 4),\n", + " ('Clovers', 6),\n", + " ('Clovers', 3),\n", + " ('Clubs', 'Queen'),\n", + " ('Diamonds', 7),\n", + " ('Clovers', 10),\n", + " ('Clovers', 4),\n", + " ('Clubs', 2),\n", + " ('Clovers', 'King'),\n", + " ('Diamonds', 9),\n", + " ('Clubs', 2),\n", + " ('Hearts', 'King'),\n", + " ('Clubs', 5),\n", + " ('Hearts', 2),\n", + " ('Hearts', 'King'),\n", + " ('Diamonds', 3),\n", + " ('Clovers', 5),\n", + " ('Clovers', 9),\n", + " ('Diamonds', 'King'),\n", + " ('Clovers', 6),\n", + " ('Diamonds', 'Ace'),\n", + " ('Clovers', 2),\n", + " ('Diamonds', 'Ace'),\n", + " ('Clovers', 'Jack'),\n", + " ('Hearts', 'Ace'),\n", + " ('Diamonds', 8),\n", + " ('Hearts', 5),\n", + " ('Diamonds', 3),\n", + " ('Clovers', 10),\n", + " ('Clubs', 'King'),\n", + " ('Diamonds', 'Ace'),\n", + " ('Clovers', 8),\n", + " ('Hearts', 4),\n", + " ('Clubs', 7),\n", + " ('Clubs', 'Jack'),\n", + " ('Diamonds', 2),\n", + " ('Diamonds', 10),\n", + " ('Diamonds', 6),\n", + " ('Clubs', 'Queen'),\n", + " ('Hearts', 7),\n", + " ('Hearts', 9),\n", + " ('Clovers', 4),\n", + " ('Clubs', 'Jack'),\n", + " ('Clovers', 7),\n", + " ('Diamonds', 2),\n", + " ('Hearts', 5),\n", + " ('Clubs', 'Jack'),\n", + " ('Hearts', 8),\n", + " ('Clubs', 10),\n", + " ('Clubs', 10),\n", + " ('Diamonds', 4),\n", + " ('Clubs', 8),\n", + " ('Diamonds', 'Jack'),\n", + " ('Hearts', 'Ace'),\n", + " ('Clovers', 8),\n", + " ('Clovers', 8),\n", + " ('Clovers', 6),\n", + " ('Clubs', 5),\n", + " ('Diamonds', 9),\n", + " ('Diamonds', 6),\n", + " ('Diamonds', 'Queen'),\n", + " ('Hearts', 3),\n", + " ('Diamonds', 6),\n", + " ('Diamonds', 8),\n", + " ('Clovers', 5),\n", + " ('Diamonds', 10),\n", + " 'plastic',\n", + " ('Clubs', 'Ace'),\n", + " ('Clovers', 2),\n", + " ('Clubs', 'Ace'),\n", + " ('Clovers', 5),\n", + " ('Clubs', 5),\n", + " ('Diamonds', 'Queen'),\n", + " ('Hearts', 9),\n", + " ('Diamonds', 9),\n", + " ('Clovers', 9),\n", + " ('Clovers', 9),\n", + " ('Clubs', 'King'),\n", + " ('Diamonds', 8),\n", + " ('Clovers', 'King'),\n", + " ('Diamonds', 7),\n", + " ('Clovers', 'Queen'),\n", + " ('Hearts', 6),\n", + " ('Diamonds', 10),\n", + " ('Clubs', 'Ace'),\n", + " ('Hearts', 2),\n", + " ('Diamonds', 7),\n", + " ('Hearts', 10),\n", + " ('Clubs', 9),\n", + " ('Clubs', 7),\n", + " ('Hearts', 9),\n", + " ('Diamonds', 4),\n", + " ('Diamonds', 9),\n", + " ('Clovers', 2),\n", + " ('Clubs', 8),\n", + " ('Clovers', 8),\n", + " ('Clovers', 7),\n", + " ('Clubs', 4),\n", + " ('Hearts', 8),\n", + " ('Hearts', 'Ace'),\n", + " ('Clovers', 'Jack'),\n", + " ('Diamonds', 4),\n", + " ('Clovers', 'Queen'),\n", + " ('Clovers', 10),\n", + " ('Diamonds', 10),\n", + " ('Clubs', 'Jack'),\n", + " ('Clubs', 8),\n", + " ('Hearts', 10),\n", + " ('Hearts', 'Jack'),\n", + " ('Hearts', 6),\n", + " ('Clovers', 6),\n", + " ('Diamonds', 'King'),\n", + " ('Clubs', 10),\n", + " ('Clubs', 'Queen'),\n", + " ('Clovers', 'Ace'),\n", + " ('Clubs', 3),\n", + " ('Hearts', 9),\n", + " ('Hearts', 3),\n", + " ('Hearts', 10),\n", + " ('Diamonds', 9),\n", + " ('Clubs', 2),\n", + " ('Hearts', 'King'),\n", + " ('Clovers', 'Ace'),\n", + " ('Hearts', 'Jack'),\n", + " ('Hearts', 9),\n", + " ('Diamonds', 'King'),\n", + " ('Hearts', 'Queen'),\n", + " ('Clovers', 9),\n", + " ('Diamonds', 'Jack'),\n", + " ('Hearts', 10),\n", + " ('Diamonds', 3),\n", + " ('Clubs', 'Queen'),\n", + " ('Clubs', 3),\n", + " ('Clubs', 10),\n", + " ('Diamonds', 'Queen'),\n", + " ('Hearts', 5),\n", + " ('Clovers', 4),\n", + " ('Clubs', 6),\n", + " ('Clubs', 4),\n", + " ('Hearts', 3),\n", + " ('Clubs', 6),\n", + " ('Clovers', 7),\n", + " ('Hearts', 'Jack'),\n", + " ('Diamonds', 'Ace'),\n", + " ('Hearts', 'King'),\n", + " ('Clubs', 9),\n", + " ('Hearts', 2),\n", + " ('Hearts', 5),\n", + " ('Diamonds', 3),\n", + " ('Hearts', 'Ace'),\n", + " ('Clovers', 3),\n", + " ('Clubs', 7),\n", + " ('Clubs', 5),\n", + " ('Clubs', 'King'),\n", + " ('Clovers', 7),\n", + " ('Clubs', 6),\n", + " ('Hearts', 5),\n", + " ('Diamonds', 7),\n", + " ('Clubs', 6),\n", + " ('Diamonds', 5),\n", + " ('Clubs', 6),\n", + " ('Hearts', 'Ace'),\n", + " ('Hearts', 'Queen')]" + ] + }, + "execution_count": 39, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#File load\n", + "with open('file.pickle', 'rb') as f: \n", + " play_deck_reloaded = pickle.load(f)\n", + "play_deck_reloaded.deck_view()" + ] + }, + { + "cell_type": "code", + "execution_count": 42, + "id": "9cb5067a", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 42, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "test=play_deck.deck_view()\n", + "test1=play_deck_reloaded.deck_view()\n", + "\n", + "for i in range(len(test)):\n", + " if test[i]==test1[i]:\n", + " same=True\n", + " else:\n", + " same=False\n", + "same\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.9" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}