{"id":196,"date":"2025-12-19T20:36:02","date_gmt":"2025-12-19T20:36:02","guid":{"rendered":"https:\/\/theroyalscode.com\/students\/g_cruz\/?p=196"},"modified":"2025-12-19T20:36:02","modified_gmt":"2025-12-19T20:36:02","slug":"rock-paper-scissors-huh","status":"publish","type":"post","link":"https:\/\/theroyalscode.com\/students\/g_cruz\/2025\/12\/19\/rock-paper-scissors-huh\/","title":{"rendered":"Rock Paper Scissors! (Huh)"},"content":{"rendered":"\n<p>I made rock\/paper\/scissors in short time<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Code:<\/p>\n\n\n\n<p>#imports<\/p>\n\n\n\n<p>import time, random, sys, getpass<\/p>\n\n\n\n<p>#variables<\/p>\n\n\n\n<p>pause = 1<\/p>\n\n\n\n<p>player_1 = &#8220;&#8221;<\/p>\n\n\n\n<p>player_2 = &#8220;&#8221;<\/p>\n\n\n\n<p>#define what&#8217;s done when the player wins<\/p>\n\n\n\n<p>def win(player_w, player_l):<\/p>\n\n\n\n<p>&nbsp; &nbsp; print(f&#8221;Player {player_w} defeats {player_l}!&#8221;)<\/p>\n\n\n\n<p>&nbsp; &nbsp; while True:<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; choice = str(input(&#8220;Do you want to play again?\\n&gt;\\t&#8221;))<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; if &#8220;y&#8221; in choice.lower() or &#8220;yes&#8221; in choice.lower():<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; elif &#8220;n&#8221;in choice.lower() or &#8220;no&#8221; in choice.lower():<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sys.exit()<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; else:<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print(&#8220;Invalid answer, try again&#8221;)<\/p>\n\n\n\n<p>#define what&#8217;s done when the player loses<\/p>\n\n\n\n<p>def draw():<\/p>\n\n\n\n<p>&nbsp; &nbsp; print(&#8220;DRAW!&#8221;)<\/p>\n\n\n\n<p>&nbsp; &nbsp; while True:<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; choice = str(input(&#8220;Do you want to play again?\\n&gt; &#8220;))<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; if &#8220;y&#8221; in choice.lower() or &#8220;yes&#8221; in choice.lower():<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; elif &#8220;n&#8221;in choice.lower() or &#8220;no&#8221; in choice.lower():<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sys.exit()<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; else:<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print(&#8220;Invalid answer, try again&#8221;)<\/p>\n\n\n\n<p>#main<\/p>\n\n\n\n<p>while True:<\/p>\n\n\n\n<p>&nbsp; &nbsp; #make the choice of playing optional<\/p>\n\n\n\n<p>&nbsp; &nbsp; while True:<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; choice = str(input(&#8220;Are you ready?\\n&gt;\\t&#8221;))<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; if &#8220;y&#8221; in choice.lower() or &#8220;yes&#8221; in choice.lower():<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print(&#8220;Great!&#8221;)<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; time.sleep(pause)<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; elif &#8220;n&#8221;in choice.lower() or &#8220;no&#8221; in choice.lower():<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print(&#8220;Pussies&#8221;)<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; time.sleep(pause)<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sys.exit()<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; else:<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print(&#8220;Invalid answer, try again&#8221;)<\/p>\n\n\n\n<p>&nbsp; &nbsp; #get first player&#8217;s choice<\/p>\n\n\n\n<p>&nbsp; &nbsp; while True:<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; player_1 = str(getpass.getpass(&#8220;Player 1, choose\\n&gt;\\t&#8221;))<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; if player_1.lower() == &#8220;rock&#8221; or player_1.lower() == &#8220;paper&#8221; or player_1.lower() == &#8220;scissors&#8221;:<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print(&#8220;Got it&#8221;)<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; time.sleep(pause)<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; else:<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print(&#8220;Invalid choice, try again&#8221;)<\/p>\n\n\n\n<p>&nbsp; &nbsp; #get second player&#8217;s choice<\/p>\n\n\n\n<p>&nbsp; &nbsp; while True:<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; player_2 = str(getpass.getpass(&#8220;Player 2, choose\\n&gt;\\t&#8221;))<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; if player_2.lower() == &#8220;rock&#8221; or player_2.lower() == &#8220;paper&#8221; or player_2.lower() == &#8220;scissors&#8221;:<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print(&#8220;Got it&#8221;)<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; time.sleep(pause)<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; else:<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print(&#8220;Invalid choice, try again&#8221;)<\/p>\n\n\n\n<p>&nbsp; &nbsp; if player_1 == player_2:<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; draw()<\/p>\n\n\n\n<p>&nbsp; &nbsp; elif player_1 == &#8220;rock&#8221; and player_2 == &#8220;scissors&#8221;:<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; win(1,2)<\/p>\n\n\n\n<p>&nbsp; &nbsp; elif player_1 == &#8220;paper&#8221; and player_2 == &#8220;rock&#8221;:<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; win(1,2)<\/p>\n\n\n\n<p>&nbsp; &nbsp; elif player_1 == &#8220;scissors&#8221; and player_2 == &#8220;paper&#8221;:<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; win(1,2)<\/p>\n\n\n\n<p>&nbsp; &nbsp; elif player_2 == &#8220;rock&#8221; and player_1 == &#8220;scissors&#8221;:<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; win(2,1)<\/p>\n\n\n\n<p>&nbsp; &nbsp; elif player_2 == &#8220;paper&#8221; and player_1 == &#8220;rock&#8221;:<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; win(2,1)<\/p>\n\n\n\n<p>&nbsp; &nbsp; elif player_2 == &#8220;scissors&#8221; and player_1 == &#8220;paper&#8221;:<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; win(2,1)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I made rock\/paper\/scissors in short time Code: #imports import time, random, sys, getpass #variables pause = 1 player_1 = &#8220;&#8221; player_2 = &#8220;&#8221; #define what&#8217;s done when the player wins def win(player_w, player_l): &nbsp; &nbsp; print(f&#8221;Player {player_w} defeats {player_l}!&#8221;) &nbsp; &nbsp; while True: &nbsp; &nbsp; &nbsp; &nbsp; choice = str(input(&#8220;Do you want to play again?\\n&gt;\\t&#8221;)) [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-196","post","type-post","status-publish","format-standard","hentry","category-progress"],"_links":{"self":[{"href":"https:\/\/theroyalscode.com\/students\/g_cruz\/wp-json\/wp\/v2\/posts\/196","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/theroyalscode.com\/students\/g_cruz\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/theroyalscode.com\/students\/g_cruz\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/theroyalscode.com\/students\/g_cruz\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/theroyalscode.com\/students\/g_cruz\/wp-json\/wp\/v2\/comments?post=196"}],"version-history":[{"count":2,"href":"https:\/\/theroyalscode.com\/students\/g_cruz\/wp-json\/wp\/v2\/posts\/196\/revisions"}],"predecessor-version":[{"id":198,"href":"https:\/\/theroyalscode.com\/students\/g_cruz\/wp-json\/wp\/v2\/posts\/196\/revisions\/198"}],"wp:attachment":[{"href":"https:\/\/theroyalscode.com\/students\/g_cruz\/wp-json\/wp\/v2\/media?parent=196"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/theroyalscode.com\/students\/g_cruz\/wp-json\/wp\/v2\/categories?post=196"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/theroyalscode.com\/students\/g_cruz\/wp-json\/wp\/v2\/tags?post=196"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}