Module 4 4930

Daniel Tafmizi

Dr. Friedman

Lis 4930

June 10, 2024

Module 4

GitHub link: DanielDataGit/lis4930 (github.com)

Comments: I enjoyed going back to my algebra days. It has been a while since I reviewed quadratic equations and had to do some googling. Overall, I did not run into much trouble with the prompts.

For the second question I kept putting x/y instead of x/n, but I resolved the issue after some mental focusing. 

Question: How can I prevent the "none" at the end of the incDenominator script? I resolved the issue. I was printing a print.

import math


def quadraticroots(a, b, c):
# calculate discriminant
discriminant = b ** 2 - 4 * a * c
# plus minus sign
fancysym = u"\u00B1"
# calculates roots based off of discriminant
if discriminant > 0:
print(f"The roots are: {(-b + math.sqrt(discriminant)) / (2 * a)} , {(-b - math.sqrt(discriminant)) / (2 * a)}")
elif discriminant == 0:
print(f"The roots is: {(-b + math.sqrt(discriminant)) / (2 * a)}")
else:
rp = -b / (2 * a)
ip = math.sqrt(abs(discriminant)) / (2 * a)
print(f"The roots are: {rp} {fancysym} {ip}i")


quadraticroots(1, -5.86, 8.5408)
quadraticroots(1, -4, 4)
quadraticroots(1, 2, 5)

The roots are: 3.1400000000000006 , 2.7199999999999998
The roots is: 2.0
The roots are: -1.0 ± 2.0i

def incDenominator(x):
if x > 0:
y = range(1, 11)
for n in y:
print(x/n)
z = incDenominator(1)
print(z)

1.0
0.5
0.3333333333333333
0.25
0.2
0.16666666666666666
0.14285714285714285
0.125
0.1111111111111111
0.1
None



Comments

Popular posts from this blog

First Day Assignment

Module 10 Assignment

Final Project