79320631

Date: 2024-12-31 19:06:59
Score: 5.5
Natty:
Report link

print(y * 3)

I have similar issue and still get some errors. I don't know what is wrong in the script, although I put the same operation.:

Vector2D(other * self.x, other * self.y)

class Vector2D:
def __init__(self, x: float | int, y: float | int):
    self.x = x
    self.y = y
    pass

def __mul__(self, other: float | int) -> 'Vector2D':
    if not isinstance(other, Vector2D):
        raise ValueError("IncorrectType")
    return Vector2D(other*self.x, other*self.y)
    pass

When I try to test it by

def test_multiply(self):
    p1 = Vector2D(1, 2)

    mult = p1 * 5

    self.assertTrue(mult == Vector2D(5, 10))

    with self.assertRaises(ValueError):
        mult = p1 * 'Alice'

I have an error: 'line 91, in test_multiply mult = p1 * 5

File "2552856375.py", line 34, in mul raise ValueError("IncorrectType") ValueError: IncorrectType

Reasons:
  • Blacklisted phrase (1): know what is wrong
  • Blacklisted phrase (1): I have similar
  • RegEx Blacklisted phrase (1): I have an error
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Me too answer (2.5): I have similar issue
  • Low reputation (1):
Posted by: Mark