Close Menu
    Facebook X (Twitter) Instagram
    pyprogramming.org
    Facebook X (Twitter) Instagram
    pyprogramming.org
    Home»Python»Writing Program in Python
    Python

    Writing Program in Python

    Python ProgrammingBy Python ProgrammingJanuary 19, 2023No Comments3 Mins Read
    Facebook Twitter Pinterest LinkedIn Tumblr Email
    Writing Program in Python
    Share
    Facebook Twitter LinkedIn Pinterest Email
    • What is a program?
    • Writing our first Python program
    • Comments and Indentation in Python
      • Comments in Python
      • Understanding Indentation
    • To Summarize

    What is a program?

    A program is a set of instructions that tells the computer how to perform a specific task. A programming language is a language used to create programs. We will be using Python to create our first program.

    Does this mean I can make my computer do anything?
    Yeah, true within its limits.
    Everything involves giving instructions. E.g.: When you click on the Play button on a media player and the music starts playing, there is a program working behind the scenes which tell the computer to turn on the music when the Play button is clicked.

    Writing our first Python program

    Let’s start with a hello world program, usually, the first program learned when studying a language. We want to display “Hello World” on the output screen. But, how?

    Let’s see.

    To tell the computer to write to the screen, we use the print statement.

    print()

    It is a built-in function in Python to display things on the screen.
    A built-in function is a function that is predefined and can be used directly.

    Whatever we want to display, needs to be written inside brackets and enclosed within double quotes ” “. So, to display Hello World:

    print(“Hello World”)

    Output: Hello World

    Comments and Indentation in Python

    Comments in Python

    Comments are pieces of code that are ignored by the Python interpreter. Comments are written to make source code easier to understand by other people. Python supports single-line comments, meaning that they can cover only one line. Anything written following # is considered a single-line comment in Python.

    # This is a comment in Python.

    Understanding Indentation

    Program in Python

    Indentation in Python refers to the (spaces and tabs) that are used at the beginning of a statement. The statements with the same indentation belong to the same group called a suite. Thus, it is used to create or represent a block of code.

    For example, Let’s try and run the below code,

    print("Hello Programmer!")
         print("I am indented")

    The above piece of code will give an error since the second print statement is indented which is not expected. You will surely understand this more once you write more code in Python.

    To Summarize

    The print() function can be used to write the output on the screen.
    The text to be printed has to be enclosed in quotes (” “)
    print() is a built-in function.

    # is used to write comments in Python. The concept of indentation has to be kept in mind while writing the code in Python

    Comments in Python python program Python3
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Python Programming
    • Website

    Related Posts

    How to Plot Line of Best Fit in Python (With Examples)

    June 10, 2025

    Reading XML in Python

    February 17, 2025

    The Even Groups Problem in Python

    August 26, 2024
    Leave A Reply Cancel Reply

    Facebook X (Twitter) Instagram Pinterest
    © 2026 ThemeSphere. Designed by ThemeSphere.

    Type above and press Enter to search. Press Esc to cancel.