If you run a hotel, a restaurant, or a supermarket, understanding this system puts you ahead of 90% of casual buyers.
Nawalapitiya Badu Numbers, also known as Nawalapitiya lottery numbers, are a popular lottery game in Sri Lanka. The game involves choosing a set of numbers to win a prize. In this feature, we will create a full-featured implementation of the Nawalapitiya Badu Numbers game. nawalapitiya badu numbers
We will create a Python class to generate the Badu Numbers. If you run a hotel, a restaurant, or
import random
class BaduNumbers:
def __init__(self):
self.pool = list(range(1, 50))
def generate_numbers(self):
"""Generate 7 unique random numbers from the pool."""
return random.sample(self.pool, 7)
def validate_player_numbers(self, player_numbers):
"""Validate if the player's numbers are within the pool and unique."""
if len(player_numbers) != 7:
raise ValueError("Player must choose 7 numbers.")
if not all(1 <= num <= 49 for num in player_numbers):
raise ValueError("All player numbers must be within 1 to 49.")
if len(player_numbers) != len(set(player_numbers)):
raise ValueError("Player numbers must be unique.")
def calculate_winnings(self, player_numbers, drawn_numbers):
"""Calculate the number of matching numbers."""
self.validate_player_numbers(player_numbers)
matches = len(set(player_numbers) & set(drawn_numbers))
return matches
def play(self):
drawn_numbers = self.generate_numbers()
print("Drawn Numbers:", drawn_numbers)
player_numbers = input("Enter your 7 numbers (separated by spaces): ")
player_numbers = [int(num) for num in player_numbers.split()]
try:
self.validate_player_numbers(player_numbers)
except ValueError as e:
print(e)
return
matches = self.calculate_winnings(player_numbers, drawn_numbers)
print("Matching Numbers:", matches)
if matches >= 4:
print("Congratulations! You won with {} matches.".format(matches))
else:
print("Better luck next time! You had {} matches.".format(matches))
if __name__ == "__main__":
game = BaduNumbers()
game.play()