Quiz Space

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

Question 1

+10 marksProgramming

Write a function is_both_divisible_by that takes three integers a, b and c as input and checks if a and b numbers are divisible by c. Assume that c number is non-zero.

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_both_divisible_by(10, 15, 5) # both 10 and 15 are divisible by 5
True
>>>is_both_divisible_by(10, 13, 5) # 13 is not divisible by 5
False
>>>is_both_divisible_by(19, 15, 5) # 19 is not divisible by 5
False

Your task

Implement this function:

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

Example

Input

10
15
5

Output

True

Question 2

+10 marksProgramming

Write a function that checks if one string is a rotation of another.

Hint: all the rotations of a particular string will be present in the string formed by concatenating it with itself.

For example the rotations of the word apple can be formed by.

a[pplea]pple - pplea ap[pleap]ple - pleap app[leapp]le - leapp appl[eappl]e - eappl apple[apple] - apple

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_rotation('abcde','cdeab')
True
>>>is_rotation('hello','ehllo')
False
>>>is_rotation('hello','helol')
False

Explanation

Since cdeab is a rotation of abcde,

So, is_rotation('abcde','cdeab') should return True

Your task

Implement this function:

def is_rotation(str1: str, str2: 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: str1, str2.

Example

Input

'abcde'
'cdeab'

Output

True

Question 3

+10 marksProgramming

Given a list with numbers from 1 to n (inclusive) except one number in the range, write a function to find the missing number.

Assume that only one number from the range will be missing in the given list.

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

Given the inputs nums=[1, 4, 2, 4, 6, 5, 6] and n is 6.

The number 3 is missing from the range. So, find_missing_number(nums) should return 3 as it is the missing number.

Your task

Implement this function:

def find_missing_number(nums: list, n: 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: nums, n.

Example

Input

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

Output

3

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 2 paper

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

Other sets that day

More Python