Friday, April 4, 2025

Comparison of Main Operators: C++ vs. Python

Category

Operator

C++

Python

Assignment

Assignment

=

=

Arithmetic

Addition

+

+


Subtraction

-

-


Multiplication

*

*


Division

/

/


Integer Division

/ (but returns float)

//


Modulo

%

%


Exponentiation

pow(x, y) or <cmath>

**

Relational

Equal to

==

==


Not equal to

!=

!=


Greater than

>

>


Less than

<

<


Greater or equal

>=

>=


Less or equal

<=

<=

Logical

AND

&&

and


OR

`



NOT

!

not

Bitwise

AND

&

&


OR

`

`


XOR

^

^


NOT

~

~


Shift Left

<<

<<


Shift Right

>>

>>

Membership

In

N/A

in


Not in

N/A

not in

Identity

Is / Is not

N/A

is, is not

Ternary

Conditional expression

cond ? a : b

a if cond else b

Increment/Decrement

++ / --

++x, x++, --x, x--

Not supported (use x += 1)

No comments:

Post a Comment

Basic Comparison of C++ and HTML/JavaScript

 Here’s a basic comparison of C++ and HTML/JavaScript for common programming concepts and  simple code examples for each. This will help ...