NEW
Font size
WorksheetsC++ vs Python: A Quiz Introduction
Total questions: 10
Worksheet time: 5mins
What is the file extension for a C++ source file?
.py
.cpp
.java
.html
Which of the following is a valid way to declare an integer variable in C++?
int x;
integer x;
var x;
x: int
In C++, which of the following is used to output text to the console?
print()
cout
echo
Console.WriteLine()
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++?
int arr[5];
array
int arr = [5];
int arr(5);
Which of the following is a correct way to start a for loop in C++?
for (int i = 0; i < 10; i++)
for i in range(10):
foreach (int i in 10)
for (i = 0; i < 10; i++)
Identify the correct syntax to include a standard library in C++.
#include
import iostream
using namespace iostream
include iostream
How does C++ handle memory management compared to Python?
C++ uses automatic garbage collection.
C++ requires manual memory management using pointers.
C++ does not allow dynamic memory allocation.
C++ uses reference counting like Python.
Which of the following is a correct way to define a function in C++ that returns an integer?
int functionName() { return 0; }
def functionName(): return 0
function int functionName() { return 0; }
int functionName: return 0
What is the equivalent of Python's `None` in C++ when dealing with pointers?
null
nullptr
void
0
Which of the following statements correctly contrasts the use of indentation in Python and C++?
Both Python and C++ use indentation to define code blocks.
Python uses indentation for code blocks, while C++ uses braces `{}`.
C++ uses indentation for code blocks, while Python uses braces `{}`.
Neither Python nor C++ uses indentation for code blocks.
