Python Syntax



Here, you will learn the basic syntax of Python.The Python language has many similarities to Perl, C, and Java. However, there are some definite differences between the languages.


Python Indentation

Indentation refers to the spaces at the beginning of a code line.

Where in other programming languages the indentation in code is for readability only, the indentation in Python is very important.

Python uses indentation to indicate a block of code.

if 10 > 5: 
    print("10 is greater than 5")
    print("Now checking 20 > 10")
    if 20 > 10: 
        print("20 is greater than 10") 
elif: #
    print("10 is less than 5")
    print("This will never print")


Python Variables 

In Python, data are represented by objects or by relations between objects. Use the type() function to get the class name of an object. For example, the following displays the class name of integer value.

x = 5
y = "Hello, World!"

 


Post a Comment

0 Comments