This Python Tutorial by Mayank Gupta, you will learn about User Input in Python, typecasting the user input, some basic uses of list() function, use of split() function, use of map() function for multiple user input, and at last Test Your Skills.
Today’s Subtopics :
1) Taking input from user.
2) How to take input in different data types.
3) Some points about list().
4) Use of split() function.
5) Use of map() function for multiple input.
6) Test your skills.
1. Taking input from user :
We use input() function to take input from user.
It takes the input in String data type.
2. How to take input in different data types.
We can do typecasting to change the data type of input.
int() : To change into integer.
float() : To change into float or Decimal.
3. Some points about list().
A list is created by placing all the items (elements) inside a square bracket [ ], separated by commas.
It can have any number of items and they may be of different types (integer, float, string etc.).
4. Use of split() function.
split() function is used to split the words.
We are using split() function to take multiple inputs from the user.
By default split() function split the words from blank spaces “ “.
5. Use of map() function.
Syntax : map(function, iterable)
The map() function applies a given to function to each item of an iterable and returns a list of the results.
The returned value from map() (map object) then can be passed to functions like list() (to create a list), set() (to create a set) and so on.
6. Test your skills
Q1. print(“Enter two numbers”)
x,y = input().split()
Q2. print(“Enter two numbers”)
x,y = map(int, input().split())
This is the third lecture of the Python series of 13 Videos.
Please Like, Comment, Share and Subscribe to my Channel.
My profile : https://www.xsonic.in/profile/