Python Basic Syntax & Comments — Wakeupcoders

programming syntax and comments

Syntax:

  • Python language is very easy to understand language, So like other languages you dont have to mention the main method. Python internally uses __main__ to run the main coding stuff. The rest of the syntax is very easy.
  • Just Open any editor like VSCode or IDLE, Write the basic output statement in that (Check below example), Please make sure latest python is installed.
  • Save the file with name myfirstprogram.py, You can mention any name

>>> print(“wakeup, Coders!”)
wakeup, Coders!

Use the below command to run the python program.

C:\Users\Your Name>python myfirstprogram.py

It will print wakeup, Coders! in console.

Congratulations !! You have learnt how to print the text in a console.

Let’s learn some more syntax.

Basic Conditions:

Write the below code, Save it and run it as we done in previous example.

if 10 > 20:
print(“Ten is higher than twenty!”)

Output: Ten is higher than twenty!

We also can write multiple conditions as well.

if 15 > 21:
print(“Fifteen is higher than twenty One!”)
if 50 > 22:
print(“Fifty is higherthan twenty two!”)

Output: Fifteen is higher than twenty One!, Fifty is higherthan twenty two!

These are the basic syntax that every beginner should practice, There are so many other building blocks that we can use to create complex programs.

Commenting:

What & Why is comments ?

When programs are very complex, To make a program easy to understand we can write labels above or below the code so that it can be easy to understand. Generally comments are ignored by the computer compiler.

Lets see what are the ways we can write the comments.

We use keyword “#” to define a comment. We can write anything that is required for ease purpose.

One Line Comment:

#This is a basic one line comment.
print(“Wakeup, World!”)

Multiline Comment:

#This is a basic one line comment.

#This is basic second line of comment.
print(“Wakeup, World!”)

Docstring Commenting:

using ””” —Enter comment here with multiple line — ”””.

”””

This is a multiple

line of comment

”””

Let’s Wind up:

If you liked this Blog and found this blog informative do share with your friends and co-workers to help them. Till then keep Reading and Enjoying.

Contact us

If you are having any feedback or looking a way to connect with us.

Let’s connect together www.wakeupcoders.com/contact & think beyond everything.

Thanks to the Wakeupcoders Team: For thinking beyond everything

Purnima Sinha (Editor), Narayan Jha (Author), Anjali Jha (digital marketing)

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Wakeupcoders

Wakeupcoders

73 Followers

We make your business smarter and broader through the power of the internet. Researcher | Web developer | Internet of things | AI | www.wakeupcoders.com