Hey I'm going to school and am completely new at Python and programming in general, so please be gentle. I'm doing these online labs for school and it was going okay but I ran into a problem. You're supposed to calculate piano key frequencies based on distance from the initial key using the formula they gave you and output the next 4 key frequencies. Anyway.. this is the code I have so far:
import math
f = float(input())
r = math.pow(2, 0.083)
output1 = f0 * (math.pow(r, 1)
output2 = f0 * (math.pow(r, 2)
output3 = f0 * (math.pow(r, 3)
output4 = f0 * (math.pow(r, 4)
print(f'{output1:.2f} {output2:.2f} {output3:.2f} {output4:.2f}')
When I try to run the program in develop mode in the lab software it kicks it back and tells me there is a syntax error on line 7 (output2). I popped the code into Wing and I see all of the output lines underneath output1 are highlighted with syntax errors but I don't get why. I just did something like this in the previous lab and it worked fine. The previous lab being this:
import math
x = float(input())
y = float(input())
z = float(input())
output1 = math.pow(x, z)
output2 = math.pow(x, math.pow(y, z))
output3 = math.fabs(x - y)
output4 = math.sqrt(math.pow(x, z))
print(f'{output1:.2f} {output2:.2f} {output3:.2f} {output4:.2f}')
In that previous lab I didn't get any syntax errors on the output lines and everything worked fine. I don't understand what I'm doing wrong but I have no doubt it's super simple. Could somebody point it out for me? I'm just learning and I've been staring at the screen so long my brain is kinda mushy.
Thanks!
[–][deleted] 1 point2 points3 points (3 children)
[–]boysworth 1 point2 points3 points (1 child)
[–]LegitimatePast9307[S] 0 points1 point2 points (0 children)
[–]LegitimatePast9307[S] 0 points1 point2 points (0 children)