You are currently viewing BAREBONES OF PYTHON PROGRAM

BAREBONES OF PYTHON PROGRAM

Hey!! Dear visitors!! You’re most welcome on bittutech.com. I hope you all are fine. So today, I am going to write an interesting blog post of Python Programming Language to develop your skills.

In Today’s blog post, we will talk about the basic structure of Python program. So here we go –:

Look at the following code and then proceed to the discussion that follows. Don’t worry if the things are not clear to you right now. They’ll become clear when the discussion proceed.

As you can see above program contains various components like–:

  • Expressions
  • Statements
  • Comments
  • Function
  • Blocks and indentation

Let’s discuss various components one by one—:

Expressions

An expression is an legal combination of symbols that represents a value.

For Example–:

15, 2.9, 6.0 } expressions that are values only.

a+5, (3+5)/4 } complex expressions that produce a value when evaluated.

Statements

A statement is a programming instruction that does something means some action takes place in program.

For Example–:

Print ("Hello") #this statement calls print function.

While expression is evaluated, a statement is executed means some action take place. And it is not necessary that a statement results in a value it may or may not yield a value.

Comments

Comments are the additional readable information to clarify the source code.

Comments in Python begin with symbol # ( Pound or hash character ) and generally end with end of the physical line.

NOTE–: A Physical line is the one complete line that you see on the computer whereas a logical line is the one that Python sees as one full statement.

Multi-line Comments–:

You can enter a multiline comment in Python code in two ways–:

i). Add a hash (#) symbol in the beginning of every physical line, part of the multi line comments.

ii). Type comment as a triple-quoted multiline string.

NOTE–: This type of multiline comment is also known as docstring or comments enclosed in triple quotes ( ” ” ” ) or triple apostrophe ( ‘ ‘ ‘ ) is called docstrings.

The docstrings are very useful in documentation.

Functions

A function is a code that has a name and it can be reused (executed again) by specifying its name in the program, where needed.

Blocks and Indentation

A group of statements which are part of another statement or a function or called block or code block or suite in Python.

For Example–:

Many languages such as C, C++, Java etc. use symbols like curly brackets to show blocks but Python does not use any symbol for it, rather it uses indentation.

A group of individual statements which make a single code-block is also called a suite in Python.

NOTE–:

Python uses indentation to create blocks of code. Statements at same indentation level are part of same block/suite.

Statements requiring suit/code-block have a colon(:) at their end. You cannot unnecessarily indent a statement; Python will raise error for that.

Last words-: Hhha!!! I hope you like this blog post. Thank you so much for your support and love. So it’s enough for today we’ll meet soon, till then keep learning and keep exploring :⁠-⁠)

Share post

Prajjwal Singh

Tech Blogger || Web developer || Computer Networking Enthusiast || Microsoft SQL Database Management Expert || Software Debugger || Learned DOS OS Structure

Leave a Reply