Tuesday, November 29, 2016

Transition from C/C++/Java to Python

I am trying to learn Python myself, as it greatly expedites prototype development compared to C/C++/Java.
Here is quick conversion of C/C++/Java common codes into Python:

for (int i=0; i<N; i++) {
for i in range(N):

if (x==y) {

if x==y:


not True

else if {


printf("%d\n", i)

print i

printf("%d ", i)

print i,

for (int i : array) {

for i in array:

vector<int> v;

v = [1,2]

// C++
vector<int> u,v;
v = u;
import copy
v = copy.copy(u) // OR // v = u[:]

// C++ vector<int> &u, &v;
v = u;
v = u

No comments:

Post a Comment