wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

C++ vs Python: A Quiz Introduction

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

What is the file extension for a C++ source file?

a)

.py

b)

.cpp

c)

.java

d)

.html

2.

Which of the following is a valid way to declare an integer variable in C++?

a)

int x;

b)

integer x;

c)

var x;

d)

x: int

3.

In C++, which of the following is used to output text to the console?

a)

print()

b)

cout

c)

echo

d)

Console.WriteLine()

4.

Compare the way a list is defined in Python with an array in C++. Which of the following correctly defines an array of integers with 5 elements in C++?

a)

int arr[5];

b)

array arr;

c)

int arr = [5];

d)

int arr(5);

5.

Which of the following is a correct way to start a for loop in C++?

a)

for (int i = 0; i < 10; i++)

b)

for i in range(10):

c)

foreach (int i in 10)

d)

for (i = 0; i < 10; i++)

6.

Identify the correct syntax to include a standard library in C++.

a)

#include

b)

import iostream

c)

using namespace iostream

d)

include iostream

7.

How does C++ handle memory management compared to Python?

a)

C++ uses automatic garbage collection.

b)

C++ requires manual memory management using pointers.

c)

C++ does not allow dynamic memory allocation.

d)

C++ uses reference counting like Python.

8.

Which of the following is a correct way to define a function in C++ that returns an integer?

a)

int functionName() { return 0; }

b)

def functionName(): return 0

c)

function int functionName() { return 0; }

d)

int functionName: return 0

9.

What is the equivalent of Python's `None` in C++ when dealing with pointers?

a)

null

b)

nullptr

c)

void

d)

0

10.

Which of the following statements correctly contrasts the use of indentation in Python and C++?

a)

Both Python and C++ use indentation to define code blocks.

b)

Python uses indentation for code blocks, while C++ uses braces `{}`.

c)

C++ uses indentation for code blocks, while Python uses braces `{}`.

d)

Neither Python nor C++ uses indentation for code blocks.