Main.Input History

Hide minor edits - Show changes to markup

January 24, 2010, at 05:05 PM MST by 71.196.160.210 -
Added line 3:
Changed lines 6-7 from:
  1. There are two built-in functions in Python for getting keyboard input:
to:
  1. There are two built-in functions in Python for getting keyboard input
  2. when you want to read a string a string use the "raw_input" function:
Changed lines 10-19 from:

print name

to:

print "name has a type", type(name)

  1. when you want to read numbers use the "input" function:

age = input("your age? ") print "age has a type", type(age)

print name, "says he is", age, "years old"

  1. if you enter an expression using input, python evaluates it:
Added lines 22-26:
  1. you can enter a string using input, but you have to surround it
  2. with quotes

string = input("please enter a string: ") print type(string)

January 21, 2010, at 01:38 PM MST by 129.82.44.241 -
Added lines 1-12:

(:source lang=python:)

"""Getting input from the user"""

  1. There are two built-in functions in Python for getting keyboard input:

name = raw_input("Please enter your name: ") print name expression = input("Enter a numerical expression: ") print expression

(:sourceend:)