Syntax Basics
Control Flow
Functions
Strings & Input/Output
Lists/Array
100

Declare an int variable named x and set it to 10

Py: x = 10/ Java: int x = 10;

C: int x = 10;/ C++: int x = 10;

100

The keyword for “if”

just "if"

100

Keyword to define a function

Py: def/ Java: (public/private + type + name)

C/C++: Type+name


100

output “Hello” to screen

Py: print("Hello")/ C: printf("Hello");

C++: cout << "Hello";/ Java:  System.out.print("Hello");

100

Create an empty list/array

Py: []/ C: does not exist

C++: vector v;/ Java: new ArrayList<>()

200

Declare a string variable named name with your name

Py: name = "Ali"/ C: char name[]="Ali"

C++: string name = "Ali";/ Java: String name = "Ali";

200

The “else-if” keyword

Py: elif/ C: else if

C++: else if/ Java: else if

200

How to call a function (let's say it's named go())

Py: go()/ C/C++/Java: go();

200

output a number (ex:42)

Py:print(42)/C: printf("%d",42);

C++:cout << 42;/Java:System.out.println(42);

200

Add a value to the end of the list(ex:7)

Py:mylist.append(7)/C:(MANUAL or realloc())

C++:v.push_back(7)/Java:list.add(7)

300

The literal/value that means boolean true

Py:True/C:1

C++:true/Java: true

300

Logical AND operator

Py:and

C++/C/Java:&&

300

Keyword to return a value

Py/C/C++/Java: return

300

Get the length of a string called s

Py:len(s)/C:strlen(s)

C++/s.length() or s.size()/ Java: s.length()

300

Get the item at position/index 3

Py:3mylist[3]/ C:arr[3]

C++:v[3]/ Java:list.get(3)

500

Declare a constant named MAX with value 100

Py:MAX = 100/ C: const int MAX = 100;

C++: constexpr(or const) int MAX = 100;/ Java: final int MAX = 100;

500

Single-line comment syntax

Py:#/ 

C/C++/Java: //

500

Function header that takes two ints and returns an int

Py: def add(a: int, b: int) → int

C/C++/Java: int add(int a, int b)

500

Read one full line from the user

Py:input()/ C: fgets / gets

C++: std::getline(cin, str)/ Java: new Scanner(System.in).nextLine()

500

Loop through every item in the list and print it

Py: for item in list: print(item)/C:for(int i=0;i<n;i++)printf("%d\n", arr[i]);

C++: for(int i=0;i<n;i++)cout<<arr[i];/ Java: for(Integer x : list) println(x)

1000

The exact name of the error when you use a variable you never created

Py:NameError/C:(warning or garbage)

C++:(compile error)/Java: compile error – must declare

1000

The keyword for the block that runs only when nothing above matched

All: else

1000

The special function name that runs automatically when you create an object

Py: init. Others: same name as class

1000

The exact name of the error when you try to access index 50 on a 5-item list

Py:IndexError/ C:undefined/segfault

C++:undefined/segfault

Java:IndexOutOfBoundsException

1000

What is the exact name of the error you get when you try to access an index that is too large?

Python:“IndexError” (or “IndexError: list index out of range”)

C:“segmentation fault” or “segfault”

C++:“segmentation fault” or “segfault” (or “out of range” if using .at())

Java:“ArrayIndexOutOfBoundsException” (or “IndexOutOfBoundsException” for lists)