In C and C++ we first declare the data type of the variable and then declare the name of Variables. A few examples of data types are int, char, float, double, etc.
Python is not “statically typed”. We do not need to declare variables before using them or declare their type. A variable is created the moment we first assign a value to it.
C
#include <stdio.h>
int main()
{
int a;
char a, b, c, d;
float a = 0, b, c;
b = 1;
return 0;
}
|
C++
#include <iostream.h>
int main()
{
int a;
char a, b, c, d;
float a = 0, b, c;
b = 1;
return 0;
}
|
Python
age = 45
salary = 1456.8
name = "John"
|
Comparing Python with C and C++
In the following article, we will compare the 3 most used coding languages from a beginner’s perspective. It will help you to learn basics of all the 3 languages together while saving your time and will also help you to inter shift from one language you know to the other which you don’t. Let’s discuss a brief history of all the 3 languages and then we will move on to the practical learning.