Wednesday 15 October 2014


How to Get User Input From the Command Line in a Python Script

Assalamualaikum and hye all. Before this, in class we do not learn how to get user input in Python script. I was curious to know how to get user input in Python script. So, I was looking for it and here I will share it to all of you. In my opinion, Python script is more easier and simple than Java script.

Here is an example Python command line script that demonstrates how to obtain data from the user:

1.Open a notepad


 2. Type the coding


3. Save the file with extension. .py (I save it with name TestInput.py)


4. Open cmd and run the file at cmd.

The coding is successfully done. :) - double click to enlarge

In Java, to get the same output we need about 14 lines of coding, while in Python we just need only 3 lines of coding.

double click to enlarge


Ok only this for this week post. Happy learning Python everyone. Thank you.

Resources:http://sweetme.at/2014/01/22/how-to-get-user-input-from-the-command-line-in-a-python-script/

 

1 comment:

  1. Thank you kak farahana...Your post is about python that what I want to know...

    ReplyDelete