Quiz Space

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

Question 1

+10 marksProgramming

Write a function are_orthogonal that takes two tuples t1 and t2 as input. Each tuple represents a 2D vector with two elements (x, y). The function should return True if the vectors are orthogonal (perpendicular), and False otherwise.

Hint: Two vectors are orthogonal if their dot product is zero. Dot product is the sum of product of the corresponding elements in the vectors.

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

>>> are_orthogonal((1, 2), (12, -6)) # 1*12 + 2*(-6) = 0, equal to zero
True
>>> are_orthogonal((2, 0), (4, 1)) # 2*4 - 1*0 = 8, not equal to zero
False
>>> are_orthogonal((0, 5), (-5, 0)) # 0*(-5) - 5*0 = 0, equal to zero
True

Your task

Implement this function:

def are_orthogonal(t1: tuple, t2: tuple) -> 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: t1, t2.

Example

Input

(1, 2)
(12, -6)

Output

True

Question 2

+10 marksProgramming

Write a function next_roll_no that takes a roll number roll_no as input and returns the next roll number in sequence within the same year and term.

The roll number format is {yy}f{t}{num}, where:

{yy} represents the two-digit year
f is a fixed character

{t} represents the term number (1, 2, or 3)
{num} is a six-digit number padded with zeros on the left

Assume the num part of the roll number will be less than 999999.

Example

next_roll_no("23f2000001") -> '23f2000002'
next_roll_no("24f3099999") -> '24f3100000'

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.

Your task

Implement this function:

def next_roll_no(roll_no: 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: roll_no.

Example

Input

"23f2000001"

Output

'23f2000002'

Question 3

+10 marksProgramming

Write a function has_no_vowels_in_even_indices that takes a string s as input and returns True if there are no vowels in the even indices of the string, otherwise returns 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.

Examples

>>> has_no_vowels_in_even_indices("babebibobu") # The vowels are present in odd indices
True
>>> has_no_vowels_in_even_indices("abcde") # a is present in even index 0
False
>>> has_no_vowels_in_even_indices("test") # only vowel e is present in odd index 1
True
>>> has_no_vowels_in_even_indices("why") # no vowels
True

Your task

Implement this function:

def has_no_vowels_in_even_indices(s: 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: s.

Example

Input

"babebibobu"

Output

True

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

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

Other sets that day

More Python