Quiz Space

Python OPPE 1: September 2024, Set 1 (September 2024 term)

Question 1

+10 marksProgramming

Write a function sum_squares_abs_diff_squares that takes two integer inputs, a and b, and returns a tuple with:

  1. The sum of the squares of a and b.
  2. The absolute difference of the squares of a and b.

NOTE: This is a function type question, you don't have to take input or print the output, just have to complete the required function definition.

Example

Given the inputs a = 3 and b = 4:

Explanation

  • The sum of squares would be 9 + 16 = 25.
  • The absolute difference of squares would be |9 - 16| = 7.

So, sum_squares_abs_diff_squares(3, 4) should return (25, 7).

Your task

Implement this function:

def sum_squares_abs_diff_squares(a:int, b:int) -> tuple:

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.

Example

Input

3
4

Output

(25, 7)

Question 2

+10 marksProgramming

Write a function is_odd_length_palindrome that takes a string s and returns True if s is a palindrome of odd length, and False otherwise.

NOTE: This is a function type question, you don't have to take input or print the output, just have to complete the required function definition.

Example

  • "hello" --> False (not a palindrome)
  • "noon" --> False (palindrome but not odd length)
  • "nun" --> True (palindrome and odd length)

Your task

Implement this function:

def is_odd_length_palindrome(s: 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: s.

Example

Input

'hello'

Output

False

Question 3

+10 marksProgramming

Write a function remove_elements_at_two_indices that takes a list l and two indices i1 and i2. The function should remove the elements at these two indices from the list l.

Assume the indices are non-negative and unique.

The function should not return anything but should modify the input list directly.

NOTE: This is a function type question, you don't have to take input or print the output, just have to complete the required function definition.

Example

>>> l = [1, 2, 3, 4, 5, 6, 7]
>>> i1 = 5
>>> i2 = 1
>>> remove_elements_at_two_indices(l, i1, i2)
>>> l
[1, 3, 4, 5, 7]

Your task

Implement this function:

def remove_elements_at_two_indices(l: list, i1: int, i2: int):

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, i1, i2.

Example

Input

[1, 2, 3, 4, 5, 6, 7]
5
1

Output

[1, 3, 4, 5, 7]

4 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 Sept 2024 Set 1 paper

The IIT Madras BS Programming in Python (Python) OPPE 1 paper sat on Sept 2024, in the September 2024 term, set 1: 7 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 Sept 2024 Set 1 at a glance
TermSeptember 2024 term
SubjectProgramming in Python
Course codeBSCS1002
Questions7
Marks100
Duration180 min
Programming7
Official paperOPPE 1, September 2024 Set 1
Negative markingNo negative marking.
Updated

Other sets that day

Same OPPE 1, other subjects

More Python