GATE Assistant

Past questions › Data Science and Artificial Intelligence › GATE 2025

GATE 2025 · DA · NAT · 2 marks · Programming, Data Structures and Algorithms › Python Programming

GATE 2025 Data Science and Artificial Intelligence question: Consider the following Python code snippet. code The value printed by the code snippet…

Consider the following Python code snippet.

def f(a,b):
    if (a==0):
        return b
    if (a%2==1):
        return 2*f((a-1)/2,b)
    return b+f(a-1,b)
print(f(15,10))

The value printed by the code snippet is ____________ (Answer in integer)

Show answer

Official answer: 160

Practise this question with exam-style marking

Discussion

No discussion yet.

Join the discussion