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
- Syntax 1.
- Result.
python raw_input example - Syntax 2. the syntax read the Address using raw_input() and display back on the screen using print():
- Result
python raw_input example - Syntax 3.
- Result
raw_input python
data = raw_input(please input your data here :)
print (data)
name=raw_input(Who is your name ? )
print ("Hello %s, Nice to meet you" % name);
name=raw_input("Who is your name :");
Address=raw_input("Where is your Address :");
print"Your Name is :",name
print"You live in :",Address
Input.
Only Integer data ty pe can be entered here.
- Math Operations.
- result.
input python - the syntax read the Address using raw_input() and input () then display back on the screen using print():
- Result.
raw_input and input python
result=input("Calculation :")
print result
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 + "!")
No comments:
Post a Comment