avatarJ3

Free AI web copilot to create summaries, insights and extended knowledge, download it at here

10395

Abstract

string">'There is a draw!'</span>) <span class="hljs-keyword">elif</span> (computer_choice == <span class="hljs-number">1</span> <span class="hljs-keyword">and</span> your_choice == <span class="hljs-number">2</span>): <span class="hljs-built_in">print</span>(<span class="hljs-string">'You win!'</span>) <span class="hljs-keyword">elif</span> (computer_choice == <span class="hljs-number">2</span> <span class="hljs-keyword">and</span> your_choice == <span class="hljs-number">0</span>): <span class="hljs-built_in">print</span>(<span class="hljs-string">'You win!'</span>) <span class="hljs-keyword">elif</span> (computer_choice == <span class="hljs-number">2</span> <span class="hljs-keyword">and</span> your_choice == <span class="hljs-number">1</span>): <span class="hljs-built_in">print</span>(<span class="hljs-string">'You loose!'</span>) <span class="hljs-keyword">elif</span> (computer_choice == <span class="hljs-number">2</span> <span class="hljs-keyword">and</span> your_choice == <span class="hljs-number">2</span>): <span class="hljs-built_in">print</span>(<span class="hljs-string">'There is a draw!'</span>)</pre></div><div id="df2c"><pre><span class="hljs-attribute">Choose</span> <span class="hljs-number">0</span> for rock, <span class="hljs-number">1</span> for paper, or <span class="hljs-number">2</span> for scissors. <span class="hljs-number">3</span> <span class="hljs-attribute">You</span> chose <span class="hljs-number">3</span>. List index out of range. Please choose <span class="hljs-number">0</span>, <span class="hljs-number">1</span> or <span class="hljs-number">2</span>! <span class="hljs-attribute">Choose</span> <span class="hljs-number">0</span> for rock, <span class="hljs-number">1</span> for paper, or <span class="hljs-number">2</span> for scissors. <span class="hljs-number">2</span> <span class="hljs-attribute">You</span> chose: scissors <span class="hljs-attribute">Computer</span> chose: scissors <span class="hljs-attribute">There</span> is a draw!</pre></div><p id="048d">06#step — RPS Game implementations V2</p><div id="d38d"><pre><span class="hljs-keyword">import</span> random

list_game = [<span class="hljs-string">'rock'</span>, <span class="hljs-string">'paper'</span>, <span class="hljs-string">'scissors'</span>] your_choice = <span class="hljs-built_in">int</span>(<span class="hljs-built_in">input</span>(<span class="hljs-string">"Choose 0 for rock, 1 for paper, or 2 for scissors: "</span>)) computer_choice = random.randint(<span class="hljs-number">0</span>, <span class="hljs-built_in">len</span>(list_game) - <span class="hljs-number">1</span>) <span class="hljs-built_in">print</span>(<span class="hljs-string">f"Computer chose: <span class="hljs-subst">{list_game[computer_choice]}</span>"</span>) <span class="hljs-built_in">print</span>(<span class="hljs-string">f"You chose: <span class="hljs-subst">{list_game[your_choice]}</span>"</span>) <span class="hljs-keyword">if</span> computer_choice == your_choice: <span class="hljs-built_in">print</span>(<span class="hljs-string">'There is a draw!'</span>) <span class="hljs-keyword">elif</span> (computer_choice == <span class="hljs-number">0</span> <span class="hljs-keyword">and</span> your_choice == <span class="hljs-number">1</span>) <span class="hljs-keyword">or</span> (computer_choice == <span class="hljs-number">1</span> <span class="hljs-keyword">and</span> your_choice == <span class="hljs-number">2</span>) <span class="hljs-keyword">or</span> (computer_choice == <span class="hljs-number">2</span> <span class="hljs-keyword">and</span> your_choice == <span class="hljs-number">0</span>): <span class="hljs-built_in">print</span>(<span class="hljs-string">'You win!'</span>) <span class="hljs-keyword">else</span>: <span class="hljs-built_in">print</span>(<span class="hljs-string">'You lose!'</span>)</pre></div><div id="e7ea"><pre><span class="hljs-attribute">Choose</span> <span class="hljs-number">0</span> for rock, <span class="hljs-number">1</span> for paper, or <span class="hljs-number">2</span> for scissors: <span class="hljs-number">1</span> <span class="hljs-attribute">Computer</span> chose: paper <span class="hljs-attribute">You</span> chose: paper <span class="hljs-attribute">There</span> is a draw! </pre></div><p id="aada">07#step — Rock Paper Scissors ASCII Art</p><div id="0968"><pre><span class="hljs-comment"># Rock Paper Scissors ASCII Art</span>

<span class="hljs-comment"># Rock</span> <span class="hljs-built_in">print</span>(<span class="hljs-string">""" _______ ---' ) () () () ---.(_) """</span>)

<span class="hljs-comment"># Paper</span> <span class="hljs-built_in">print</span>(<span class="hljs-string">""" _______ ---' ) _____) _____) ) ---.) """</span>)

<span class="hljs-comment"># Scissors</span> <span class="hljs-built_in">print</span>(<span class="hljs-string">""" _______ ---' ) ) __) () ---.() """</span>)</pre></div><p id="d8a4">08#step — RPS Game implementations V3</p><div id="0fb0"><pre><span class="hljs-comment"># Game implementations V3</span> <span class="hljs-comment"># Rock Paper Scissors ASCII Art</span> rock = <span class="hljs-string">""" _______ ---' ____) () () (____) ---.() """</span>

paper = <span class="hljs-string">""" _______ ---' ) _____) _____) ) ---.) """</span>

scissors = <span class="hljs-string">""" _______ ---' ) _____) __) () ---.() """</span> imgs = [rock, paper, scissors]

<span class="hljs-keyword">import</span> random

list_game = [<span class="hljs-string">'rock'</span>, <span class="hljs-string">'paper'</span>, <span class="hljs-string">'scissors'</span>] your_choice = <span class="hljs-built_in">int</span>(<span class="hljs-built_in">input</span>(<span class="hljs-string">"Choose 0 for rock, 1 for paper, or 2 for scissors: "</span>)) computer_choice = random.randint(<span class="hljs-number">0</span>, <span class="hljs-built_in">len</span>(list_game) - <span class="hljs-number">1</span>)

<span class="hljs-built_in">print</span>(<span class="hljs-string">f"Computer chose: <span class="hljs-subst">{imgs[computer_choice]}</span>"</span>) <span class="hljs-built_in">print</span>(<span class="hljs-string">f"You chose: <span class="hljs-subst">{imgs[your_choice]}</span>"</span>)

<span class="hljs-keyword">if</span> computer_choice == your_choice: <span class="hljs-built_in">print</span>(<span class="hljs-string">'There is a draw!'</span>) <span class="hljs-keyword">elif</span> (computer_choice == <span class="hljs-number">0</span> <span class="hljs-keyword">and</span> your_choice == <span class="hljs-number">1</span>) <span class="hljs-keyword">or</span> (computer_choice == <span class="hljs-number">1</span> <span class="hljs-keyword">and</span> your_choice == <span class="hljs-number">2</span>) <span class="hljs-keyword">or</span> (computer_choice == <span class="hljs-number">2</span> <span class="hljs-keyword">and</span> your_choice == <span class="hljs-number">0</span>): <span class="hljs-built_in">print</span>(<span class="hljs-string">'You win!'</span>) <span class="hljs-keyword">else</span>: <span class="hljs-built_in">print</span>(<span class="hljs-string">'You lose!'</span>)</pre></div><div id="19f7"><pre>Choose <span class="hljs-number">0</span> for rock, <span class="hljs-number">1</span> for paper, or <span class="hljs-number">2</span> for scissors: <span class="hljs-number">0</span> Computer chose: _______ ---' ) <span class="hljs-params">()</span> <span class="hljs-params">()</span> <span class="hljs-params">()</span> ---.(_)

You chose: _______ ---' ) <span class="hljs-params">()</span> <span class="hljs-params">()</span> <span class="hljs-params">()</span> ---.(_)

There is a draw!</pre></div><p id="1cd2">09#step — RPS Game implementations V4

Rock Paper Scissors ASCII Art</p><div id="5596"><pre><span class="hljs-comment"># Game implementations V4</span>

<span class="hljs-comment"># Rock Paper Scissors ASCII Art</span> rock = <span class="hljs-string">""" _______ ---' ) () () () ---.(_) """</span>

paper = <span class="hljs-string">""" _______ ---' ) _____) _____) ) ---.) """</span>

scissors = <span class="hljs-string">""" _______ ---' ) _____) __) () ---.() """</span> imgs = [rock, paper, scissors]

<span class="hljs-keyword">import</span> random

list_game = [<span class="hljs-string">'rock'</span>, <span class="hljs-string">'paper'</span>, <span class="hljs-string">'scissors'</span>] your_choice = <span class="hljs-built_in">int</span>(<span class="hljs-built_in">input</span>(<span class="hljs-string">"Choose 0 for rock, 1 for paper, or 2 for scissors: "</span>)) computer_choice = random.randint(<span class="hljs-number">0</span>, <span class="hljs-built_in">len</span>(list_game) - <span class="hljs-number">1</span>)

<span class="hljs-built_in">print</span>(<span class="hljs-string">f"Computer chose:\n<span class="hljs-subst">{imgs[computer_choice]}</span>"</span>) <span class="hljs-built_in">print</span>(<span class="hljs-string">f"You chose:\n<span class="hljs-subst">{imgs[your_choice]}</span>"</span>)

<span class="hljs-keyword">if</span> computer_choice == your_choice: <span class="hljs-built_in">print</span>(<span class="hljs-string">"There is a draw!"</span>) <span class="hljs-keyword">elif</span> (computer_choice == <span class="hljs-number">0</span> <span class="hljs-keyword">and</span> your_choice == <span class="hljs-number">1</span>) <span class="hljs-keyword">or</span>
(computer_choice == <span class="hljs-number">1</span> <span class="hljs-keyword">and</span> your_choice == <span class="hljs-number">2</span>) <span class="hljs-keyword">or</span>
(computer_choice == <span class="hljs-number">2</span> <span class="hljs-keyword">and</span> your_choice == <span class="hljs-number">0</span>): <span class="hljs-built_in">pr

Options

int</span>(<span class="hljs-string">"You win!"</span>) <span class="hljs-keyword">else</span>: <span class="hljs-built_in">print</span>(<span class="hljs-string">"You lose!"</span>)</pre></div><div id="badb"><pre>Choose 0 for rock, 1 for paper, or 2 for scissors: 2 Computer chose:

_______

<span class="hljs-params">---</span>' ) <span class="hljs-params">()</span> <span class="hljs-params">()</span> <span class="hljs-params">()</span> <span class="hljs-params">---</span><span class="hljs-string">.</span><span class="hljs-params">(_)</span>

You chose:

_______

<span class="hljs-params">---</span>' ) _____) __) <span class="hljs-params">()</span> <span class="hljs-params">---</span><span class="hljs-string">.</span><span class="hljs-params">()</span>

You lose!</pre></div><p id="efa1">10#step — create rock paper scissors game in the console Using Gemini Chat on <a href="https://colab.research.google.com/">Google Collab</a>. Click Generator and make a question…</p><div id="efbf"><pre><span class="hljs-comment"># prompt: create rock paper scissors game in the console</span>

<span class="hljs-keyword">import</span> random

rock = <span class="hljs-string">""" _______ ---' ) () () () ---.(_) """</span>

paper = <span class="hljs-string">""" _______ ---' ) _____) _____) ) ---.) """</span>

scissors = <span class="hljs-string">""" _______ ---' ) _____) __) () ---.() """</span>

<span class="hljs-comment"># List of choices</span> choices = [rock, paper, scissors]

<span class="hljs-comment"># Get user choice</span> user_choice = <span class="hljs-built_in">int</span>(<span class="hljs-built_in">input</span>(<span class="hljs-string">"What do you choose? Type 0 for Rock, 1 for Paper or 2 for Scissors.\n"</span>)) <span class="hljs-keyword">while</span> user_choice >= <span class="hljs-number">3</span> <span class="hljs-keyword">or</span> user_choice < <span class="hljs-number">0</span>: <span class="hljs-built_in">print</span>(<span class="hljs-string">"You typed an invalid number, you lose!"</span>) user_choice = <span class="hljs-built_in">int</span>(<span class="hljs-built_in">input</span>(<span class="hljs-string">"What do you choose? Type 0 for Rock, 1 for Paper or 2 for Scissors.\n"</span>))

<span class="hljs-built_in">print</span>(choices[user_choice])

<span class="hljs-comment"># Computer's choice</span> computer_choice = random.randint(<span class="hljs-number">0</span>, <span class="hljs-number">2</span>) <span class="hljs-built_in">print</span>(<span class="hljs-string">"Computer chose:"</span>) <span class="hljs-built_in">print</span>(choices[computer_choice])

<span class="hljs-comment"># Determine the winner</span> <span class="hljs-keyword">if</span> user_choice == computer_choice: <span class="hljs-built_in">print</span>(<span class="hljs-string">"It's a draw"</span>) <span class="hljs-keyword">elif</span> (user_choice == <span class="hljs-number">0</span> <span class="hljs-keyword">and</span> computer_choice == <span class="hljs-number">2</span>) <span class="hljs-keyword">or</span> (user_choice == <span class="hljs-number">1</span> <span class="hljs-keyword">and</span> computer_choice == <span class="hljs-number">0</span>) <span class="hljs-keyword">or</span> (user_choice == <span class="hljs-number">2</span> <span class="hljs-keyword">and</span> computer_choice == <span class="hljs-number">1</span>): <span class="hljs-built_in">print</span>(<span class="hljs-string">"You win!"</span>) <span class="hljs-keyword">else</span>: <span class="hljs-built_in">print</span>(<span class="hljs-string">"You lose"</span>)</pre></div><div id="8ec9"><pre>What <span class="hljs-keyword">do</span> you choose? <span class="hljs-keyword">Type</span> <span class="hljs-type">0 </span><span class="hljs-keyword">for</span> Rock, <span class="hljs-number">1</span> <span class="hljs-keyword">for</span> Paper <span class="hljs-keyword">or</span> <span class="hljs-number">2</span> <span class="hljs-keyword">for</span> Scissors. <span class="hljs-number">0</span>

_______

<span class="hljs-comment">---' )</span> () () () <span class="hljs-comment">---.(_)</span>

Computer chose:

 _______

<span class="hljs-comment">---' )</span> _____) _____) ) <span class="hljs-comment">---.)</span>

You lose</pre></div><p id="d8dc">That’s all folks!</p><p id="bf2b">👉Project — Pure Python Episodes List (<a href="https://github.com/giljr/my_jupyter_notebook"><b>Project #16</b></a>)</p><figure id="231a"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*BUMJrJARHzTPAfx1cAtC1w.png"><figcaption>Supercharge your Programming in Colab with AI-Powered tools — Subscribe to the Google Research Channel → <a href="https://www.youtube.com/redirect?event=video_description&amp;redir_token=QUFFLUhqbFByZ3ZUalhXZjFwa3VqU2EzdjNnMjdJT3BRZ3xBQ3Jtc0tsSC1vdXRLLTYtNEJlTjV6c0pweFdNR0V0Q0hHOE9CU0tzcFBVYWpxYkdpM0stdFYtNnFNek5COEtZYWpfdHNVV280SDlRVENaLWVnZ0JMS0l2SGRzVk9zYzRxMXdDNjBRb2V3SXZVc1pVRldybF9XVQ&amp;q=https%3A%2F%2Fgoo.gle%2FGoogleResearch&amp;v=V7RXyqFUR98">https://goo.gle/GoogleResearch</a></figcaption></figure><div id="30b3"><pre>What <span class="hljs-keyword">is</span> Colab?

Colab notebooks allow you <span class="hljs-keyword">to</span> combine executable code <span class="hljs-keyword">and</span> rich <span class="hljs-type">text</span> <span class="hljs-keyword">in</span> a single document, along <span class="hljs-keyword">with</span> images, HTML, LaTeX <span class="hljs-keyword">and</span> more. <span class="hljs-keyword">When</span> you <span class="hljs-keyword">create</span> your own Colab notebooks, they are stored <span class="hljs-keyword">in</span> your Google Drive account. You can easily <span class="hljs-keyword">share</span> your Colab notebooks <span class="hljs-keyword">with</span> co-workers <span class="hljs-keyword">or</span> friends, allowing them <span class="hljs-keyword">to</span> <span class="hljs-keyword">comment</span> <span class="hljs-keyword">on</span> your notebooks <span class="hljs-keyword">or</span> even edit them. </pre></div><h1 id="9765">Related Posts</h1><p id="08dd"><b>00</b>#Episode#PurePythonSeries — <a href="https://readmedium.com/lambda-in-python-421b0c18e825"><b>Lambda in Python </b></a>— Python Lambda Desmistification</p><p id="4118"><b>01</b>#Episode#PurePythonSeries — <a href="https://readmedium.com/send-emails-using-python-jupyter-notebook-94d14a5a5655"><b>Send Email in Python</b></a> — Using Jupyter Notebook — How To Send Gmail In Python</p><p id="4320"><b>02</b>#Episode#PurePythonSeries — <a href="https://readmedium.com/automate-your-email-marketing-with-python-f0d68234b789"><b>Automate Your Email With Python & Outlook</b></a><b> </b>— How To Create An Email Trigger System in Python</p><p id="782c"><b>03</b>#Episode#PurePythonSeries — <a href="https://readmedium.com/manipulating-files-with-python-3f9a781287e9"><b>Manipulating Files With Python</b></a> — Manage Your Lovely Photos With Python!</p><p id="3c81"><b>04</b>#Episode#PurePythonSeries — <a href="https://readmedium.com/pandas-dataframe-advanced-48f83a5b097f"><b>Pandas DataFrame Advanced </b></a>— A Complete Notebook Review</p><p id="38ac"><b>05</b>#Episode#PurePythonSeries — <a href="https://readmedium.com/is-this-leap-year-python-calendar-3d1a61f2c4a7"><b>Is This Leap Year? Python Calendar</b> </a>— How To Calculate If The Year Is Leap Year and How Many Days Are In The Month</p><p id="bf25"><b>06</b>#Episode#PurePythonSeries — <a href="https://readmedium.com/list-comprehension-in-python-c22c4b0a6a8a"><b>List Comprehension In Python </b></a>— Locked-in Secrets About List Comprehension</p><p id="ee5b"><b>07</b>#Episode#PurePythonSeries — <a href="https://readmedium.com/graphs-in-python-b7d243737b77"><b>Graphs — In Python </b></a>— Extremely Simple Algorithms in Python</p><p id="969f"><b>08</b>#Episode#PurePythonSeries — <a href="https://readmedium.com/decorator-in-python-62c00f7e818"><b>Decorator in Python</b></a> — How To Simplifying Your Code And Boost Your Function</p><p id="4423"><b>12#</b>Episode#PurePythonSeries — <a href="https://readmedium.com/advanced-python-technologies-d3dbdf1d70cb"><b>Advanced Python Technologies</b> </a><a href="https://readmedium.com/advanced-python-technologies-d3dbdf1d70cb">qrcode, Speech Recognition in Python, Google Speech Recognition</a></p><p id="381d"><b>13#</b>Episode#PurePythonSeries — <a href="https://readmedium.com/advanced-python-technologies-ii-33d2d6888583"><b>Advanced Python Technologies II</b></a> — qFace Recognition w/ Jupyter Notebook & Ubuntu</p><p id="937a"><b>14#</b>Episode#PurePythonSeries — <a href="https://readmedium.com/advanced-python-technologies-iii-ac92cd677e5e"><b>Advanced Python Technologies III</b> </a>— Face Recognition w/ Colab</p><p id="1945"><b>15#</b>Episode#PurePythonSeries — <a href="https://readmedium.com/iss-tracking-project-python-af4b5fa47a28"><b>ISS Tracking Project</b></a> — Get an Email alert when International Space Station (ISS) is above of us in the sky, at night</p><p id="70f3"><b>16#</b>Episode#PurePythonSeries —<a href="https://readmedium.com/using-gemini-chat-on-collab-2626fb035176"><b>Using Gemini Chat on Collab</b></a> —Random Number Generation, List Manipulation & Rock-Paper-Scissors Game Implementations (this one)</p><p id="eaf2"><b>17#</b>Episode#PurePythonSeries — Python — <a href="https://readmedium.com/python-basics-2ce557a80f42"><b>Basics</b> </a>— Functions, OOP, file handling, calculator, loops (this one)</p><p id="bf10"><b>18#</b>Episode#PurePythonSeries — Python — <a href="https://readmedium.com/efficient-file-handling-in-python-0d952971ebc9"><b>Efficient File Handling in Python</b></a><b> </b>— Best Practices and Common Methods</p><p id="acae"><b>19#</b>Episode#PurePythonSeries — Python — <a href="https://readmedium.com/how-to-securely-save-credentials-in-python-dd5c6983741a"><b>How To Securely Save Credentials in Python</b> </a>— Like API tokens, passwords, or other sensitive data (this one)</p></article></body>

Using Gemini Chat on Collab

Random Number Generation, List Manipulation & Rock-Paper-Scissors Game Implementations #PurePythonSeries — Episode #16

Supercharge your Programming in Colab with AI-Powered tools: Gemini Chat.

This notebook covers various aspects of Python programming, including:

1. Random Number Generation: — Generating random integers and floats using the ‘random’ module. — Randomly selecting elements from lists.

2. List Manipulation: — Counting occurrences of elements in lists. — Appending elements to lists. — Finding the index of elements. — Reversing and sorting lists. — Removing elements from lists using ‘pop’.

3. Rock-Paper-Scissors Game Implementations: — Multiple versions of the game with increasing complexity. — Using ASCII art to represent choices. — Handling user input and determining the winner.

In the end, we will experience Gemini Chat. Hold on tight! Let’s get Started:

00#step — An integer random number between 0 and 10

import random
print(random.randint(1,10))
7

01#step — Generate a float random number between 0.0 and 1.0

print(random.random())
0.19203798450438125

02# step — Generate a float random number between 0.0 and 5.0

print(5*random.random())
3.7332815531953187

03#step — List: An example that uses most of the list methods

fruits = [‘orange’, ‘apple’, ‘pear’, ‘banana’, ‘kiwi’, ‘apple’, ‘banana’]
apples = fruits.count(‘apple’)
print(f’There are {apples} Apples on fruits list.’)
tangirines = fruits.count(‘tangerine’)
print(f’There are {tangirines} tangirines on fruits list.’)
print(fruits)
print(‘Adding tangirine’)
fruits.append(‘tangirine’)
tangirines = fruits.count(‘tangirine’)
print(f’There are {tangirines} tangirines on fruits list.’)
print(fruits)
banana_index = fruits.index(‘banana’)
print(f’Banana apppears on index {banana_index} on fruits list.’)
fruits.index(‘banana’, 0) # Find next banana starting at position 4
print(‘Reversing the list…’)
fruits.reverse()
print(fruits)
print(‘Adding grape’)
fruits.append(‘grape’)
print(fruits)
print(‘Sorting list…’)
fruits.sort()
print(fruits)
print(‘Poping one fruit…’)
fruit = fruits.pop()
print(fruits)
print(f’{fruit} was popped!’)
There are 2 Apples on fruits list.
There are 0 tangirines on fruits list.
['orange', 'apple', 'pear', 'banana', 'kiwi', 'apple', 'banana']
Adding tangirine
There are 1 tangirines on fruits list.
['orange', 'apple', 'pear', 'banana', 'kiwi', 'apple', 'banana', 'tangirine']
Banana apppears on index 3 on fruits list.
Reversing the list...
['tangirine', 'banana', 'apple', 'kiwi', 'banana', 'pear', 'apple', 'orange']
Adding grape
['tangirine', 'banana', 'apple', 'kiwi', 'banana', 'pear', 'apple', 'orange', 'grape']
Sorting list...
['apple', 'apple', 'banana', 'banana', 'grape', 'kiwi', 'orange', 'pear', 'tangirine']
Poping one fruit...
['apple', 'apple', 'banana', 'banana', 'grape', 'kiwi', 'orange', 'pear']
tangirine was popped!

04#step — Choosing one name randomly

import random

names = ['j3', 'luk', 'peter', 'rachel']
random_name = random.choice(names)
print(random_name)
peter

05#step — RPS Game implementations V1

# rock = 0
# paper = 1
# scissors = 2

import random

list_game = ['rock', 'paper', 'scissors'] 
your_choice = int(input("Choose 0 for rock, 1 for paper, or 2 for scissors. "))
while your_choice not in range(0,3):
 print(f'You chose {your_choice}. List index out of range. Please choose 0, 1 or 2!')
 your_choice = int(input("Choose 0 for rock, 1 for paper, or 2 for scissors. "))
else:
 print(f'You chose: {list_game[your_choice]}')
 computer_choice = random.randint(0, len(list_game)-1 )
 print(f'Computer chose: {list_game[computer_choice]}')
 if (computer_choice == 0 and your_choice == 0):
 print('There is a draw!')
 elif (computer_choice == 0 and your_choice == 1):
 print('You loose!')
 elif (computer_choice == 0 and your_choice == 2):
 print('You lose!')
 elif (computer_choice == 1 and your_choice == 0):
 print('You win!')
 elif (computer_choice == 1 and your_choice == 1):
 print('There is a draw!')
 elif (computer_choice == 1 and your_choice == 2):
 print('You win!')
 elif (computer_choice == 2 and your_choice == 0):
 print('You win!')
 elif (computer_choice == 2 and your_choice == 1):
 print('You loose!')
 elif (computer_choice == 2 and your_choice == 2):
 print('There is a draw!')
Choose 0 for rock, 1 for paper, or 2 for scissors. 3
You chose 3. List index out of range. Please choose 0, 1 or 2!
Choose 0 for rock, 1 for paper, or 2 for scissors. 2
You chose: scissors
Computer chose: scissors
There is a draw!

06#step — RPS Game implementations V2

import random

list_game = ['rock', 'paper', 'scissors']
your_choice = int(input("Choose 0 for rock, 1 for paper, or 2 for scissors: "))
computer_choice = random.randint(0, len(list_game) - 1)
print(f"Computer chose: {list_game[computer_choice]}")
print(f"You chose: {list_game[your_choice]}")
if computer_choice == your_choice:
 print('There is a draw!')
elif (computer_choice == 0 and your_choice == 1) or (computer_choice == 1 and your_choice == 2) or (computer_choice == 2 and your_choice == 0):
 print('You win!')
else:
 print('You lose!')
Choose 0 for rock, 1 for paper, or 2 for scissors: 1
Computer chose: paper
You chose: paper
There is a draw!

07#step — Rock Paper Scissors ASCII Art

# Rock Paper Scissors ASCII Art

# Rock
print("""
    _______
---'   ____)
      (_____)
      (_____)
      (____)
---.__(___)
""")

# Paper
print("""
     _______
---'    ____)____
           ______)
          _______)
         _______)
---.__________)
""")

# Scissors
print("""
    _______
---'   ____)____
          ______)
       __________)
      (____)
---.__(___)
""")

08#step — RPS Game implementations V3

# Game implementations V3
# Rock Paper Scissors ASCII Art
rock = """
    _______
---'   ____)
      (_____)
      (_____)
      (____)
---.__(___)
"""

paper = """
     _______
---'    ____)____
           ______)
          _______)
         _______)
---.__________)
"""

scissors = """
    _______
---'   ____)____
          ______)
       __________)
      (____)
---.__(___)
"""
imgs = [rock, paper, scissors]

import random

list_game = ['rock', 'paper', 'scissors']
your_choice = int(input("Choose 0 for rock, 1 for paper, or 2 for scissors: "))
computer_choice = random.randint(0, len(list_game) - 1)

print(f"Computer chose: {imgs[computer_choice]}")
print(f"You chose: {imgs[your_choice]}")

if computer_choice == your_choice:
    print('There is a draw!')
elif (computer_choice == 0 and your_choice == 1) or (computer_choice == 1 and your_choice == 2) or (computer_choice == 2 and your_choice == 0):
    print('You win!')
else:
    print('You lose!')
Choose 0 for rock, 1 for paper, or 2 for scissors: 0
Computer chose: 
    _______
---'   ____)
      (_____)
      (_____)
      (____)
---.__(___)

You chose: 
    _______
---'   ____)
      (_____)
      (_____)
      (____)
---.__(___)

There is a draw!

09#step — RPS Game implementations V4 # Rock Paper Scissors ASCII Art

# Game implementations V4
# Rock Paper Scissors ASCII Art
rock = """
    _______
---'   ____)
      (_____)
      (_____)
      (____)
---.__(___)
"""

paper = """
     _______
---'    ____)____
           ______)
          _______)
         _______)
---.__________)
"""

scissors = """
    _______
---'   ____)____
          ______)
       __________)
      (____)
---.__(___)
"""
imgs = [rock, paper, scissors]

import random

list_game = ['rock', 'paper', 'scissors']
your_choice = int(input("Choose 0 for rock, 1 for paper, or 2 for scissors: "))
computer_choice = random.randint(0, len(list_game) - 1)

print(f"Computer chose:\n{imgs[computer_choice]}")
print(f"You chose:\n{imgs[your_choice]}")

if computer_choice == your_choice:
    print("There is a draw!")
elif (computer_choice == 0 and your_choice == 1) or \
     (computer_choice == 1 and your_choice == 2) or \
     (computer_choice == 2 and your_choice == 0):
    print("You win!")
else:
    print("You lose!")
Choose 0 for rock, 1 for paper, or 2 for scissors: 2
Computer chose:

    _______
---'   ____)
      (_____)
      (_____)
      (____)
---.__(___)

You chose:

    _______
---'   ____)____
          ______)
       __________)
      (____)
---.__(___)

You lose!

10#step — create rock paper scissors game in the console Using Gemini Chat on Google Collab. Click Generator and make a question…

# prompt: create rock paper scissors game in the console

import random

rock = """
    _______
---'   ____)
      (_____)
      (_____)
      (____)
---.__(___)
"""

paper = """
     _______
---'    ____)____
           ______)
          _______)
         _______)
---.__________)
"""

scissors = """
    _______
---'   ____)____
          ______)
       __________)
      (____)
---.__(___)
"""

# List of choices
choices = [rock, paper, scissors]

# Get user choice
user_choice = int(input("What do you choose? Type 0 for Rock, 1 for Paper or 2 for Scissors.\n"))
while user_choice >= 3 or user_choice < 0:
  print("You typed an invalid number, you lose!") 
  user_choice = int(input("What do you choose? Type 0 for Rock, 1 for Paper or 2 for Scissors.\n"))

print(choices[user_choice])

# Computer's choice
computer_choice = random.randint(0, 2)
print("Computer chose:")
print(choices[computer_choice])

# Determine the winner
if user_choice == computer_choice:
  print("It's a draw")
elif (user_choice == 0 and computer_choice == 2) or (user_choice == 1 and computer_choice == 0) or (user_choice == 2 and computer_choice == 1):
  print("You win!")
else:
  print("You lose")
What do you choose? Type 0 for Rock, 1 for Paper or 2 for Scissors.
0

    _______
---'   ____)
      (_____)
      (_____)
      (____)
---.__(___)

Computer chose:

     _______
---'    ____)____
           ______)
          _______)
         _______)
---.__________)

You lose

That’s all folks!

👉Project — Pure Python Episodes List (Project #16)

Supercharge your Programming in Colab with AI-Powered tools — Subscribe to the Google Research Channel → https://goo.gle/GoogleResearch
What is Colab?

Colab notebooks allow you to combine executable code
and rich text in a single document, along with images, 
HTML, LaTeX and more. When you create your own 
Colab notebooks, they are stored in your 
Google Drive account. You can easily share your 
Colab notebooks with co-workers or friends, 
allowing them to comment on your notebooks or even edit them. 

Related Posts

00#Episode#PurePythonSeries — Lambda in Python — Python Lambda Desmistification

01#Episode#PurePythonSeries — Send Email in Python — Using Jupyter Notebook — How To Send Gmail In Python

02#Episode#PurePythonSeries — Automate Your Email With Python & Outlook — How To Create An Email Trigger System in Python

03#Episode#PurePythonSeries — Manipulating Files With Python — Manage Your Lovely Photos With Python!

04#Episode#PurePythonSeries — Pandas DataFrame Advanced — A Complete Notebook Review

05#Episode#PurePythonSeries — Is This Leap Year? Python Calendar — How To Calculate If The Year Is Leap Year and How Many Days Are In The Month

06#Episode#PurePythonSeries — List Comprehension In Python — Locked-in Secrets About List Comprehension

07#Episode#PurePythonSeries — Graphs — In Python — Extremely Simple Algorithms in Python

08#Episode#PurePythonSeries — Decorator in Python — How To Simplifying Your Code And Boost Your Function

12#Episode#PurePythonSeries — Advanced Python Technologies qrcode, Speech Recognition in Python, Google Speech Recognition

13#Episode#PurePythonSeries — Advanced Python Technologies II — qFace Recognition w/ Jupyter Notebook & Ubuntu

14#Episode#PurePythonSeries — Advanced Python Technologies III — Face Recognition w/ Colab

15#Episode#PurePythonSeries — ISS Tracking Project — Get an Email alert when International Space Station (ISS) is above of us in the sky, at night

16#Episode#PurePythonSeries —Using Gemini Chat on Collab —Random Number Generation, List Manipulation & Rock-Paper-Scissors Game Implementations (this one)

17#Episode#PurePythonSeries — Python — Basics — Functions, OOP, file handling, calculator, loops (this one)

18#Episode#PurePythonSeries — Python — Efficient File Handling in Python — Best Practices and Common Methods

19#Episode#PurePythonSeries — Python — How To Securely Save Credentials in Python — Like API tokens, passwords, or other sensitive data (this one)

Colab
Google Gemini Ai
Python List Tutorial
Rock Paper Scissors Game
Ramdom
Recommended from ReadMedium