# Setting up variables
numberOfZones = int(input("Enter the number of zones: "))
spacesPerZone = int(input("Enter the spaces per zone: "))
zoneCounter = 1
maxFreeSpaces = 1
zoneWithMaxFree = 1

# Looping through each zone and calculating occupancy status until all zones are completed
while zoneCounter <= numberOfZones:

	# Setting up variables
	spaceCounter = 1
	occupiedCount = 0
	totalSpaces = spacesPerZone

	# Prompt for user input
	print(f"Enter the data for zone {zoneCounter}")

	# Looping through each space and calculating occupancy status until all spaces are completed
	while spaceCounter <= spacesPerZone:
		occupancyStatus = input(f"Is space {spaceCounter} occupied? (1/0): ")
		while occupancyStatus != "1" and occupancyStatus != "0":
			occupancyStatus = input(f"Invalid status. Please enter 1 or 0: ")

		# Incrementing the occupied space count, if space is occupied
		if occupancyStatus == "1":
			occupiedCount += 1

		# Incrementing space counter
		spaceCounter += 1

	# Calculating the number of free spaces and the percentage of spaces occupied
	freeSpaces = totalSpaces - occupiedCount
	occupiedPercent = int((occupiedCount / totalSpaces) * 100)

	# Presents the zone status to the user
	print(f"Zone {zoneCounter} has {occupiedCount} occupied spaces and is {occupiedPercent}% occupied.")

	# Displays a warning if the percentage of occupied spaces is above 80%
	if occupiedPercent >= 80:
		print(f"Warning: zone {zoneCounter} is {occupiedPercent}% occupied. You should use a different zone.")

	# Storing the current zone as the zone with max free spaces, if more free spaces than previously stored number
	if freeSpaces > maxFreeSpaces:
		maxFreeSpaces = freeSpaces
		zoneWithMaxFree = zoneCounter

	# Incrementing zone counter before looping back to address the next zone
	zoneCounter += 1

# Presents the car park status to the user
print(f"Zone {zoneWithMaxFree} has the most available space, with {freeSpaces} available spaces.")
