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

Multiple choice
  1. using a while loop

  2. repetition

  3. using a for loop

  4. start again

Reveal answer Fill a bubble to check yourself
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.

Multiple choice
  1. print("hello)

  2. for i range(10):

  3. for line in file

  4. def myFunction():

Reveal answer Fill a bubble to check yourself
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.

Multiple choice
  1. Selection

  2. Iteration

  3. Sequence

  4. Variables

Reveal answer Fill a bubble to check yourself
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.

Multiple choice
  1. print()

  2. float()

  3. num1 = 9

  4. int()

Reveal answer Fill a bubble to check yourself
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.

Multiple choice
  1. True

  2. False

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

Float is a fundamental data type in Python and many other languages used to store numbers that have fractional parts.

Multiple choice
  1. True

  2. False

Reveal answer Fill a bubble to check yourself
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.

Multiple choice
  1. Let's the turtle out of its den.

  2. Makes everything work.

  3. Allows us to use turtle functions like fd() and pu().

  4. Imports the turtle from overseas.

Reveal answer Fill a bubble to check yourself
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.

Multiple choice
  1. Function doesn't return a value, procedure returns a value

  2. Both return a value both are sub programs

  3. Procedure doesn't return a value, function returns a value

  4. Procedure allows the use of recursion

Reveal answer Fill a bubble to check yourself
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.

Multiple choice
  1. Allows the code to be reusable

  2. There is less chance of errors

  3. Less copying and pasting of similar code

  4. A lot more programming code

Reveal answer Fill a bubble to check yourself
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.

Multiple choice
  1. Programming code following a logical order

  2. Programming code that repeats

  3. Programming code performs an action based on a condition

  4. Programming code that assigns a value to a variable

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

Sequencing is the basic construct where instructions are executed one after another in the order they appear.

Multiple choice
  1. Check a condition

  2. Assign a variable

  3. Repeat a statement based on a condition

  4. Assign a variable several times

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

Iteration, or looping, allows a block of code to be executed repeatedly as long as a specific condition is met.