During AMC testing, the AoPS Wiki is in read-only mode and no edits can be made.

Difference between revisions of "Input function"

(Created page with 'In Python, the '''input''' function prompts the user for input. It has the following syntax answer = input([prompt]) When called, it will print <tt>prompt</tt> to the scree…')
 
 
(One intermediate revision by one other user not shown)
Line 9: Line 9:
  
 
[[Category:Introduction to Programming]]
 
[[Category:Introduction to Programming]]
 +
[[Category:Python Functions]]
 +
[[Category:Computer programming]]

Latest revision as of 15:11, 18 May 2025

In Python, the input function prompts the user for input. It has the following syntax

answer = input([prompt])

When called, it will print prompt to the screen, and wait for the user to type something and press enter. Then, the text the user entered is stored as a string in answer.

Because the user input is always stored as a string, to convert it to an integer or floating point number it's necessary to use one of Python's type conversion functions.

See Also

Python 3.2 Documentation