{"id":148,"date":"2026-04-10T14:04:31","date_gmt":"2026-04-10T14:04:31","guid":{"rendered":"https:\/\/theroyalscode.com\/students\/d_harkless\/?p=148"},"modified":"2026-04-10T14:04:31","modified_gmt":"2026-04-10T14:04:31","slug":"free-friday-4-10-26","status":"publish","type":"post","link":"https:\/\/theroyalscode.com\/students\/d_harkless\/2026\/04\/10\/free-friday-4-10-26\/","title":{"rendered":"Free Friday 4\/10\/26"},"content":{"rendered":"\n<p>Today in class, I made a dice roller program. It asks the user how many dice they want then adds the number of die up and tells the total.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"603\" height=\"122\" src=\"https:\/\/theroyalscode.com\/students\/d_harkless\/wp-content\/uploads\/2026\/04\/image-1.png\" alt=\"\" class=\"wp-image-150\" style=\"aspect-ratio:4.943001686340641;width:496px;height:auto\" srcset=\"https:\/\/theroyalscode.com\/students\/d_harkless\/wp-content\/uploads\/2026\/04\/image-1.png 603w, https:\/\/theroyalscode.com\/students\/d_harkless\/wp-content\/uploads\/2026\/04\/image-1-300x61.png 300w\" sizes=\"auto, (max-width: 603px) 100vw, 603px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"284\" height=\"121\" src=\"https:\/\/theroyalscode.com\/students\/d_harkless\/wp-content\/uploads\/2026\/04\/image.png\" alt=\"\" class=\"wp-image-149\" style=\"width:256px;height:auto\"\/><\/figure>\n\n\n\n<p>This the code for the dice.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>dice_art = {\n    1: (\"\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\",\n        \"\u2502         \u2502\",\n        \"\u2502    \u25cf    \u2502\",\n        \"\u2502         \u2502\",\n        \"\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\"),\n    2: (\"\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\",\n        \"\u2502  \u25cf      \u2502\",\n        \"\u2502         \u2502\",\n        \"\u2502      \u25cf  \u2502\",\n        \"\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\"),\n    3: (\"\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\",\n        \"\u2502  \u25cf      \u2502\",\n        \"\u2502    \u25cf    \u2502\",\n        \"\u2502      \u25cf  \u2502\",\n        \"\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\"),\n    4: (\"\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\",\n        \"\u2502  \u25cf   \u25cf  \u2502\",\n        \"\u2502         \u2502\",\n        \"\u2502  \u25cf   \u25cf  \u2502\",\n        \"\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\"),\n    5: (\"\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\",\n        \"\u2502  \u25cf   \u25cf  \u2502\",\n        \"\u2502    \u25cf    \u2502\",\n        \"\u2502  \u25cf   \u25cf  \u2502\",\n        \"\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\"),\n    6: (\"\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\",\n        \"\u2502  \u25cf   \u25cf  \u2502\",\n        \"\u2502  \u25cf   \u25cf  \u2502\",\n        \"\u2502  \u25cf   \u25cf  \u2502\",\n        \"\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\")\n}\n\n<\/code><\/pre>\n\n\n\n<p>This is the code that gets random dices out of 6.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>for die in range(num_of_dice):\n    dice.append(random.randint(1, 6))\n<\/code><\/pre>\n\n\n\n<p>This is the code that prints all the dice horizontally.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>for line in range(5):\n    for die in dice:\n        print(dice_art.get(die)&#91;line], end =\"\")\n    print()<\/code><\/pre>\n\n\n\n<p>This is the code to print all the dice vertically.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>for die in range(num_of_dice):\n    for line in dice_art.get(dice&#91;die]):\n        print(line)<\/code><\/pre>\n\n\n\n<p>This is the code that counts the die on the dice and adds them up.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>for die in dice:\n    total += die\nprint(f\"total:{total}\")    <\/code><\/pre>\n\n\n\n<p>I also made a encryption program. It asks the user to enter a message to encrypt and it encrypts the message.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"289\" height=\"88\" src=\"https:\/\/theroyalscode.com\/students\/d_harkless\/wp-content\/uploads\/2026\/04\/image-3.png\" alt=\"\" class=\"wp-image-152\"\/><\/figure>\n\n\n\n<p>This is the code for the letters, digits, and punctuation used to encrypt the message.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>chars = \" \" + string.punctuation + string.digits + string.ascii_letters\nchars = list(chars)\nkey = chars.copy()<\/code><\/pre>\n\n\n\n<p>This is the code that shuffles the keys used for the encrypted message.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>random.shuffle(key)\n<\/code><\/pre>\n\n\n\n<p>This is the code that asks the user to enter a message to encrypt then it encrypts the message and shows the original message and encrypted message.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>plain_text = input(\"Enter a message to encrypt: \")\ncipher_text = \"\"\n\nfor letter in plain_text:\n    index = chars.index(letter)\n    cipher_text += key&#91;index]\n\nprint(f\"original message : {plain_text}\")\nprint(f\"encrypted message: {cipher_text}\")\n<\/code><\/pre>\n\n\n\n<p>This is the code that decrypts the message.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cipher_text = input(\"Enter a message to encrypt: \")\nplain_text = \"\"\n\nfor letter in cipher_text:\n    index = key.index(letter)\n    plain_text += chars&#91;index]\n\nprint(f\"encrypted message: {cipher_text}\")\nprint(f\"original message : {plain_text}\")<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"323\" height=\"108\" src=\"https:\/\/theroyalscode.com\/students\/d_harkless\/wp-content\/uploads\/2026\/04\/image-4.png\" alt=\"\" class=\"wp-image-153\" style=\"aspect-ratio:2.9910777510267668;width:362px;height:auto\" srcset=\"https:\/\/theroyalscode.com\/students\/d_harkless\/wp-content\/uploads\/2026\/04\/image-4.png 323w, https:\/\/theroyalscode.com\/students\/d_harkless\/wp-content\/uploads\/2026\/04\/image-4-300x100.png 300w\" sizes=\"auto, (max-width: 323px) 100vw, 323px\" \/><\/figure>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today in class, I made a dice roller program. It asks the user how many dice they want then adds the number of die up and tells the total. This the code for the dice. This is the code that gets random dices out of 6. This is the code that prints all the dice [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-148","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/theroyalscode.com\/students\/d_harkless\/wp-json\/wp\/v2\/posts\/148","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/theroyalscode.com\/students\/d_harkless\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/theroyalscode.com\/students\/d_harkless\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/theroyalscode.com\/students\/d_harkless\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/theroyalscode.com\/students\/d_harkless\/wp-json\/wp\/v2\/comments?post=148"}],"version-history":[{"count":1,"href":"https:\/\/theroyalscode.com\/students\/d_harkless\/wp-json\/wp\/v2\/posts\/148\/revisions"}],"predecessor-version":[{"id":154,"href":"https:\/\/theroyalscode.com\/students\/d_harkless\/wp-json\/wp\/v2\/posts\/148\/revisions\/154"}],"wp:attachment":[{"href":"https:\/\/theroyalscode.com\/students\/d_harkless\/wp-json\/wp\/v2\/media?parent=148"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/theroyalscode.com\/students\/d_harkless\/wp-json\/wp\/v2\/categories?post=148"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/theroyalscode.com\/students\/d_harkless\/wp-json\/wp\/v2\/tags?post=148"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}