Skip to content

Commit 7a6932f

Browse files
committed
Add bad pep8 code that'll break the linters
1 parent d7659cb commit 7a6932f

File tree

7 files changed

+51
-0
lines changed

7 files changed

+51
-0
lines changed

pep8-beautiful-code/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# How to Write Beautiful Python Code With PEP 8
2+
3+
This repository contains a code snippets shown in the tutorial on [How to Write Beautiful Python Code With PEP 8](https://realpython.com/python-pep8/).
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"""This is a docstring."""
2+
3+
# ...
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
def mixed_indentation(greet=True):
2+
if greet:
3+
print("Hello") # Indented with 4 spaces.
4+
print("World") # Indented with a tab.
5+
6+
mixed_indentation()

pep8-beautiful-code/quadratic.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
def quadratic(a, b, c):
2+
"""Solve quadratic equation via the quadratic formula.
3+
4+
A quadratic equation has the following form:
5+
ax**2 + bx + c = 0
6+
7+
There always two solutions to a quadratic equation: x_1 & x_2.
8+
"""
9+
x_1 = (-b + (b**2 - 4 * a * c) ** (1 / 2)) / (2 * a)
10+
x_2 = (-b - (b**2 - 4 * a * c) ** (1 / 2)) / (2 * a)
11+
12+
return x_1, x_2
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
x = 1 + 2 + \
2+
3 + 4
3+
4+
print(x)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import math
2+
3+
numbers = [1,2,\
4+
3,4]
5+
6+
def add_all_numbers_from_collection(
7+
number_one, number_two, number_three,
8+
number_four):
9+
return number_one+number_two + number_three +number_four
10+
11+
print (add_all_numbers_from_collection( *numbers ))

pep8-beautiful-code/variance.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
def calculate_variance(number_list):
2+
sum_list = 0
3+
for number in number_list:
4+
sum_list = sum_list + number
5+
mean = sum_list / len(number_list)
6+
7+
sum_squares = 0
8+
for number in number_list:
9+
sum_squares = sum_squares + number**2
10+
mean_squares = sum_squares / len(number_list)
11+
12+
return mean_squares - mean**2

0 commit comments

Comments
 (0)