Learning Python #2 - Data types, operators, variable creation...

Learning Python #2 - Data types, operators, variable creation...

ยท

2 min read

As promised here I am with a new blog post on Python programming where we are going to discuss the below points today:-

  • Data types
  • Operators
  • Variable creation
  • Python Syntax - Why is it necessary?

Data types

Python has some commonly used data types.

  • Numbers
    x = 1.3 //float
    y = 1   // integer
    z = 1 + 2j //complex number
    
  • Words
    x = "Hello World!" //Represented with double quotes
    y = 'I am a dev' //Represented with single quotes
    z = 'Roger\'s dog said "woof"'
    
  • Booleans
    x = True
    y = False
    
    These are easy to understand once you start playing around with them in the python editor.

Operators

There are a different sets of operators provided by a python that can be used to manipulate data and get a result out of it.

Arithmetic operators

Demo on operators As you can see in the above screenshot we have 7 commonly used arithmetic operators that are

+, -, *, /, **, %, and //

These can be used to get the desired result on the numbers.

Comparion operators

Some of the most commonly used comparison operators are

< //Less than
> //Greater than
== //Equal to
<= //Less than or equal to
>= //Greater than or equal to
!= //Not equal to
is //Object identity
is not //Negated object identity

Comparion operators

Boolean operators

Some of the commonly used boolean operators are

or //if value_1 or value_2 are true
and //if both value_2 and value_2 are true
not //if value_1 is not full

Boolean operators

Variable creation

Python is pretty clean when it comes to variable creation. A variable shall start with _ or a letter. You can not have a variable starting with a number of special characters.

  • You can camelCased variable name
  • You can have a variable name starting with _ or a letter

Image description

Python code syntax

Unlike other programming languages, Python strictly follows the syntax. For example, in the screenshot below, you could see that I am trying to assign a letter to a number, and it yells at me.

Image description

Some of the best resources to begin your Python learning are:-

In the next blog post, we will learn about the basic building blocks of Python like Numbers, Text and Dates. Till then goodbye and take care.

Let's learn and grow ourselves. Thanks everyone in advance for reading this article !!

Let us meet soon