Python Syntax
Python Concepts
C Syntax
C Concepts
Cybersecurity and Memory
100

What symbol is used in Python to start a block of code, such as after an if or for statement?

:

100

What is the output of this

x = 7

if x > 5:

    print("Hello")

else:

    print("Goodbye")

hello

100

What does int main() signify in a C program?

defines the starting point of your C program and specifies that it will return an integer value to the calling environment, typically the operating system, to indicate the success or failure of its execution.

100

What does the %d format specifier mean in a printf statement?

In a printf statement, the %d format specifier is used to indicate that the corresponding argument should be treated and printed as a signed decimal integer.

100

What is a buffer overflow, in simple terms?

A buffer overflow occurs when a program tries to put more data into a temporary storage area, called a buffer, than it was designed to hold. Imagine you have a glass that can hold 8 ounces of milk. If you try to pour in 12 ounces, the extra 4 ounces will spill out of the glass and onto the counter. In a computer program, this "spilling over" means the extra data overflows into adjacent memory locations, potentially corrupting or overwriting other data stored there

200

What built-in function outputs text to the console in Python?

print()
200

Which function reads user input from the keyboard?

In Python, the input() function is used to read a line of text entered by the user from the keyboard. For example:

200

Which C statement displays text to the standard output?

The C statement used to display text to the standard output, typically the console screen, is the printf() function.

200

What is a pointer in C?

In C programming, a pointer is a variable that stores the memory address of another variable. Instead of holding a direct value, it holds the location in memory where that value is stored

200

What is the purpose of the free() function in C?

The purpose of the free() function in C is to deallocate dynamically allocated memory. When memory is allocated using functions like malloc(), calloc(), or realloc(), it resides in the heap section of a program's memory. This memory does not automatically get released when the pointer goes out of scope or the program finishes executing.

300

How do you write a loop that prints the numbers 1 through 5 in Python?

for i in range(1, 6):
    print(i)


OR 

count = 1
while count <= 5:
    print(count)
    count += 1

300

In Python, what does the lower() string method do?

In Python, the lower() string method converts all uppercase characters in a string to their lowercase equivalents. It returns a new string with the converted characters, leaving the original string unchanged because strings in Python are immutable.

300

What symbol is used to end statements in C?

;

300

What C function reads a string from standard input

In C, several functions can be used to read a string from standard input, each with its own characteristics:

300

Why is input validation important in both Python and C?

Input validation is crucial in both Python and C for several key reasons, encompassing security, data integrity, and program stability.

400

What function in Python is used to get the length of a list?

The function in Python used to get the length of a list is the built-in len() function.

400

What does the following Python code output?

python

for i in range(3):

    print(i)

012

400

In C, what type is used to store an integer value?

int

400

What will printf("%s", "Hello"); print?

The printf("%s", "Hello"); statement will print the string "Hello" to the standard output.




400

What does the argv array store in a C program?

In a C program, the argv array, typically declared as char *argv[] or char **argv in the main function's parameters, stores the command-line arguments passed to the program when it is executed.




500

What keyword is used to define a function in Python?

def

500

What is a dictionary in Python?

In Python, a dictionary is a built-in data type used to store collections of data in key-value pairs. This means each piece of data (the value) is associated with a unique identifier (the key), allowing for efficient retrieval.

500

What keyword is used for defining a block of code in C?

{}

500

What is the difference between float and double in C?

In C, float and double are both data types used to represent floating-point numbers, but they differ primarily in their precision and storage size.

500

What keyword in Python creates a block to handle exceptions?

In Python, the try keyword creates a block of code where exceptions might occur. This try block is then followed by one or more except blocks, which handle specific types of exceptions that may arise within the try block.