Python Guide | Using Keyboard Input Function. (input & raw_input)

Python Guide | Using Keyboard Input Function. (input & raw_input).

Python Keyboard Input. Here is a basic python tutorial, we will learn how to use input keyboard function on this program. Almost every program certainly use the keyboard input commands. In fact, there are a variety of ways to send an input. For example input from the keyboard, from a mouse click, input from the database, input from another computer. For this case, we will show you how to use input function, we can input string data or integer data. 

There are two kinds of input commands you need to know, 
  • First, raw_input
    • This command reads a line from input, then returns a string by stripping a trailing newline.
  • Second, input
    • Used to get an expression from the keyboard input, for example, mathematics expression (3*3, 9+2, 5/2, ...etc) 
So, if you still confuse with my explanations. Now follow the tutorial guide below.

Raw_input

  1. Syntax 1.
  2. data = raw_input('please input your data here :')
    print (data)
    • Result.
      python raw_input example
      python raw_input example
  3. Syntax 2. the syntax read the Address using raw_input() and display back on the screen using print():

  4. name=raw_input('Who is your name ? ')
    print ("Hello %s, Nice to meet you" % name);
    • Result
    • python raw_input example
      python raw_input example
  5. Syntax 3.

  6. name=raw_input("Who is your name\t:");
    Address=raw_input("Where is your Address\t:");
    print"Your Name is\t\t:",name
    print"You live in\t\t:",Address
    • Result
      raw_input python
      raw_input python

Input.

Only Integer data type can be entered here.
  1. Math Operations.
  2. result=input("Calculation :")
    print result
    • result.
      input python
      input python
  3. the syntax read the Address using raw_input() and input () then display back on the screen using print():
  4. yourname = raw_input("What's your name? ")
    print("Nice to meet you " + yourname + "!")
    age = input("Your age? ")
    print("So, you are already " + str(age) + " years old, " + yourname + "!")
    • Result.
      raw_input and input python
      raw_input and input python

0 Response to "Python Guide | Using Keyboard Input Function. (input & raw_input)"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel