Quiz Space

Python OPPE 1: September 2025, Set 3 (September 2025 term)

Question 1

+10 marksProgramming

Write a function shuffle_sentence(sentence, order) that takes a string sentence containing three words separated by spaces and a tuple order specifying the shuffling order.

The function should return a string with the words of the sentence shuffled according to the specified 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.

Examples

sentence = "apple banana orange", order = (0, 2, 1) -> "apple orange banana" Explanation: 0 - apple , 2 - orange, 1 - banana
sentence = "cat dog mouse", order = (2, 1, 0) -> "mouse dog cat" Explanation: 2 - mouse, 1 - dog, 0 - cat

Your task

Implement this function:

def shuffle_sentence(sentence, order):

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: sentence, order.

Example

Input

"apple banana orange"
(0, 2, 1)

Output

'apple orange banana'

Question 2

+10 marksProgramming

Write a function n_unique_letters_in_exactly_one_of(s1, s2) that takes two strings as input and returns the number of unique letters that are present in exactly one of the strings but not in both.

Assume the strings will have only alphabets (both uppercase and lowercase). The letters should be compared in case insensitive manner ('A' and 'a' are considered same).

Hint: Use set operations to find this.

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

>>> n_unique_letters_in_exactly_one_of("APPLE", "plum")

"a", "e", "u" and "m" are the characters that are present in exactly one of the strings.

Your task

Implement this function:

def n_unique_letters_in_exactly_one_of(s1: str, s2: str) -> 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: s1, s2.

Example

Input

"APPLE"
"plum"

Output

4

Question 3

+10 marksProgramming

Write a function that takes an integer n and:

doubles it if it is even, otherwise returns its square.

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.

Examples

>>> double_if_even_else_square(8)
>>> double_if_even_else_square(9)

Your task

Implement this function:

def double_if_even_else_square(n):

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.

Example

Input

8

Output

16

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 2025 Set 3 paper

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

Other sets that day

Same OPPE 1, other subjects

More Python