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
-
using a while loop
-
repetition
-
using a for loop
-
start again
D
Correct answer
Explanation
Iteration refers to the process of repeating a block of code. 'Start again' is not a formal definition of iteration in programming.
-
print("hello)
-
for i range(10):
-
for line in file
-
def myFunction():
D
Correct answer
Explanation
Option D is a valid function definition. Option A is missing a closing quote, B is missing the 'in' keyword, and C is missing a colon.
D
Correct answer
Explanation
The 'def' keyword is used to define a function in Python.
-
Selection
-
Iteration
-
Sequence
-
Variables
B
Correct answer
Explanation
A for loop is a fundamental programming structure used to repeat a block of code multiple times, which is the definition of iteration. Selection refers to conditional logic (if statements), and sequence refers to the order of execution.
-
print()
-
float()
-
num1 = 9
-
int()
C
Correct answer
Explanation
A variable is a named storage location for data. In 'num1 = 9', 'num1' is the variable name being assigned the value 9. The other options are function calls or type conversion functions.
A
Correct answer
Explanation
Float is a fundamental data type in Python and many other languages used to store numbers that have fractional parts.
B
Correct answer
Explanation
The print() function is a built-in command in Python used for outputting information, so the statement that it is NOT a command is false.
-
Let's the turtle out of its den.
-
Makes everything work.
-
Allows us to use turtle functions like fd() and pu().
-
Imports the turtle from overseas.
C
Correct answer
Explanation
The statement 'from turtle import *' imports all functions from the turtle module into the current namespace, allowing the programmer to use commands like fd() directly.
A
Correct answer
Explanation
The 'for' keyword is a standard way to implement a definite loop in Python and many other programming languages.
-
Char
-
Integer
-
Boolean
-
String
C
Correct answer
Explanation
The value True is a logical value, which is represented by the Boolean data type in programming.
-
Function doesn't return a value, procedure returns a value
-
Both return a value both are sub programs
-
Procedure doesn't return a value, function returns a value
-
Procedure allows the use of recursion
C
Correct answer
Explanation
In procedural programming, a function is designed to return a value to the caller, while a procedure performs a task without returning a value.
-
Allows the code to be reusable
-
There is less chance of errors
-
Less copying and pasting of similar code
-
A lot more programming code
D
Correct answer
Explanation
Subprograms are used to reduce code complexity and improve maintainability; they do not increase the amount of code required, but rather help organize it.
-
Programming code following a logical order
-
Programming code that repeats
-
Programming code performs an action based on a condition
-
Programming code that assigns a value to a variable
A
Correct answer
Explanation
Sequencing is the basic construct where instructions are executed one after another in the order they appear.
-
Check a condition
-
Assign a variable
-
Repeat a statement based on a condition
-
Assign a variable several times
C
Correct answer
Explanation
Iteration, or looping, allows a block of code to be executed repeatedly as long as a specific condition is met.
-
For
-
While
-
If
-
Repeat Until
C
Correct answer
Explanation
If is a selection construct used for conditional branching, not an iteration construct.