Knowee
Questions
Features
Study Tools

def print_n(s, n):     if n > 0:          print(s)          print_n(s, n-1)     return nn = 3while print_n("hi", n):     print_n("there!", n)     n = 0

Question

def print_n(s, n):     if n > 0:          print(s)          print_n(s, n-1)     return nn = 3while print_n("hi", n):     print_n("there!", n)     n = 0
🧐 Not the exact question you are looking for?Go ask a question

Solution 1

The code you've provided is written in Python. It defines a recursive function print_n(s, n) that prints a string s n times. If n is greater than 0, it prints the string and then calls itself with n decremented by 1. The function stops calling itself when n is no longer greater than 0.

Knowee AI  is a powerful AI-powered study tool designed to help you to solve study problem.
Knowee AI  is a powerful AI-powered study tool designed to help you to solve study problem.
Knowee AI  is a powerful AI-powered study tool designed to help you to solve study problem.
Knowee AI  is a powerful AI-powered study tool designed to help you to solve study problem.
Knowee AI  is a powerful AI-powered study tool designed to help you to solve study problem.
Knowee AI  

This problem has been solved

Similar Questions

swerWhat will be the output of the following Python code?def demo(p,q):  if(p == 0):    return q  else:    return demo(p-1,p+q)print(demo(4,5))

What will be the output of the following Python code?def foo(x): x[0] = ['def'] x[1] = ['abc'] return id(x)q = ['abc', 'def']print(id(q) == foo(q))

def even_odd_decimal(num): if num%1!=0: return num "is decimal" elif num%2==0: return num "is even" else: return num "is odd"

What will be the output of the following Python code?def foo(k): k = [1]q = [0]foo(q)print(q) [0][1][1, 0][0, 1]

rect answerWhat will be the output of the following Python code snippet?def code(x):  x = x + '3'  print(x*3)  return xcode("hi") # function called

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.