Quiz Space

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

Question 1

+10 marksProgramming

Write a function is_even_or_divisible_by_5 that takes an integer as input and return True if it is even or is divisible by 5 else 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

is_even_or_divisible_by_5(8) -> True (8 is even number)
is_even_or_divisible_by_5(10) -> True (10 is even number and divisible by 5)
is_even_or_divisible_by_5(15) -> True (15 is divisible by 5)
is_even_or_divisible_by_5(7) -> False (not an even number nor divisible by 5)

Your task

Implement this function:

def is_even_or_divisible_by_5(num: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: num.

Example

Input

8

Output

True

Question 2

+10 marksProgramming

Write a function deinterleave that takes a string s as input and returns a new string where the characters at even indices are placed before the characters at odd indices.

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

"abcdef" -> "acebdf"
"12345" -> "13524"

Your task

Implement this function:

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

'abcdef'

Output

'acebdf'

Question 3

+10 marksProgramming

Write a function make_dict_from_elems_in_index that returns a dictionary consisting of a single key-value pair formed as follows:

the key is the element at the given index from the list keys. the value is the element at the given index from the list values .

Assume the index is always within valid bounds for both lists.

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

>>> keys = ['apple', 'banana', 'cherry']
>>> values = [10, 20, 30, 40]
>>> make_dict_from_elems_in_index(keys, values, 1)
{'banana': 20}
>>> make_dict_from_elems_in_index(keys, values, -1)
{'cherry': 40}

Explanation

Elements of keys, values at index 1 are banana, 20 respectively. Hence the dictionary is {'banana': 20} Elements of keys, values at index -1 are cherry, 40 respectively. Hence the dictionary is {'cherry': 40}

Your task

Implement this function:

def make_dict_from_elems_in_index(keys, values, index:int)-> dict:

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: keys, values, index.

Example

Input

['apple', 'banana', 'cherry']
[10, 20, 30, 40]
1

Output

{'banana': 20}

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

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

Other sets that day

More Python