3 BIT python programming

In this blog you can learn python from basic level to advanced level completely for free

ads header

Tuesday, 11 April 2023

' HELLO PYTHON ! ' and SYNTAX

 

What is python ???


Python is an interpreted, object-oriented, high-level programming language with dynamic semantics. Its high-level built in data structures, combined with dynamic typing and dynamic binding, make it very attractive for Rapid Application Development, as well as for use as a scripting or glue language to connect existing components together. Python's simple, easy to learn syntax emphasizes readability and therefore reduces the cost of program maintenance. Python supports modules and packages, which encourages program modularity and code reuse. The Python interpreter and the extensive standard library are available in source or binary form without charge for all major platforms, and can be freely distributed.


Hello, World!

Print()


#first python program
#Hello Python
print("Hello Python")

Python is a very simple language, and has a very straightforward syntax. It encourages programmers to program without boilerplate (prepared) code. The simplest directive in Python is the "print" directive - it simply prints out a line.

syntax of print():

print("any thing you type appear when you execute the code")

note: you can use single quotes or double quotes inside print() there is no issue in python about quotes like other programming languages

Python SYNTAX

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.



#JUST AN EXAMPLE FOR INDENTATION
if 10 > 9:
  print("10 is greater than 9!")
#WRONG SYNTAX
if 10 > 9:
print("10 is greater than 9!")
note: you can use tab button in your keyboard to get correct indentation and escape from indentation errors

Comments in python

python interpreter exclude the lines with # on beginning of the line

Comments can be used to explain Python code.

Comments can be used to make the code more readable.

Comments can be used to prevent execution when testing code.

There is another way to write multi line comment by using triple quotes in the beginning and at the end of the text what you need to be commented 



#This is a single line comment in python
#These line will not be excecuted by interpreter

print('Hello Python')

"""
THIS
IS 
A
MULTI
LINE
COMMENT
"""
print('Hello World')

No comments:

Post a Comment

Search This Blog

Powered by Blogger.

' HELLO PYTHON ! ' and SYNTAX

  What is python ??? Python is an interpreted, object-oriented, high-level programming language with dynamic semantics. Its high-level bui...