Python: Fix Flake8 E722 and E741

Additionally:

* Use functions to group blocks of code
* Use variable names (not just one character...)
This commit is contained in:
Martin Thoma
2022-03-12 08:17:03 +01:00
parent fc9ea8eaf9
commit af88007734
18 changed files with 846 additions and 764 deletions

View File

@@ -4,11 +4,11 @@
#
# Converted from BASIC to Python by Trevor Hobson
import math
from math import exp, floor, sqrt
def equation(input):
return 30 * math.exp(-input * input / 100)
def equation(x: float) -> float:
return 30 * exp(-x * x / 100)
print(" " * 32 + "3D PLOT")
@@ -16,13 +16,13 @@ print(" " * 15 + "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY\n\n\n\n")
for x in range(-300, 315, 15):
x1 = x / 10
l = 0
y1 = 5 * math.floor(math.sqrt(900 - x1 * x1) / 5)
yPlot = [" "] * 80
max_column = 0
y1 = 5 * floor(sqrt(900 - x1 * x1) / 5)
y_plot = [" "] * 80
for y in range(y1, -(y1 + 5), -5):
z = math.floor(25 + equation(math.sqrt(x1 * x1 + y * y)) - 0.7 * y)
if z > l:
l = z
yPlot[z] = "*"
print("".join(yPlot))
column = floor(25 + equation(sqrt(x1 * x1 + y * y)) - 0.7 * y)
if column > max_column:
max_column = column
y_plot[column] = "*"
print("".join(y_plot))