Quiz Space

Programming in Python OPPE 1: January 2026, Set 3 (January 2026 term)

Question 1

+10 marksProgramming

Write a function near_multiple(n, k) that returns the multiple of the positive integer k which is nearest to the non-negative integer n. If n is exactly in the middle of two multiples, return the larger one.

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

near_multiple(13, 5) -> 15
near_multiple(12, 5) -> 10

Your task

Implement this function:

def near_multiple(n: int, k: int) -> 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: n, k.

Example

Input

13
5

Output

15

Question 2

+10 marksProgramming

The string s has at least 2 lowercase letters. Write a function encode_by_shifting_ends(s) that returns s with its first letter replaced by the next letter of the alphabet and its last letter replaced by the previous letter of the alphabet. The letters in the middle stay as they are. There are two exceptions: a first letter z stays z, and a last letter a stays a.

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

encode_by_shifting_ends("abc") -> 'bbb'
encode_by_shifting_ends("hello") -> 'ielln'

Your task

Implement this function:

def encode_by_shifting_ends(s: str) -> str:

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

"abc"

Output

'bbb'

Question 3

+10 marksProgramming

Write a function repeat_second_half(t) that takes a tuple t and returns a new tuple where the second half of the original tuple is repeated after the first half. If the tuple has an odd number of elements, the middle element should be included in the first half.

Constraints

The input tuple will contain at least two elements.
The elements in the tuple can be of any type (integers, strings, etc.).

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

>>> repeat_second_half((1, 2, 3, 4, 5))
(1, 2, 3, 4, 5, 4, 5)
>>> repeat_second_half((10, 20, 30, 40))
(10, 20, 30, 40, 30, 40)
>>> repeat_second_half(('a', 'b', 'c', 'd', 'e', 'f'))
('a', 'b', 'c', 'd', 'e', 'f', 'd', 'e', 'f')
>>> repeat_second_half((1, 2, 3))
(1, 2, 3, 3)

Your task

Implement this function:

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

(1, 2, 3, 4, 5)

Output

(1, 2, 3, 4, 5, 4, 5)

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 Jan 2026 Set 3 paper

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

Other sets that day

Same OPPE 1, other subjects

More Python