Open unaveragetech opened 3 weeks ago
Here are the errors I found in your code:
pi
to a variable; it's already defined as a built-in constant. So you can remove this line pi = 3.14
.print("The area of the circle is: " + area)
to print(f"The area of the circle is: {area}")
.main()
function, you're using an assignment instead of comparison in the if name == "main":
statement. It should be if __name__ == "__main__":
.calculate_area()
function. You can do this by adding a float(r)
after the input line.Here's the corrected code:
import math
def calculate_area(radius):
area = math.pi * radius ** 2
return area
def main():
r = float(input("Enter the radius: "))
area = calculate_area(r)
print(f"The area of the circle is: {area}")
if __name__ == "__main__":
main()
this is a python script there are some errors id like you to 1 write all the errors you find a in list and 2 rewrite the code to be correct
""" def calculate_area(radius): pi = 3.14 area = pi radius radius return area
def main(): r = input("Enter the radius: ") area = calculate_area(r) print("The area of the circle is: " + area)
if name == "main": main()
"""