Web page: Difference between revisions

Content deleted Content added
No edit summary
Tags: Reverted Mobile edit Mobile web edit
m Reverted edit by 2400:ADC5:1AF:F300:3D7C:38F7:33D2:8EEB (talk) to last version by Kent Dominic
Line 4:
 
A '''web page''' (or '''webpage''') is a [[World Wide Web|Web]] document that is accessed in a [[web browser]].<ref name=":0">{{cite web |title=Web page – definition of web page by The Free Dictionary |url=https://www.thefreedictionary.com/web+page |access-date=23 April 2021 |archive-date=23 April 2021 |archive-url=https://web.archive.org/web/20210423170632/https://www.thefreedictionary.com/web+page |url-status=live }}</ref> A [[website]] typically consists of many web pages [[hyperlink|linked]] together under a common [[___domain name]]. The term "web page" is therefore a [[metaphor]] of paper pages bound together into a book.
def print_board(board):
for row in board:
print(" | ".join(row))
print("-" * 9)
 
def check_winner(board, player):
for row in board:
if all(cell == player for cell in row):
return True
 
for col in range(3):
if all(board[row][col] == player for row in range(3)):
return True
 
if all(board[i][i] == player for i in range(3)) or all(board[i][2-i] == player for i in range(3)):
return True
 
return False
 
def is_full(board):
return all(all(cell != " " for cell in row) for row in board)
 
def tic_tac_toe():
board = [[" " for _ in range(3)] for _ in range(3)]
players = ["X", "O"]
turn = 0
 
while True:
print_board(board)
player = players[turn % 2]
print(f"Player {player}, enter your move (row and column from 0-2, separated by space):")
try:
row, col = map(int, input().split())
if board[row][col] != " ":
print("Cell already taken! Try again.")
continue
except (ValueError, IndexError):
print("Invalid input! Enter row and column numbers (0-2).")
continue
board[row][col] = player
if check_winner(board, player):
print_board(board)
print(f"Player {player} wins!")
break
if is_full(board):
print_board(board)
print("It's a tie!")
break
turn += 1
 
tic_tac_toe()
 
== Navigation ==