Всем привет
Можете помочь с кодом?
Не могу понять как исправить ошибку
import threading
# Sa creat o clasa!
class Cub:
def __init__(self, num):
self.num = num
self.lenght = None
self.volum = None
print(“Un cub cu latura de {}”.format(self.num))
# Sa definit o metoda pentru calcularea volumului!
def calc_volum(self):
return “Volumul cubului = {}”.format(self.num * self.num * self.num)
# Sa definit o metoda pentru calcularea tuturor laturilor!
def lenght_lat(self):
self.lenght =self.num * 12
return “Lungimea totala a tuturor laturilor = {}”.format(self.lenght)
# Sunt create doua fire de execuție!
# Am utilizat a doua metoda prima apoi pe a doua cum e cerut în enunț!
if __name__ == “__main__”:
t1 = threading.Thread(target=lenght_lat, args))
t2 = threading.Thread(target=calc_volum, args))
t1.start()
t1.join()
t2.start()
t2.join()
# Primul obiect de tip cub care utilizează clasa CUB!
cub_1 = Cub(10)
# Rezultatele sunt afișate cu comanda print!
print(cub_1.lenght_lat())
print(cub_1.calc_volum())
# Al doilea obiect de tip cub care utilizează clasa CUB!
cub_2 = Cub(12)
# Rezultatele sunt afișate cu comanda print!
print(cub_2.lenght_lat())
print(cub_2.calc_volum())
print(“Finalizare!”)
Ошибка
Exception in thread Thread-1:
Traceback (most recent call last):
File “/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py”, line 954, in _bootstrap_inner
self.run()
File “/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py”, line 892, in run
self._target(*self._args, **self._kwargs)
TypeError: lenght_lat() missing 1 required positional argument: ‘self’
Exception in thread Thread-2:
Traceback (most recent call last):
File “/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py”, line 954, in _bootstrap_inner
self.run()
File “/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py”, line 892, in run
self._target(*self._args, **self._kwargs)
TypeError: calc_volum() missing 1 required positional argument: ‘self’
Результат есть и работает только это ошибка