Computer Knowledge
Programming Fundamentals
2,381 Questions
Programming fundamentals form the core logic of software development and computer science. This includes variable declarations, pointer assignments, loop iterations, and exception handling. These technical topics are regularly tested in computer knowledge and IT officer competitive examinations.
Variables and arraysPointer assignmentsLoop iterationsException handling blocksCompile time errorsFunction references
Programming Fundamentals Questions
-
Sequence
-
Selection
-
Iteration
-
Object
D
Correct answer
Explanation
Procedural programming is built on sequence, selection, and iteration. Objects are the core of Object-Oriented Programming, not procedural programming.
-
Variable
-
Constant
-
Array
-
Definition
C
Correct answer
Explanation
An array is a data structure that can store multiple values under a single name. Variables and constants typically hold a single value at a time.
-
Constant
-
String
-
Character
-
Boolean
A
Correct answer
Explanation
A constant is a value that does not change during program execution, not a data type. String, Character, and Boolean are standard data types used to categorize data.
-
name == input
-
name = input("Enter your name: ")
-
name == input("Enter your name: ")
-
name = int(input("Enter your name: "))
B
Correct answer
Explanation
In Python, the input function is used to capture user input, and the assignment operator (=) stores that value into a variable. Option B correctly uses the function with a prompt string.
-
A memory location.
-
A memory store that you cannot change.
-
A value.
-
A memory store that you can change.
B
Correct answer
Explanation
A constant is a named memory location whose value is fixed and cannot be altered once the program is running. Variables, by contrast, are designed to have their values changed.
-
print "Computer Science"
-
output(Computer Science)
-
print("Computer Science")
-
print(Computer Science)
C
Correct answer
Explanation
In Python 3, print is a function, so it requires parentheses to enclose the arguments. Option C correctly uses parentheses and quotes for the string.
-
A memory location.
-
A memory store that you cannot change.
-
A value.
-
A memory store that you can change.
D
Correct answer
Explanation
A variable is a named memory location used to store data that can be modified or updated during the program's execution. This distinguishes it from a constant.
-
To explain the code
-
To ask the coder how he/she is doing
-
To make the code work
-
To avoid a syntax error
A
Correct answer
Explanation
Comments are non-executable lines in code used by programmers to document and explain what the code does for human readers. They do not affect program execution.
-
Not consistent or having a fixed pattern; liable to change
-
Somewhere to store functions
-
Names used to store one or morevalues e.g. a users ages
-
A symbol that represents a quantity
C
Correct answer
Explanation
Variables are named containers for storing values that can be changed. Option C correctly describes variables as named storage for values like age.
-
Selections
-
Debuggers
-
Functions
-
Procedures
C
Correct answer
Explanation
Functions are pre-defined blocks of code that perform specific tasks, such as printing to the console or accepting user input. These are invoked by their names.
B
Correct answer
Explanation
A logic error occurs when the code runs without crashing but produces incorrect results because the underlying algorithm or logic is flawed.
A
Correct answer
Explanation
A syntax error occurs when the code violates the rules of the programming language, such as missing parentheses or incorrect keywords, preventing the program from running.
-
Debugger
-
Algorithm
-
Psuedocode
-
Script
C
Correct answer
Explanation
Pseudocode is a planning tool that mixes English-like descriptions with code-like structure. It helps design algorithms before coding.
-
Loops
-
Selection
-
Iteration
-
Procudure
B
Correct answer
Explanation
Selection statements (also known as conditional statements) allow a program to choose different paths of execution based on whether a condition is true or false.
B
Correct answer
Explanation
The 'while' statement is a control structure used for iteration, meaning it repeats a block of code as long as a specified condition remains true.