Introduction

C++ or Cpp is a programming language derived from c that is also considered as a middle-level programming language, due to the capability of handling hardware level and its human like readability. This makes it heavily powerful and risky if it is miss set.

Variables and Types

The Python ease comes from the fact that it’s object-oriented, meaning you don’t need to declare the variables before using them because they are objects already.

Let’s explore how it works and have some fun with it. The first step is to understand the variables and types.

Numbers :

it can support two types of numeric variables’ integer (whole numbers) and floating point (decimals) and also complex numbers. The syntax for those is ease to show.

Integers

Integers are represented by the function int().

1
2
3
a = int(1)
b = int(2.5)
print(a,b)
output:
1
1 2

Floats

Float are represented by the function float()

1
2
3
a = float(1)
b = float(2.5)
print(a,b)
output:
1
1.0 2.5

Complex

For the complex numbers, the function complex() accepts two parameters, the first is for the real part and the second one is for the imaginary part.

1
2
3
a = complex(1)
b = complex(2,5)
print(a,b)
output:
1
1+0j 2+5j

As shown another way to define variables is the easiest one, just write them down as it, they will be interpreted as their type.

1
2
3
4
a = 1
b = 2.5
c = 3+5j
print(a, b, c)
output:
1
1, 2.5 3+5j

Strings

Other programming languages treats the letters and words differently, as single letter (characters/char) and words (strings). In Python, they are treated similarly as strings, which is the function for it string() another technic to use is to enclose them between quotation marks single (’ ‘) and doubles(" “). The difference between the two is that using double quotes makes easy to include apostrophes.

1
2
3
a = string(my code here)
b = "also this can be my code"
print(a, b)
output:
1
my code here also this can be my code

We had mentioned variable definition. What does that mean in simple English? It is quite different at the math variable we all know, first Python is capital sensitive, which means that this and This are different strings, second variables must be equal to something or none, otherwise x= will produce an error, best practices is to set it to none x= None.

1
2
x = None
print(x)
output:
1
None

Data structures

Depending on the situation, Python provides structures that allow you to access data more efficiently. For programs, accessing data is like searching for a book in a library shell, where you have to look through all the books to find the one you want, but instead of book shells is the memory allocation.

Python provides by default some data structures, they can be classified in mutable and nonmutable.