Skip to content

User Input

Python Input and Conversion Functions

1. input()

The input() function is used to take input from the user. This function allows for prompting the user for input, which is then treated as a string.

Example:

age = input("Enter Age")

2. int()

The int() function is used to convert a string or a number to an integer.

**Example:**
int(input("Enter Age"))

3. float()

The float() function is used to convert a string or a number into a floating-point number.

**Example:**
float(input("enter the value"))

4. \n (New Line)

The \n sequence is used within strings to move the cursor to the next line when the string is printed.

**Example:**
eg:  print("Employee Name =", name, "\nEmployee ID =", id, "\nSalary =", salary, "\nDesignation =", designation, "\nEmail Id =", email, "\nPhone Number =", phone)

Reference Code