Sunday, November 19, 2017

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 various of ways to sent an input. For example input from keyboard, from mouse click, input from 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 expression from the keyboard input, for example mathematics expression (3*3, 9+2, 5/2, ...etc) 
So, if you still co nfuse 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	:");
    Address=raw_input("Where is your Address :");
    print"Your Name is :",name
    print"You live in :",Address
    • Result
      raw_input python
      raw_input python

Input.

Only Integer data ty pe 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("Whats 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

No comments:

Post a Comment