Python - Part 1: Hello World! , Variables and Data types

Python - Part 1: Hello World! , Variables and Data types

Python is a widely used general-purposem, simple language in its own way and is very popular, high level programming language. It was created by Guido van Rossum in 1991 and further developed by the Python Software Foundation. It was designed with an emphasis on code readability, and its syntax allows programmers to express their concepts in fewer lines of code.

Why Python?

It is a programming language which is very close to human language and because of that it is easy to learn and use. It has been used to develop web applications, desktop applications, system adminstration, and machine learning libraries. Python is highly embraced language in the data science and machine learning community.

Hello World in Python

print("Hello World!")

Output:

Hello World!

Congratulations, you have written your first line! I told you it's a comparatively simple language and its code is easy to read.

Comments

Comments are one of the most important things that make your code easier and more readable by writing notes. I forgot something. It also disables your code so that it doesn't work. Once you type the (#) at the beginning of the line, this is a comment.

1. Single Line Comment

# This is the first comment
# This is the second comment
# This is the third comment

2. Multiline Comment

Triple quote can be used for multiline comment.

"""
This is Multiline Comment
"""

Data Types in Python

There are many types of data in Python but we will talk about the most important types of data that we use in development

Number

  • Integer: Integer(negative, zero and positive) numbers. (..., -2, -1, 0, 1, 2, ...)
  • Float: Decimal number. (-2.5, -1.3, 0.30, 1.6, 2.8)
  • Complex: (1 + j, 2 + 4j)

String

A collection of one or more characters under a single or double quote. If the string contains more than one sentence, we use triple quotes

'Python'
'Hashnode'
'I love Python'

Booleans

A boolean data type is either a True or False value.

True
False

List

Python list is an ordered collection which allows to store different data type items.

[0, 1, 2, 3, 4] # list of numbers
['Khairallah', 'Eugene', 'Ayesha', 'Swapna'] # list of string
['Andrew', 24, False, 6.37] # list of string, integer, boolean and float

Dictionary

A Python dictionary object is an unordered collection of data in a key value pair format.

{
'first_name': 'Khairallah',
'last_name': 'AL-Awady',
'country': 'Yemen', 
'is_married': False,
'skills': ['Pthon', 'Django', 'JavaScript', 'ReactJS']
}

Tuple

A tuple is an ordered collection of different data types like list but tuples can not be modified once they are created.

('Khairallah', 'Eugene', 'Ayesha', 'Swapna') # tuple of string

Set

A set is a collection of data types similar to list and tuple. Unlike list and tuple, set is not an ordered collection of items. Like in Mathematics, set in Python stores only unique items.

{0, 1, 2, 3, 4, 5}

That's it, folks! hope it was a good read for you. Thank you! ☺️

Let's connect: