OPPE 2 Revision/Practice Session

preview_player
Показать описание

Рекомендации по теме
Комментарии
Автор

how can we get the pdf of this session

simantkumar
Автор

def is_present_in_opposite_halves(elem, l1: list, l2: list):
"""
Determines whether an element is present in the first half of one list
and the second half of the other list, or vice versa.

Args:
elem (Any): The element to check for.
l1 (list): The first list to search.
l2 (list): The second list to search.

Returns:
bool: True if `elem` is present in opposite halves of `l1` and `l2`,
False otherwise.
"""
mid1 = len(l1) // 2
mid2 = len(l2) // 2

if elem in l1[:mid1] and elem in l2[mid2:]:
return True
elif elem in l1[mid1:] and elem in l2[:mid2]:
return True
return False

Rehan-Nazir
Автор

def

return len(str(abs(num))) == 2 and num % 2 == 0

Rehan-Nazir