Knowee
Questions
Features
Study Tools

. What will be the output of the following Python code?def say(message, times = 1): print(message * times)say('Hello')say('World', 5)HelloWorld 5HelloWorld,World,World,World,WorldHelloHelloHelloHelloHelloHelloHelloWorldWorldWorldWorldWorld

Question

. What will be the output of the following Python code?def say(message, times = 1): print(message * times)say('Hello')say('World', 5)HelloWorld 5HelloWorld,World,World,World,WorldHelloHelloHelloHelloHelloHelloHelloWorldWorldWorldWorldWorld

🧐 Not the exact question you are looking for?Go ask a question

Solution

The output of the Python code will be:

Hello WorldWorldWorldWorldWorld

Explanation:

The function 'say' takes two arguments: 'message' and 'times'. The 'times' argument has a default value of 1.

In the first function call, say('Hello'), only the 'message' argument is provided. Therefore, 'times' takes its default value of 1. The string 'Hello' is printed once.

In the second function call, say('World', 5), both arguments are provided. The string 'World' is printed 5 times, without spaces, because the print function does not add spaces between repeated strings.

This problem has been solved

Similar Questions

What would be the output of the following Python statement?def func(i):  print('Hello world', i)

What will be the output of the following code?if 15 > 5: print("Hello")elif 10 >= 10: print("World")else: print("Hello World!")Options: Pick one correct answer from belowWorldHelloHello World!Hello World(next line)

What will be the output of the following Python code?def ct(y): global y y+=2 print(y)ct(5)print("hi")Optionserrorhi77hi

ect answer What will be the output of the following Python code?print('py45'.isalnum())

What will be the output of the following Python code?1.  def foo():2.     try:3.       print(1)4.    finally:5.        print(2)6.   7.  foo()

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.