DSA Mini Project
DSA Mini Project
Mini Project
Report on
SUBMITTED BY
1
CERTIFICATE
is a bonafide work carried out by above students under the guidance of Prof.
Shilpa Vishwabrahma and it is approved for the Computer Graphics Laboratory
– Mini Project fulfilment of the requirement of Savitribai Phule Pune
University
2
DATA STRUCTURES AND
ALGORTIHMS
MINI PROJECT
Problem Statement:-
Design a mini project to implement Snake and Ladders Game using Python.
Introduction:-
Snake and Ladders is a classic board game enjoyed by people of all ages.
Implementing this game in Python provides a great opportunity to practice
programming concepts such as data structures, loops, conditionals, and user
interaction. In this mini project, we will design and implement a Snake and Ladders
game using Python. Let's embark on this exciting journey of building our own Snake
and Ladders game in Python!
3
PYTHON PROGRAM CODE
import random
def create_board():
"""Initialize the game board with snakes and ladders positions."""
board = list(range(1, 101))
snakes = {16: 6, 47: 26, 49: 11, 56: 53, 62: 19, 64: 60, 87: 24, 93: 73, 95: 75, 98: 78}
ladders = {1: 38, 4: 14, 9: 31, 21: 42, 28: 84, 36: 44, 51: 67, 71: 91, 80: 100}
return board, snakes, ladders
def get_num_players():
"""Ask the user for the number of players."""
num_players = int(input("Enter the number of players: "))
return num_players
def get_player_names(num_players):
"""Ask the user for the names of each player."""
players = [input(f"Enter name for Player {i+1}: ") for i in range(num_players)]
return players
def roll_dice():
"""Simulate rolling a dice."""
return random.randint(1, 6)
# Main code
board, snakes, ladders = create_board()
num_players = get_num_players()
players = get_player_names(num_players)
play_game(players, board, snakes, ladders)
5
OUTPUT:-
6
CONCLUSION
In conclusion, the journey of designing and implementing a Snake and Ladders game
using Python has been both educational and enjoyable. Through this mini project,
we've explored various programming concepts and techniques, while also creating a
classic board game that provides entertainment and challenges for players.