added battelships

This commit is contained in:
2025-11-06 10:14:37 +03:00
parent 0117f2c18e
commit 36b9a83619
6 changed files with 322 additions and 0 deletions

22
Battleships/lesson_2.py Normal file
View File

@@ -0,0 +1,22 @@
# BATTLESHIPS - Grade 7 Python Game
# Lesson 1: Find the hidden ship!
import random
# Step 1: Create a secret ship location (row 0-4, col 0-4)
ship_row = random.randint(0, 4)
ship_col = random.randint(0, 4)
# Step 2: Ask the player for a guess (we'll improve this later!)
print("Guess the ship location!")
guess_row = int(input("Row (0-4): "))
guess_col = int(input("Col (0-4): "))
# Step 3: Check if they hit the ship
if guess_row == ship_row and guess_col == ship_col:
print("🎯 HIT! You sank the ship!")
else:
print("💦 MISS! Try again.")
# Step 4: (Optional) Show where the ship really was
print("The ship was at row", ship_row, "and col", ship_col)