Skip to content

Python function name convention

  • by

Python function name convention is to use a lowercase word or words. Separate words by underscores to improve readability.


For example, if you have a function that calculates the sum of two numbers, you could name it calculate_sum or sum_numbers.

Python function name convention examples

A simple example code function takes two numbers as input and returns their sum.

def calculate_sum(num1, num2):
return num1 + num2

print(calculate_sum(500, 499))


Python function name convention

Comment if you have any doubts or suggestions on this Python name convention topic.

Note: IDE: PyCharm 2021.3.3 (Community Edition)

Windows 10

Python 3.10.1

All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.

Leave a Reply

Your email address will not be published. Required fields are marked *