+ 4

Please can some one explain,me this function :- int(input() )

10th Jul 2021, 6:05 AM
stark industries
stark industries - avatar
28 Answers
+ 13
input() is a function used to take user input, for example asking user to enter a name for game etc. Anything given by user will be of type str. int() is a function which is used to convert type str to type int So, int(input()) means takes user input as str and then make it int.
10th Jul 2021, 6:58 AM
Abhiyantā
Abhiyantā - avatar
+ 7
visph , He/she is a beginner that's why I just say str šŸ™ƒ
10th Jul 2021, 8:18 AM
Abhiyantā
Abhiyantā - avatar
+ 4
input() take an input as a string... int(input()) take an input and cast it to an int...
10th Jul 2021, 6:45 AM
visph
visph - avatar
+ 2
You can check this lesson: https://www.sololearn.com/learning/2426/
11th Jul 2021, 3:55 AM
Cmurio
Cmurio - avatar
+ 1
The input() function takes input from the user which is in string format. So even if you enter a numerical value through the keyboard, it will be in str format due to which it cannot be evaluated through computation. The int(input()) converts the str into an int type.
11th Jul 2021, 8:10 AM
Laxman Bist
Laxman Bist - avatar
+ 1
input() is used to take input from user .. , and int is used to convert that users input to integer.. as any input given by user is of type str.
11th Jul 2021, 12:28 PM
Falguni Raja
Falguni Raja - avatar
+ 1
int(input()) The input () function is used to take the value from the user. The value is not defined in the program. By default, the value type will be a string(str). To convert a value type into an integer, the int keyword is used.
11th Jul 2021, 5:00 PM
Jisha Tiwari
Jisha Tiwari - avatar
+ 1
That function takes only integer input of the user
11th Jul 2021, 6:45 PM
Okosi Divine
Okosi Divine - avatar
+ 1
input() is a function in Python for taking string as a input but if you take integer as a input then you have to write int before the input function (int(input()). If you write eval(input()) then interpreter automatically unerstand the data type enter bye the user. That's all
12th Jul 2021, 1:33 AM
Abhishek Kumar
Abhishek Kumar - avatar
+ 1
input() is used to take input from a user . If the data type of the input is different from integer datatype, is then you can convert it into integer data type using the int keyword.
12th Jul 2021, 4:29 AM
Kontent Stacked
Kontent Stacked - avatar
+ 1
Very simple, read built in function of python.
12th Jul 2021, 5:51 AM
Pranjal Rastogi
Pranjal Rastogi - avatar
0
visph Where is the input stored when we type something (without pressing enter) in the command prompt? Is it stored in the memory allocated to the command prompt process?
10th Jul 2021, 7:18 AM
Calvin Thomas
Calvin Thomas - avatar
0
Calvin Thomas input() read characters from standard input (stdin) logical file stream provided by the terminal / command prompt, until a new line char is encounteted... this stream (and stdout / stderr) is created by os for the process wich run your programm... so in a sense, it is "stored in the memory allocated to the command prompt process" (in fact it is stored in specific buffer in memory allocated at the layer of the os, and available for the terminal / command prompt process) https://en.m.wikipedia.org/wiki/Standard_streams
10th Jul 2021, 7:48 AM
visph
visph - avatar
0
Rishav Tiwari int() is a function wich is used to initialize an int: it is a class, and its __init__ method has the signature (x, base=10)... if the argument provided cannot be converted to an int, it raise an exception... but that argument would not be necessarly a string ;P
10th Jul 2021, 8:14 AM
visph
visph - avatar
0
Rishav Tiwari as you explained what is int(), it would have been more right to say "is a function wich is used to convert any value to type int, or raise exception if it's not possible" ^^
10th Jul 2021, 8:22 AM
visph
visph - avatar
0
visph Thank you. So "stdin" means the keyboard? I'm confused about what the standard input is. Is "read from stdin" the same as "read from the keyboard"?
10th Jul 2021, 8:32 AM
Calvin Thomas
Calvin Thomas - avatar
0
Calvin Thomas in most of case, yes... but stdin is an abstraction and can be other source: read the wikipedia article wich I have linked in my previous answer to learn more about standard streams ^^
10th Jul 2021, 8:37 AM
visph
visph - avatar
0
visph Thank you very much.
10th Jul 2021, 8:45 AM
Calvin Thomas
Calvin Thomas - avatar
0
It simply means the input data should be of type integer or whole number
10th Jul 2021, 2:00 PM
Emilio Charles
Emilio Charles - avatar
0
It converts the user input to an integer so you can use it for maths For example: var = int(input()) print(var+1)
10th Jul 2021, 3:13 PM
6hpxq9
6hpxq9 - avatar