7. Demonstrate with example print(), input(), and string replication function in Python.

1. print() Function

The print() function in Python is used to display text or output on the screen.

2. input() Function

The input() function takes user input during program execution. The input is always taken as a string.

3. String Replication using * Operator

In Python, multiplying a string by an integer using the * operator replicates that string multiple times.

Sample Output: Enter your name: Raj
Raj! Raj! Raj!

Points to Remember:

  • print() displays information.
  • input() waits for the user to type input and returns it as a string.
  • * operator used with strings replicates the string.

Leave a Reply

Your email address will not be published. Required fields are marked *