View Categories

Basic Python Program

Basic Python Program

This is a simple Python program that prints Hello World on the screen. Most programmers write the Hello World program as their first program.

First_program.py
Copy to clipboard
print("Hello, World!")

Python Program Explained

  • No main Function needed: Unlike other programs, basic Python programs execute sequentially from the first line without requiring a starting function wrapper.
  • print(...): The built-in function used to output text to the console screen.
  • "Hello, World!": The text string to display, which can use either double quotes (") or single quotes (').
  • No curly braces {}: Python defines blocks of code using indentation (spaces) rather than braces.
  • No semicolons ;: Python uses a new line to signify the end of a statement, making semicolons unnecessary.

Basic Python Program For Printing Name

To print a specific name, replace the text inside the quotation marks with just write like this.

NamePrint.py
name = "Computerkite"
print(name)

Semicolons (Optional, Rarely Used)

Semicolons are optional in Python. You can write multiple statements on one line by separating them with ; But this is rarely used because it makes it hard to read:

Example
Copy to clipboard
print("Hello"); print("How are you?"); print("Bye bye!")

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to Top