Quiz Space

Python OPPE 2: September 2024, Set 2 (September 2024 term)

Question 1

+10 marksProgramming

Write a function is_both_divisible_by(a, b, c) that returns True if both a and b are divisible by c, and False otherwise. c is never 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) -> True
is_both_divisible_by(10, 13, 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 is_rotation(str1, str2) that returns True if str2 can be obtained by rotating str1, that is, by moving some characters from the front of str1 to its end without changing their order. A string is also a rotation of itself. Otherwise return 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_rotation("abcde", "cdeab") -> True
is_rotation("hello", "ehllo") -> False

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

The list nums was meant to hold every integer from 1 to n, but one of them is missing. Some of the other numbers may appear more than once. Write a function find_missing_number(nums, n) that returns the number from 1 to n that is not in the 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

find_missing_number([1, 4, 2, 4, 6, 5, 6], 6) -> 3
find_missing_number([2, 3, 4, 5], 5) -> 1

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 2 Sept 2024 Set 2 paper

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

Other sets that day

More Python