Python Basics – Introduction to Python

Python is a general-purpose programming language and has lots of uses. It’s one of the high-level programming languages and thus easier to read and write.



Python Introduction

Python was created by Guido van Rossum in December 1989. As mentioned by Guido, the name Python was the working project title of his programming project inspired by the British comedy group Monty Python.


Python is also an open-source software which means it is free to use and distribute, even for commercial use.


Python Basics

Let’s look at some of the basics of Python including its syntax and writing your first Hello World program in Python.


Python is really easy to write and you will see this from writing your first few valid python code blocks.


Python Programming Terms

As in any programming language terms, Python has variables, functions, and objects.


Variable:

Variable is a way to store data in Python.


Here’s how to write a variable in Python.


variable_name = “variable value”


Functions and Objects:


Functions have a name and usually have a value.


Functions are always written in a specific way in Python.


The function’s first line should end with a colon


python_function_name():


and the function body, the line or lines that belong to the function should be indented.


print(“this is the function body”)


Python Syntax

Like all programming languages, Python has its own rules. The syntax is like grammar rules in a programming language.


The good thing about Python is that it also has rules on the style and so everyone’s Python code looks similar, making it easy to read others' code.


Writing Hello World in Python

Now that you know a few things about Python, let’s learn how to write the infamous Hello World with Python.


You will need to have Python installed on your computer and use a suitable code editor to create Python files.


Python files have the extension .py


Using your code editor, create a file Hello_world.py and write the code below.


print("Hello World!")


Now, run the Python file in the shell and it will print Hello World!


It’s that easy to get started to Python!


What do you think?

Previous Post Next Post

نموذج الاتصال