Computer Knowledge
Programming Fundamentals
2,611 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
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.
-
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.