Python Syntax Basics

Learn the basic syntax of Python with practical examples to print text, numbers, and strings using the print() function.

Basic Syntax of Printing "Hello World"

The basic syntax for printing "Hello World" in Python uses the print() function.

print("Hello World")
        
Output
Hello World
        
Printing a Number

To print a number in Python, simply use the print() function.

print(6)
        
Output
6
        
Strings

A string in Python is enclosed in either double quotes (" ") or single quotes (' '). Strings can contain any character, including special characters.

x = "Small Code"
print(x)
        
Output
Small Code