Quiz Space

Programming in Python OPPE 1: May 2024, Set 2 (May 2024 term)

Question 1

+5 marksProgramming

Implement the function according to the docstring.

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 the 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

Your task

Implement this function:

def is_right_triangle_with_even_sides(a: int, b: int, c: int) -> bool:

Write the function only — the arguments are read for you and the return value is printed automatically.

Arguments arrive as one Python literal per line, in this order: a, b, c.

Example

Input

6
8
10

Output

True

Question 2

+5 marksProgramming

Implement the function according to the docstring.

Given a string, check if all the odd indices are alphabets and the even indices are digits.

Note: indices start from 0.

Arguments:

  • string: str - the input string

Return:

  • bool - True if all odd indices are alphabets and even indices are digits, else False

Your task

Implement this function:

def is_odd_indices_alpha_and_even_indices_digits(string: str) -> bool:

Write the function only — the arguments are read for you and the return value is printed automatically.

Arguments arrive as one Python literal per line, in this order: string.

Example

Input

'1a2b3c'

Output

True

Question 3

+5 marksProgramming

Implement the function according to the docstring.

Given a list of integers, swap the values at the even indices and the odd indices by modifying the same list.

Arguments:

  • l: list - the input list of integers

Return:

  • None - the input list is modified inside the function.

Your task

Implement this function:

def swap_even_and_odd_indices(l: list) -> None:

Write the function only — the arguments are read for you and the return value is printed automatically.

Arguments arrive as one Python literal per line, in this order: l.

Example

Input

[1, 2, 3, 4]

Output

[2, 1, 4, 3]

6 more questions in this paper

Sign in with Google — it is free — to see every question with its answer and explanation, practise it in learning mode, or take it as a timed mock test.

More on the Python OPPE 1 May 2024 Set 2 paper

The IIT Madras BS Programming in Python (Python) OPPE 1 paper sat on May 2024, in the May 2024 term (T2 2024), set 2: 9 questions for 100 marks in 180 minutes. The first 3 questions are below. Sign in with Google — it is free — to see the whole paper with its answers and explanations, in learning mode or as a timed mock test.

FeaturePython OPPE 1 May 2024 Set 2 at a glance
TermMay 2024 term (T2 2024)
SubjectProgramming in Python
Course codeBSCS1002
Questions9
Marks100
Duration180 min
Programming9
Official paperOPPE 1, May 2024 Set 2
Negative markingNo negative marking.
Updated

Other sets that day

More Python