Skip to content

Instantly share code, notes, and snippets.

@veretennikovalexey
Created June 26, 2022 10:57
Show Gist options
  • Save veretennikovalexey/3fbc99621ceda4b414d349cbdbfa9c95 to your computer and use it in GitHub Desktop.
Save veretennikovalexey/3fbc99621ceda4b414d349cbdbfa9c95 to your computer and use it in GitHub Desktop.
rockpaperscissors.ipynb
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "rockpaperscissors.ipynb",
"provenance": [],
"authorship_tag": "ABX9TyPCRK8qj0HmaVZb8/29NL4l",
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/veretennikovalexey/3fbc99621ceda4b414d349cbdbfa9c95/rockpaperscissors.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "wB8h0KwhqCM3"
},
"outputs": [],
"source": [
"import random, sys\n",
"print( 'камень, ножницы, бумага' )\n",
"wins = 0\n",
"loss = 0\n",
"ties = 0\n",
"while True :\n",
" print( f' { wins } { loss } { ties }' )\n",
" while True :\n",
" print( 'к н б или в' )\n",
" playerMove = input()\n",
" if playerMove == 'в' :\n",
" sys.exit()\n",
" if playerMove == 'к' or playerMove == 'н' or playerMove == 'б' :\n",
" break\n",
" print( '-------------> к н б или в' )\n",
" if playerMove == 'к' :\n",
" print( 'Вы выбрали камень' )\n",
" if playerMove == 'н' :\n",
" print( 'Вы выбрали ножницы' )\n",
" if playerMove == 'б' :\n",
" print( 'Вы выбрали бумагу' )\n",
"\n",
" rand = random.randint( 1, 3 )\n",
" if rand == 1 :\n",
" compMove = 'к'\n",
" print( 'Компьютер выбрал камень' ) \n",
" if rand == 2 :\n",
" compMove = 'н'\n",
" print( 'Компьютер выбрал ножницы' ) \n",
" if rand == 3 :\n",
" compMove = 'б'\n",
" print( 'Компьютер выбрал бумагу' ) \n",
"\n",
" if playerMove == compMove :\n",
" print( 'ничья' )\n",
" ties = ties + 1\n",
" if playerMove == 'к' and compMove == 'н' :\n",
" print( 'Камень ломает ножницы' ) \n",
" wins = wins + 1\n",
" if playerMove == 'б' and compMove == 'к' :\n",
" print( 'Бумага заворачивает камень' ) \n",
" wins = wins + 1\n",
" if playerMove == 'н' and compMove == 'б' :\n",
" print( 'Ножницы режут бумагу' ) \n",
" wins = wins + 1\n",
"\n",
" if compMove == 'к' and playerMove == 'н' :\n",
" print( 'Ваши ножницы сломаны' ) \n",
" loss = loss + 1\n",
" if compMove == 'б' and playerMove == 'к' :\n",
" print( 'Ваш камень завёрнут' ) \n",
" loss = loss + 1\n",
" if compMove == 'н' and playerMove == 'б' :\n",
" print( 'Ваша бумага разрезана' ) \n",
" loss = loss + 1"
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment