Quiz Space

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

Question 1

+10 marksProgramming

Write a function is_even_and_second_last_digit_is_two that takes an integer input num and returns a boolean value. The function should check if the number is even and if the second last digit is two. If both conditions are satisfied, return True; otherwise, return False.

Examples

>>> is_even_and_second_last_digit_is_two(232)
False
>>> is_even_and_second_last_digit_is_two(120)
True
>>> is_even_and_second_last_digit_is_two(25)
False
>>> is_even_and_second_last_digit_is_two(13)
False

Your task

Implement this function:

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

232

Output

False

Question 2

+10 marksProgramming

You are given a string s and an integer n. Your task is to capitalize the nth character in the string s, If n is greater than the length of the string, return the string unchanged.

Examples

>>> upper_nth_index_char("hello", 1)
'hEllo'
>>> upper_nth_index_char("python", 3)
'pytHon'
>>> upper_nth_index_char("python", 9)
'python'

Your task

Implement this function:

def upper_nth_index_char(s: str, n: 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: s, n.

Example

Input

"hello"
1

Output

'hEllo'

Question 3

+10 marksProgramming

Given two lists list1 and list2, merge both lists and return a set with all the elements in the list1 and list2.

Examples

>>> merge_and_remove_duplicates([1, 2, 2], [2, 1, 1])
{1, 2, 1}
>>> merge_and_remove_duplicates(["ant", "bat"], ["bat", "cat"])
{'ant', 'bat', 'cat'}

Your task

Implement this function:

def merge_and_remove_duplicates(list1: list, list2: list) -> set:

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: list1, list2.

Example

Input

[1, 2, 2]
[2, 1, 1]

Output

{1, 2}

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

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

Other sets that day

More Python