Quiz Space

Programming in Python OPPE 2: January 2025, Set 1 (January 2025 term)

Question 1

+10 marksProgramming

Write a function is_multiple(a, b) that returns True if a is a multiple of b or b is a multiple of a, and False otherwise. Both numbers are positive.

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

is_multiple(10, 5) -> True
is_multiple(7, 3) -> False

Your task

Implement this function:

def is_multiple(a: int, b: 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.

Example

Input

10
5

Output

True

Question 2

+10 marksProgramming

Write a function starts_and_ends_with_same_vowel(s) that returns True if the first and the last letter of the non-empty string s are the same vowel (a, e, i, o or u), without regard to upper or lower case. Otherwise it returns False.

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

starts_and_ends_with_same_vowel("Apple") -> False
starts_and_ends_with_same_vowel("Atta") -> True

Your task

Implement this function:

def starts_and_ends_with_same_vowel(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

"Apple"

Output

False

Question 3

+10 marksProgramming

The tuple t has an even number of elements. Write a function add_middle_elems_to_ends_in_even_length_tuple(t) that takes out its two middle elements and returns a new tuple in which the first of them is at the beginning and the second one is at the end. The other elements stay between them, in their original order.

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

add_middle_elems_to_ends_in_even_length_tuple((10, 20, 30, 40)) -> (20, 10, 40, 30)
add_middle_elems_to_ends_in_even_length_tuple(("Lenovo", "Dell", "HP", "Asus")) -> ('Dell', 'Lenovo', 'Asus', 'HP')

Your task

Implement this function:

def add_middle_elems_to_ends_in_even_length_tuple(t: tuple) -> 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: t.

Example

Input

(10, 20, 30, 40)

Output

(20, 10, 40, 30)

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 2 Jan 2025 Set 1 paper

The IIT Madras BS Programming in Python (Python) OPPE 2 paper sat on Jan 2025, in the January 2025 term (T1 2025), 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 2 Jan 2025 Set 1 at a glance
TermJanuary 2025 term (T1 2025)
SubjectProgramming in Python
Course codeBSCS1002
Questions7
Marks100
Duration180 min
Programming7
Official paperOPPE 2, Jan 2025 Set 1
Negative markingNo negative marking.
Updated

Other sets that day

More Python