<!DOCTYPE html>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
padding: 20px;
}
h1 {
color: #333;
text-align: center;
}
.container {
max-width: 600px;
margin: 0 auto;
background-color: white;
padding: 20px;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
button {
background-color: #007bff;
color: white;
padding: 5px 10px;
border: none;
border-radius: 3px;
cursor: pointer;
}
Rock Paper Scissor Game in Python
Let’s play a game of Rock, Paper, Scissors! Choose your move and see if you can beat the computer.
function playGame(playerChoice) {
const choices = [‘rock’, ‘paper’, ‘scissors’];
const computerChoice = choices[Math.floor(Math.random() * choices.length)];
let result;
if (playerChoice === computerChoice) {
result = “It’s a tie!”;
} else if (playerChoice === ‘rock’ && computerChoice === ‘scissors’ ||
playerChoice === ‘paper’ && computerChoice === ‘rock’ ||
playerChoice === ‘scissors’ && computerChoice === ‘paper’) {
result = “You win!”;
} else {
result = “Computer wins!”;
}
document.getElementById(“result”).innerText = `You chose ${playerChoice}, computer chose ${computerChoice}. ${result}`;
}