If i choose Nepal then Country code will automatic generate 00977

What is the automated method for obtaining the country code '0977' when selecting a country name "Nepal" from a dropdown menu?"

You could use a look-up column in the choice list, see https://docs.getodk.org/form-datasets/#looking-up-values-in-datasets.

Other options could be:
- add the code to the label e.g. Nepal (0977)
- use _0977 or c_0977 as name of the choice
- even 0977 may work as choice name (but not following the variable naming rules, to start with s letter or _)
- esp. for few countries, you could add a variable with a calculation (cascading ifs) to map the choice name to the corresponding code
- use an external file for the mapping.

Which is the preferable solution depends on what you want to do with the 0977 info, incl. form UI, data view, export and analysis.