How to Get Gender Value by the Customer id Magento 2?

You can retrieve the customer Gender value in Magento 2 by email or customer id. Customer Gender is visible in the frontend only if the storefront allows it to display in front otherwise it will be set from the Customer Admin panel with the customer edit section.

If you have set customer gender for the customer data and want to fetch the selected value of the gender you can do it using the customer Metadata interface.

instantiate the interface Magento\Customer\Api\CustomerRepositoryInterface and Customer Repository to retrieve the selected value by model class,

Call from the template or any PHP class,
$customerId = “1”;
echo $countryName = $this->getGender($customerId);