Python input from command line -

Python input from command line

Python input from command line

Hello Students! if you are searching the article Python input from command line that you are on right place. User enters the values in the Console and that value is then used in the program as it was required To take input from the user we make use of a built-in function input().

input()–  input() function can be used to read data directly from the keyboard in the form of string type. We have to convert that string type to our required type by using type casting method.

How the input() function works in Python

1) When input function executes program flow will be stopped until the user has given an input.

2) Whatever you enter as input, input function convert it into a string. If you enter value still input() function convert it into a string. You need to explicitly convert it into an integer in your code using typecasting.

Syntax 1-



syntax 2-


Python Tokens

Smallest individual unit within a program is called Token.

Python has the following types  tokens-

1) Identifiers
2) Keywords
3) Literals
4) Punctuator
5) Operators

1) Identifier- We have to use names to identify variable or to identify methods and functions that name it self called identifiers.

For Example-


Rules of identifiers

i) The only allowed character in python identifiers are alphabet symbols ‘a-z’,’A-Z’,0-9 and underscore(_).
ex- age=18

ii) Identifier should not start with numbers or digit in any programming language.
Ex- marks12=96

iii) Python identifiers are case sensitive


iv) We cannot use reserved words as identifiers.




A variable is a name which is used to refer memory location and used to hold values.In python variable also called an identifier.

How to declare a variable

In C or C++ or Java

int a=100;
float f=52.6f;

Means here we are declaring a variable ‘a’ with the value ‘100’ of type ‘int’ and we are declare another variable ‘f’ with the value 52.6f of type float. Like that we have to declare a variable.Otherwise in compile time, compiler shows an error message.

But in Python

100 Here we declare variable ‘a’ with the value ‘100’, We are not mentioned of type of variable. In python we are not required to declare a variable of type explicitly. Based on your provided value, the type will be considered automatically by the Python virtual machine. Such types of progres languages are called ‘dynamically typed languages’.

Best examples of dynamically typed languages are Python, Javascript. Ruby, Lisp and Tel etc. But in Cor C++ or Java language compulsory we have to declare a variable of type explicitly, so that, these languages are called statically typed languages

2) Keywords- The words which are reserved to represent some meaning or functionalities, such words are called keywords.
Example- if,while,for,import,in etc

3) Literals- Literals can be defined as a data that is given in a variable or constant.


4) Punctuator- These are the symbol that are used in python to organize the structures, statements and expressions.

Examples- [ ], { }, ( ), +=, -= etc

In the Next Blog we will see the last python token Operator. Thanks For Reading the Article. I hope you will understand the topic Python input from command line well and Python token well.

For Practical Python classes Subscribe Our Youtube Channel by click on the below link


Also check the below artical for python notes

Python Algorithm and PSEUDOCODE 

IPS अधिकारी कैसे बनें?

भारतीय सेना में कैसे शामिल हो सकते है ?



1 thought on “Python input from command line”

Leave a Comment