Hello! I am new to PyTorch and I am here because I need help! I am learning Python and can’t really find a one-on-one tutor over the summer. Extension activities help. (I’m a teacher, too). I’ve seen the topic I need help with a few times, but I still can’t figure out why I’m still getting the error.
HELP!
The error is throws is for line 79: " Python takes 1 positional argument but 2 were given". However, I included the self argument.
“”"Class-based Leibniz formula for Pi.
Description: This program executes the Pi function by way of classes and also executes the circumference of a circle, the area of a circle, the volume of a circle and the surface area of a circle.
Programmer: Tecia Marshall
“”"
class Pi_LeibnizClass:
“”“A class for use with the Leibniz formula for Pi.”""
def init(self,n):
“”“Calculates the value of Pi.”""
numerator = 4
denominator = 1
self.value_of_pi = 0
counter = 0
while counter < n:
nextterm = numerator/denominator * (-1)**counter
self.value_of_pi += nextterm
denominator += 2
counter += 1
def get_circumference(self):
"""Displays calculated value of the circumference of a circle."""
return (self.value_of_pi) * (self.radius) * 2
def get_area(self):
"""Displays calculated value of the area of a circle."""
return (self.value_of_pi) * (self.radius) ** 2
def get_volume(self):
"""Displays calculated value of the volume of a sphere."""
return 4 / 3 * (self.value_of_pi) * (self.radius) ** 3
def get_surfacearea (self):
"""Displays calculated value of the surface area of a sphere."""
return 4 * (self.value_of_pi) * (self.radius) ** 2
def error_message():
“”“This function contains the reusable error message.”""
print(‘You have entered an invalid value. You must enter a positive floating poing value or an integer.’)
main()
def ending():
“”“Allows the user to run the program again or terminate it.”""
print(’’’
Type A to run the program again.
Press Enter to end the program.’’’)
runagain = input()
if runagain == ‘A’:
main()
def main():
“”“This function controls the main thread of the program.”""
print(‘Please enter a floating point value’)
response = input()
try:
max_counter = int(response)
except ValueError:
error_message()
else:
if max_counter <= 0:
error_message()
else:
Leibniz_object = Pi_LeibnizClass(max_counter)
# Collect the number from the user to use for the radius
print ('Please enter your radius number: ')
response = input()
try:
max_counter = float(response)
except ValueError:
print(‘You have entered an invalid value. You must enter a positive floating point value or an integer.’)
print (‘Please restart the program and try again.’)
else:
circumference = Leibniz_object.get_circumference(max_counter)
print (circumference)
area = Leibniz_object.get_area(max_counter)
print (area)
volume = Leibniz_object.get_volume(max_counter)
print (volume)
surface = Leibniz_object.get_surfacearea(max_counter)
print (surface)
ending()
main()