What are commands? In computing terminology, a command is an instruction given to a computer program so as to do a certain task. These commands can be given or issued via a shell or a command-line-interface. So, here in this post, we will be discussing the various List of Python Commands.

Python Commands — List of Python Commands

Python commands generally end with carriage return character. It means each line in a Python script is a command.

Lets take an example :

print('Roll No. : ', 001)
print('First Name : ', 'Shubham')
print('Last Name : ', 'Pradhan')

One can also use, the backslash character ‘/’ to hitch a press release span over multiple lines, as shown below.

if 10 > 9 and \
    20 <= 30 and \
    True != False 
        print('Hi, Shubham!')

\* '\' or the backslash character hitches a statement in a single logical line which may be in multiple physical lines. */

\* A point to note here is it does not join two different statements in one logical line. */

print('Shubham \
     Ji ...') # a multi-line statement
Output : Shubham Ji ...

print('Shubham') \
print(' Ji ...') # two statements in one logical
SyntaxError: invalid syntax

# Multi-line statements in a single line
list = ['a', 'b', 'c', 'd',
        'e', 'f', 'g', 'h',
        'i', 'j', 'k', 'l']

Indentation in Python

Leading space or tab at the start of the line is taken into account as indentation level of the line, which is use to work out various group of statements. The statements with an equivalent level of indentation considered as a block.

As for example : the various functions, classes, or loops in Python generally contain a block of statements or codes to be executed.

Note : Other programming languages like C# or Java use curly braces { } to denote a block of code. Python uses indentation, generally, a tab to denote a block of statements.

Various Indentation Rules

  • All the lines during a block must use an equivalent indentation, either space or a tab.
  • Python recommends four spaces as indentation to form the code more readable. But, one should not mix space and tab within the same block, because spaces and tabs are very different.
  • A block can have inner blocks, these are known as nested statements, with the next level indentation.

Here, we will see a block of statements with proper indentation :

if 20 > 10:  # 1st block starts
    print("20 is greater than 10") 
    print("Now checking .... if 30 > 20") 
    if 30 > 20: 
        print("30 is greater than 20") # inner block
elif: # 2nd block starts
    print("20 is less than 10") # 2nd block
# Lets now take a Python function as example
def Hello(name):
    print("Hello ", name)

Python Naming Rules

The Python program can generally contain different variables, various functions, classes, modules, packages, these are generally known as Identifiers. An identifier should start with either an alphabet letter (lower or upper case) or an underscore (_). No other characters are allowed, i.e. special characters are not allowed.

  • Identifiers in Python are case sensitive. which suggests variables named age and Age are different.
  • Class names should use the TitleCase convention. It should begin with an uppercase alphabet letter e.g. MyClass, Employee, Person.
  • Function names should be in lowercase. Multiple words may be separate by underscores, e.g. add(num), calculate_tax(amount).
  • Variable names within the function should be in lowercase e.g., x, num, salary.
  • Module and package names should be in lowercase e.g., mymodule, tax_calculation. Use underscores to enhance readability.
  • Use of underscore characters when naming the instance attributes of a category .
  • Two leading and trailing underscores get utilize in Python itself for a special purpose, e.g. __init__, etc.

How to Display an output — List of Python Commands

The print() is an output statement in Python. It echoes the worth of any Python expression on the Python shell. Multiple values are generally display by the only print() function separate by comma.

fname = "Shubham"
print(fname) # display single variable
Output : Shubham

age = 22
print(fname,'--' age) # to display multiple variables
Output : Shubham -- 22

print("Name --", fname, Age -- ",age) # display formatted output
Output : Name -- Shubham, Age -- 22

User’s Input

The input() function is a part of the core library of general Python distribution. It reads the key strokes as a string object which can be a variable having an appropriate name.

fname = input("Enter your first name : ")
lname = input("Enter your last name : ")

Enter your first name: Shubham
Enter your last name: Pradhan

age = input("Enter your age: ")


Enter your age: 22

Python Tips and Tricks

There are some tips and tricks in Python, which anyone who wants to write a good and optimized program, should follow :

  • One can use the various in-built functions in python.
  • Also, use the enumerate function to iterate the object.
  • One can also or actually must use dynamic typing.
  • Use various operators while comparing the values.
  • Also, use conditional expressions for better result.

++ SUMMING UP +++ List of Python Commands

So, we now know what are commands in Python. We have also seen various conventions and rules in Python. We also have seen a List of Python Commands.

Thus, through this article, you shall have an idea about the general steps involving use the various commands in Python. By and through this article, thus, I suppose I have made myself pretty clear. But, in case, you still have some doubts lingering. Then, please do write to me in the comments section and I am as always, ever-ready to help you. And, also solve your many queries and problems.

List of Python Commands

Until then bidding you Good-Bye !!! Ok, wait ….. before you go, you may check out my various other posts. Also, for the simple reason, that is, to enhance your knowledge on various other topics of importance. Also, where ??? Here…… And, if u still want more as in “Dil Mange More” then visit.

Categorized in: