Python Basic Syntax – Python Programming

Basic Python – Introduction to python programming: Like other programming languages, Python also has its own syntax. Syntax of Python has many similarities to Perl, C and Java etc. We will discuss all in detail and also see the basic difference between the syntax of Java and Python and will also understand accordingly.

Traditionally, the first program written in any new language is called “Hello World!” because all it does is display the words. We will see the example of the “Hello World!” program in Java and Python:

Syntax of Python vs Java

Example 1: “Hello World” in Java Programming Language

class PythonLobby {
    public static void main(String[] args) {
        System.out.println("Hello, World!"); 
    }
}

Example 2: “Hello World” in Python Programming Language

print("Hello World!")

Here we can easily observe the difference between both of them by the above-given examples.

Important: Things to remember

Indentation: In the Python programming language you will be getting rid off, of curly braces. If you are from a programming background and having some taste in C/C++ or Java then you can easily understand the importance of curly braces in those programming languages.

But in Python instead of curly braces indentation will be there. Indentation refers to the spaces at the beginning of a code line. Python uses indentation to indicate a block of code. We cannot skip the indentation in the python program.

From a Syntax point of view that much knowledge is enough. But for more understanding and knowledge I have described some more concepts of python programming in which most of the time people remain confused.

Function definition difference between Python and Java

Function definition in Java:

public fun_name() {
     system.out.println("Hello World");
}
Function definition in Python:

def fun_name:
    print("Hello World")

 

Explanation:

  • As discussed above, in other programming languages like Java, C++ etc. Curly braces rule { } is used. The compiler understands that the code written inside the curly braces is the separate code that is to execute only when some specific tasks need to perform.
  • While in Python, instead of curly braces indentation is used followed by a colon (:) before.
  • The same rule satisfies defining classes.
  • Note: This is the optional section. If you are a complete beginner you can skip this section of explanation. We’ll be covering each and every topic from Zero to Hero.

 

Features of Python basic python - introduction to python programming

Programming Glossary

  • Problem Solving: The process of formulating a problem, finding a solution and we can also say that to express solution.
  • High-Level Language: Any programming language that is designed to be easy for a human to understand in terms of reading and writing.
  • Low-Level Language: Languages that machines understand are called low-level language or assembly language.
  • Interpret: To execute a program in a high-level language by translating it one line at a time.
  • Compile: To execute a program in a high-level language by translating it all lines at a time.
  • Portability: The property of a program that can be independent on a platform or we can say that program that can run on any operating system.
  • Source Code: A program in a high-level language before being compiled.
  • Object Code: The output generated by executing source code by the compiler after it translates the program, that object is used to run to generate the final output. I know it’s a little bit tricky to understand if you are beginners.
  • Program: A set of instructions that performs some operation.
  • Bug: An error in a program.

If your are a complete beginner to programming field that it may be possible that you are not comfortable
or familiar with some of the words explained above.

You don’t need to worry about that I will make it clear in upcoming articles.”