PYTHON BUILT-IN FUNCTIONS
Python Built-in function: We are going to learn how to get input from the user through the input function and also how to calculate the length of the string through len() function and also learn more about Python’s built-in function. Both are predefined functions that is very important to understand. There are many predefined functions in python like str(), int() and float(), etc that have been discussed in the previous lectures.
Input() Function
The input function is used to get input from the user. The input function is a predefined function in Python Documentation that is used to get input from the user.
Let we take an example program that takes input from the user and prints on the screen.
Example:1
print ("What is your roll no?") input () #used to get input from the user print ("Thank You!") y=input ("what is your name? ") # print message and take input print ("Thank you for authentication!" +y)
Description: This example program get input from user and print on the screen. Input function is a predefined function that gets input from the user. The print function is used to print following user’s input on the screen. In the fourth line of program, input() function that takes input from user and store in the given variable “y”.
Len() Function
Len stands for length. Len() function is a predefined function that returns the length of the string. Which is used to calculate the length of the string? Let we take an example to understand the basic concept of len() function.
Example:1
name = "computer" # str is a veriable
print(len(name)).
Output: 8
Description: len() function given us information of string’s length. You can print the length of any string by using print statements.
We will read more about them in upcoming lectures with the passage of time. Every concept will be clear on the same platform. I assure you that you will not need to read someone else lectures. I hope this lecture is very helpful to understand “Python Built in function”.
Â