Computer Science, asked by shagunnag867, 11 months ago

write a python program to print 3 times hello.​

Answers

Answered by AskewTronics
1

Below are the python program for the above question :

Output :

hello

hello

hello

Explanation:

for x in range(3): #for loop which runs at three times.

   print("hello")#print statement.

Code Explanation :

  • The above code is in python language which holds the for loop which runs on three times.
  • Then the print statement will display the message with the help of print function which is used to display the message.
  • The code holds the for a loop because the above question states that the print message is used for three times.

Learn More :

  • Python : https://brainly.in/question/14689905
Answered by Equestriadash
7

There are three possible codes for this.

1. To assign "Hello" to a variable and multiply it 3 times.

>>> x = "Hello"

>>> print(x*3)

Hello

Hello

Hello

2. To multiply "Hello" as a string value 3 times.

>>> print("Hello"*3)

HelloHelloHello

[NOTE - not adding quotes will result in an error.]

3. To use the for loop.

>>> for i in range(3):

print("Hello")

 

Hello

Hello

Hello

Here, 'i', a variable, has a changing value. The range is given 3, so as to print the string 3 times.

Any variable can be given instead of 'i'.

Similar questions