Computer Science, asked by ThisUsernamesTooLong, 2 months ago

Write a program using python that prints a given number for a given number of times.

For example:
Enter a number : 4
4444

Answers

Answered by Anonymous
28

Printing a number of times - Python

We would take a user input string first, to enter a number.

We know that the input() function returns a string, string is one of the basis types in Python that store text.

To convert it to a number, we can use the \tt int() function.

After that we use str class. \tt str() creates a string format of a value. We know that the \tt str() class converts the argument provided to string datatype.

We then print the number, after that we will display the required result of the program.

\rule{300}{1}

The Program

num=int(input('Enter a number:'))

x=str(num)

print(num*x)

\rule{300}{1}

Sample run

Case 1:

Enter a number: 5

55555

Case 2:

Enter a number: 8

88888888

Answered by BrainlyProgrammer
7

Required Answer:-

n=int(input("Enter a number:"))

print((str(n))*n)

Logic:-

  • Simply convert to string data type and multiply with same number
  • it will print multiple times.

Required Output Attached.

Attachments:
Similar questions