Computer Science, asked by vishwajeetsingh9, 5 months ago

What is the output of the below program?

def say(message, times = 1):

print(message * times)

say('Hello')

say('World', 5)​

Answers

Answered by bhumilokhande532
3

Explanation:

say(message,times =1)

Answered by varshamittal029
0

Concept:

A function includes a collection of programming statements and in Python, it is declared with the keyword 'def'.

Given:

def say(message, times = 1):

  print(message * times)

say('Hello')

say('World', 5)

Find:

What is the output of the given program?

Solution:

The * operator is used to make a string repeat itself a specified number of times.

Syntax: string * n

(The string is repeated as many times as n specifies.)

By default, the value of times is set to 1. Therefore it prints the string only one time if the value is not given.

∴ say("Hello") will print Hello only one time.

In say("World", 5), the value of times is set to 5. Therefore, it will repeat World 5 times.

Output:

Hello

WorldWorldWorldWorldWorld

Similar questions