Registry Synced

jan-2026-python-week-7-numbers-4

729 words
4 min read

Numbers 4

Course: Jan 2026 - Python
Numbers 4
Submission deadline has passed for this assignment
Due Apr 01, 2026 at 11:59 PM IST
Instructions
Use "Test Run" to verify your code with public test cases.
Press "Submit" to have your assignment evaluated.
You can submit your assignment multiple times up until the deadline.
Make sure to submit your final code by the deadline to receive your score.
Summary
100 out of100
Score
Public Tests
4/4 Passed
Submitted on Apr 01, 2026 at 3:47 AM IST
Private Tests
4/4 Passed
Submitted on Apr 01, 2026 at 3:47 AM IST

**Change in eligibility criteria to write oppe2 exam: A5>=40/100 AND A6>=40/100 AND A7>=40/100 AND A8>=40/100. and becoming eligible to give the end term exam.


Check if right triangle with even side lengths**
Given three side lengths in the increasing order of length as a, b, and c, where a<=b<=c, check if the given sides are the sides of a right triangle whose perpendicular sides are of even length.
Template Code(Click to Expand)

def is_right_triangle_with_even_sides(a:int,b:int,c:int) -> bool:
    '''
    Given three side lengths in the increasing
    order of length as a, b, and c, where a<=b<=c,
    check if the given sides are the sides of a right
    triangle whose perpendicular sides are of even length.

    Hint: in a right triangle the square of hypotenuse is the sum of square of other two sides.

    Arguments:
    a: int - the first side length
    b: int - the second side length
    c: int - the hypotenuse length

    Return:
    bool - True if the sides form a right triangle and the perpendicular sides are even, else False
    '''
    ...


NOTE: You can use the below tools for working out and debugging. Click to open them in new tab.

Public Tests ( 4/4 )

Case 1

Input:
text
is_equal(is_right_triangle_with_even_sides(3, 3, 5), False)

Case 1

Expected Output:
text
False

Case 1

Actual Output:
text
False

Case 2

Input:
text
is_equal(is_right_triangle_with_even_sides(6, 8, 10), True)

Case 2

Expected Output:
text
True

Case 2

Actual Output:
text
True

Case 3

Input:
text
is_equal(is_right_triangle_with_even_sides(3, 4, 5), False)

Case 4

Input:
text
is_equal(is_right_triangle_with_even_sides(4, 6, 8), False)

Private Tests ( 4/4 )

Case 1

Input:
text
is_equal(is_right_triangle_with_even_sides(12, 16, 20), True)
is_equal(is_right_triangle_with_even_sides(12, 16, 20), True)
is_equal(is_right_triangle_with_even_sides(60, 45, 75), False)

Case 1

Expected Output:
text
True

True

False

Case 1

Actual Output:
text
True

True

False

Case 2

Input:
text
is_equal(is_right_triangle_with_even_sides(48, 20, 52), True)
is_equal(is_right_triangle_with_even_sides(68, 51, 85), False)
is_equal(is_right_triangle_with_even_sides(72, 21, 75), False)

Case 2

Expected Output:
text
True

False

False

Case 2

Actual Output:
text
True

False

False

Case 3

Input:
text
is_equal(is_right_triangle_with_even_sides(48, 36, 60), True)
is_equal(is_right_triangle_with_even_sides(48, 64, 80), True)
is_equal(is_right_triangle_with_even_sides(60, 63, 87), False)

Case 4

Input:
text
is_equal(is_right_triangle_with_even_sides(98, 94, 31), False)
is_equal(is_right_triangle_with_even_sides(98, 94, 32), False)
is_equal(is_right_triangle_with_even_sides(48, 64, 80), True)
is_equal(is_right_triangle_with_even_sides(98, 94, 33), False)

Case 4

Expected Output:
text
False

False

True

False

Case 4

Actual Output:
text
False

False

True

False

💻 IITM Official Solution

python

def is_right_triangle_with_even_sides(a:int,b:int,c:int) -> bool:
    '''
    Given three side lengths in the increasing
    order of length as a, b, and c, where a<=b<=c,
    check if the given sides are the sides of a right
    triangle whose perpendicular sides are of even length.

    Hint: in a right triangle the square of hypotenuse is the sum of square of other two sides.

    Arguments:
    a: int - the first side length
    b: int - the second side length
    c: int - the hypotenuse length

    Return:
    bool - True if the sides form a right triangle and the perpendicular sides are even, else False
    '''

    return a**2 + b**2 == c**2 and a % 2 == 0 and b % 2 == 0


💻 My Submitted Code

python
def is_right_triangle_with_even_sides(a: int, b: int, c: int) -> bool:
    # Condition 1: Pythagoras Theorem (a^2 + b^2 = c^2)
    # Since inputs are in increasing order, c is the hypotenuse
    is_right = (a**2 + b**2 == c**2)

    # Condition 2: Perpendicular sides (a and b) must be even
    even_sides = (a % 2 == 0 and b % 2 == 0)

    return is_right and even_sides

Document Outline
Table of Contents
System Normal // Awaiting Context

Intelligence Hub

Navigate the knowledge graph to generate context. The Hub adapts dynamically to surface backlinks, related notes, and metadata insights.