Written by :
Coding Standards in Python Programming
Coding standards are collections of rules and guidelines that determine the programming style, procedures, and methods for programming language.
Having said that python is a beginner friendly and has a simplified syntax with an emphasis on natural language. Every individual in a team must follow some basic coding standards which will intern help them to run and debug their code very easily and also makes code more readable.
One of the most commonly used style guide in python is PEP-8 , is a document that provides guidelines and best practices on how to write python code.
Common Aspects of coding Standard
● Naming Conventions
● File and folder Naming
● Indentation
● Commenting
Naming Conventions
Naming conventions indicate having a meaningful name for our variables, methods, functions and classes.it should depict what it does in your code.
Most importantly, reserve words or predefined words as your variable name shouldn’t be used.
Let us understand better with an example
Perse, both code1 and code2 works perfectly and give the same output but code2 is more readable and understandable compared to code1
File and folder Naming and Organization
It tells how the files and folders should be named and structures for example , consider code2 in the above example : instead of naming the file as “file1.py” it would be better if we name it as “checkEven.py”
Commenting
Comment is a line of text which describes the code and is not executed in the program and is used for better understanding of program.
A single line comment in python starts with “#” and multi-line comment block is enclosed in “....”.
Website: www.siliconvalley4u.com
Email: info@siliconvalley4u.com
Facebook: https://www.facebook.com/siliconvalley4u/
Twitter: https://twitter.com/Siliconvalley41
LinkedIn: https://www.linkedin.com/company/siliconvalley4u
Written by Yasaswini Tinaluri, a Siliconvalley4u's student