Quiz Space

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

Question 1

+10 marksProgramming

Write a function describe_number that takes an integer as input and returns:

"Fizz" if the number is divisible by 3.
"Buzz" if divisible by 5.
"FizzBuzz" if divisible by both 3 and 5.
"Normal" if it is divisible by neither.

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

describe_number(9) -> "Fizz"
describe_number(10) -> "Buzz"
describe_number(15) -> "FizzBuzz"
describe_number(7) -> "Normal"

Your task

Implement this function:

def describe_number(num: int) -> 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: num.

Example

Input

9

Output

'Fizz'

Question 2

+10 marksProgramming

Write a function card_to_value_tuple that takes in a playing card of as a string of format '{rank}{suit}' and returns a tuple of integers format (suit_value, rank_value) as described below.

The suit values from low to high:

S (Spades) - 1
H (Hearts) - 2
D (Diamonds) - 3
C (Clubs) - 4

The rank values from low to high:

A (Ace) - 1
2 through 10 - same as the number
J (Jack) - 11
Q (Queen) - 12
K (King) - 13

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

>>> card_to_value_tuple('AH')
(2, 1)
>>> card_to_value_tuple('7D')
(3, 7)
>>> card_to_value_tuple('QS')
(1, 12)
>>> card_to_value_tuple('9C')
(4, 9)
>>> card_to_value_tuple('10D')
(3, 10)

Your task

Implement this function:

# This mappings can be used as needed.

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: card.

Example

Input

'AH'

Output

(2, 1)

Question 3

+10 marksProgramming

Write a function rotate_even(l, k), which rotates the elements at the even indices by k positions.

Hint: This can be solved using slicing and slice update.

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\

>>> rotate_even([1,2,3,4,5,6],1)
[5,2,1,4,3,6]
>>> rotate_even([1,2,3,4,5,6,7,8],3)
[3,2,5,4,7,6,1,8]

Explanation

rotate_even([1,2,3,4,5,6],1)
+----------+
|  +---+   |
|  |   V   |
| [1,2,3,4,5,6]
|  ^   |   ^
+--+   +---+

Each element moves 1 even index and cycle back.

1 (index 0) moves to index 2
3 (index 2) moves to index 4
5 (index 4) moves to index 0

rotate_even([1,2,3,4,5,6,7,8],3)
 +-----------+
 |   +---+   |
 |   V   |   V
[1,2,3,4,5,6,7,8]
 ^   |   ^   |
 +---+   +---+

Each element moves two even indices and cycle back.

1 (index 0) moves to index 6
3 (index 2) moves to index 0
5 (index 4) moves to index 2
7 (index 6) moves to index 4

Your task

Implement this function:

def rotate_even(l: list, k: int) -> list:

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, k.

Example

Input

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

Output

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

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

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

Other sets that day

Same OPPE 1, other subjects

More Python