Python vs C++

Python vs C++

Difference between Python and C++

Python and C++ programming languages are two most used programming languages used by programmers in competitive programing. C++ was released in 1985 by Bjarne Stroustrup as an extension to c programing language. Lets us have a look at the difference between python and C++ programing language. “Python vs C++”

Difference between Python and C++

AttributesPython ProgramingC++ Programing
AboutPython is the general-purpose interpreted programing language It is interactive, object-oriented and high level programing languageC++ is a general-purpose programing language. It is an extension of C and C++ is also considered as C with class
EfficiencyAs python is interpreted language hence it is slower than compiled languagesC++ is faster than python as it is Compiled language
SyntaxPython syntaxes are simpler and easier to rememberC++ Syntaxes are harder as compared with python programming
Variable declarationNo need to declare the type of the variable while initializing it will automatically be declared on program executionWe need to declare the type of the variable while we initialize a variable in C++ programing
Library functionsPython programming have a wast library of functions as compared to any programing languageWhen compared with python, the library of C++ language is not much wast
NaturePython is dynamically typedC++ is statically typed
ApplicationsWeb development, Machine learning, Artificial Intelligence, etcOperating System, Games, GUI, Banking applications,  etc

Python programming language

Python programing language was introduced by Guido van Rossum in 1989 and the first version 0.9.0 of the language was introduced in 1991. Till then we have total 25 updates for python and now 3.8 is the most stable version used by the developers in the programming field. Python programing has now become more popular due to its rich library support and easy syntax. Python is used in many areas of development, Web development, Machine learning, Artificial Intelligence are some most popular areas of work. Some more application where python is used are:

  • Data Science
  • GUI
  • Game Development
  • Web Scraping
  • 3-D Graphics

etc.

C++ programming language

C++ programing language was introduced in 1985 by Bjarne Stroustrup as an extension to C programing language. C++ has a major update after C, it was an object-oriented language and was more efficient than C programing language. It gave programmers a high level of control over system resources and memory. C++ programing language got major updates 3 times in 2011, 2014, 2017 with C++11, C++14, and C++17. C++17 is the updated and the stable version of the language available for the programmers to use. Some applications of C++ programing language are:

  • Graphics designing
  • Distributed System
  • Data-Base
  • Telephone-Switches
  • Compilers

etc

Code in C++ programming language for checking divisibility by 3

 

#include<bits/stdc++.h>
using namespace std;
int check(string number) 
{ 
    int num = number.length(); 
    int Sum = 0; 
    for (int i=0; i<num; i++) 
        Sum += (number[i]-'0'); 
    return (Sum % 3 == 0); 
} 
int main() 
{ 
    string number = "1331"; 
    check(number)?  cout << "Yes" : cout << "No"; 
    return 0; 
}

Code in Python programming language for checking divisibility by 3

number = int(input('Enter the Number :'))
if number % 3 == 0:
    print('Yes')
else:
    print('No')