0% found this document useful (0 votes)
2 views4 pages

Assignment 01 Python

PEP 8 is the official style guide for writing Python code, aimed at improving readability and consistency among programmers. It includes key guidelines on indentation, naming conventions, line length limits, and the use of comments, which are essential for collaborative coding, especially in business analytics. Following PEP 8 helps beginners develop good programming habits and creates clean, maintainable code.

Uploaded by

imaanahmad95
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views4 pages

Assignment 01 Python

PEP 8 is the official style guide for writing Python code, aimed at improving readability and consistency among programmers. It includes key guidelines on indentation, naming conventions, line length limits, and the use of comments, which are essential for collaborative coding, especially in business analytics. Following PEP 8 helps beginners develop good programming habits and creates clean, maintainable code.

Uploaded by

imaanahmad95
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

3/9/2026 Programming

Language for
Business Analytics
Assignment no 01

Eman Ahmad
FA25-BBD-037
SECTION: 2B
PEP 8 Guidelines for Beginner Python
Programmers
Introduction
PEP 8 is the official style guide for writing Python code. It was created by the Python Software
Foundation to help programmers write code that is clear, readable, and consistent. Instead
of every programmer writing code in their own style, PEP 8 provides common rules that
everyone can follow.

Coding style matters because programs are often read by many people, not just the person
who wrote them. In real projects, teams of developers work together on the same code. If
the code is messy or written in different styles, it becomes difficult to understand and
maintain. Following a standard style makes the program easier to read, debug, and improve.

Key Guidelines
1. Indentation and Spacing
Python uses indentation to define blocks of code. According to PEP 8, each indentation level
should use 4 spaces.

Example
for number in range(5):

print(number)

Spacing also improves readability. For example, spaces should be placed around operators.

Good:
total = price + tax

Bad:
total=price+tax

2. Naming Conventions for Variables and Functions


PEP 8 recommends using lowercase letters with underscores for variable and function
names. This makes names easier to read.
Example:
student_name = "Ali"

def calculate_average():
pass

Clear naming helps other programmers understand the purpose of the code.

3. Line Length Limits


PEP 8 suggests keeping lines of code under 79 characters. Long lines are harder to read,
especially when viewing code on smaller screens.

Example of splitting a long line:


total_price = base_price + tax + service_charge \
+ delivery_fee

Short lines keep the code clean and organized.

4. Use of Comments and Documentation


Comments explain what the code is doing. They help other programmers understand the
logic behind the program.

Example:
# Calculate the total cost including tax
total = price + tax

Importance for Business Analytics Students


Business analytics students often work with data using Python. In analytics projects, scripts
may include hundreds of lines of code for cleaning data, analyzing results, and creating
reports. If the code is poorly written, it becomes difficult for others to understand or reuse.

Following PEP 8 improves teamwork because everyone follows the same coding style. It also
makes programs easier to read, which helps when fixing errors or updating analysis. Clean
and organized code also helps when sharing projects with colleagues or presenting results.

Conclusion
PEP 8 provides clear rules for writing readable and organized Python code. It covers
important practices such as proper indentation, meaningful naming, line length limits, and
useful comments. For beginners, learning these guidelines early helps develop good
programming habits. By following PEP 8, programmers can create clean, understandable
code that is easier to maintain and collaborate on.

References
• Python Software Foundation. PEP 8 – Style Guide for Python Code.
[Link]

• Eric Matthes. Python Crash Course, Page 133.

• GeeksforGeeks. PEP 8 – Coding Style Guide for Python.


[Link]

You might also like