Python Guide | Using Keyboard Input Function. (input & raw_input).
Python Keyboard Input. Here is a basic python tutorial, nosotros volition larn how to utilization input keyboard part on this program. Almost every computer program surely utilization the keyboard input commands. In fact, in that place are a diversity of ways to mail an input. For representative input from the keyboard, from a mouse click, input from the database, input from to a greater extent than or less other computer. For this case, nosotros volition demo you lot how to utilization input function, nosotros tin input string information or integer data.
There are ii kinds of input commands you lot involve to know,
- First, raw_input
- This ascendence reads a business from input, then returns a string past times stripping a trailing newline.
- Second, input
- Used to get an expression from the keyboard input, for example, mathematics seem (3*3, 9+2, 5/2, ...etc)
So, if you lot nevertheless confuse amongst my explanations. Now follow the tutorial remove below.
Raw_input
- Syntax 1.
- Syntax 2. the syntax read the Address using raw_input() together with display dorsum on the hide using print():
- Syntax 3.
data = raw_input('please input your information hither :') impress (data)
name=raw_input('Who is your refer ? ') impress ("Hello %s, Nice to run into you" % name);
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 alive in\t\t:",Address
Input.
Only Integer information type tin live on entered here.
- Math Operations.
- the syntax read the Address using raw_input() together with input () together with thence display dorsum on the hide using print():
result=input("Calculation :") impress result
yourname = raw_input("What's your name? ") print("Nice to run into you lot " + yourname + "!") historic menses = input("Your age? ") print("So, you lot are already " + str(age) + " years old, " + yourname + "!")
Add your comment