Posts

Showing posts from January, 2025

Mutable and immutable objects in programming

Mutable means that the object can change. For example if a speed of a car is 55, than it is possible to change it to 65. Mutable objects are variables. Variables take space in a computer memory. Immutable objects are constants. For example it possible to define a constant that represents maximum speed. Constants don't take space in a computer memory, at compile time a constant is replaced with an associated value. There are three reasons why constants are used: 1. Improved readability. It makes more sense to use a constant which name is maximum_speed rather then 65. A person who writes code needs to come up with meaningful names for variables and constants and not just a, b, c. 2. Value of a constant can be easily changed at a later time. For example if the height of the highest building is 100, but a new one was built that is higher than the previous one, than it is possible to update the constant with a new value just once, rather then update multiple times, if a constant is not ...

Abstraction

Abstraction is to define what are the inputs and outputs of the code and expected process of achieving the result. However, when abstraction is given, there are no implementation details. Implementation is up to a person who develops or implements it. Non-technical people do not need to know implementation level details. YouTube video Quiz: Short Answer Questions Instructions: Answer each question in 2-3 concise sentences. What is the primary focus of abstraction in coding? How does abstraction differ from implementation? Explain why abstraction is beneficial for collaboration in software development. Can you provide an example of abstraction in everyday life? What is the role of the developer in relation to implementation? How does understanding abstraction help in debugging code? What are potential drawbacks of overly abstract code? Why is clear documentation crucial when working with abstract concepts in coding? How can abstraction impact the efficiency of a program? Describe the re...

Decomposition

Decomposition is a process of breaking larger piece of code onto smaller sections. Why is it necessary to do? Decomposition allows code to be better understandable. If there is an issue somewhere it is easier to find it and to fix it, than in a larger piece of code. Decomposition is a fundamental concept in computer science, software development, and problem-solving that involves breaking down a complex problem or system into smaller, more manageable parts. This approach simplifies solving complex tasks by tackling smaller, individual components that can be understood, developed, and tested separately. The key idea is to divide and conquer, making it easier to analyze, develop, and maintain complex systems or problems. YouTube video link Short Answer Quiz Instructions: Answer the following questions in 2-3 sentences each. What is decomposition in the context of coding? What is the primary benefit of decomposing code? How does decomposition improve code debugging? Imagine you are buildi...

Bisection search algorithm

It is possible to achieve same result by different methods. For example it is possible to use brute force algorithm to find a solution. But brute force algorithm is not efficient. A better algorithm would be "bisection" search algorithm. In bisection search algorithm, a result is found by continually dividing potential result and previous result interval in half until the solution is found. YouTube video Bisection Search Algorithm Study Guide Quiz: What is the main advantage of the bisection search algorithm over a brute force algorithm? Describe the basic principle behind the bisection search algorithm. What condition must be met for the bisection search algorithm to be applicable? How is the search space adjusted in the bisection search algorithm after each iteration? What is the stopping condition for the bisection search algorithm? Explain the concept of "divide and conquer" in relation to the bisection search algorithm. What is the time complexity of the bisect...

Binary numbers

Binary numbers are represented with only two digits. These are 0 and 1. 0 represents absence of signal and 1 represent that signal is available, We accustom to have base 10, because we have 10 fingers, in US there is count to twelve - dozen, honestly I don't know where dozen came from, it makes more sense to use count from 1 to 10. Computers use transistors, if you like details of what transistor is, then look it up that information. Absence of voltage represents 0, and presence of it represents 1. YouTube video link Binary Numbers and Computer Basics Study Guide Quiz Instructions: Answer the following questions in 2-3 sentences each. What are the two digits used in binary representation and what do they symbolize? Why is the decimal system (base 10) commonly used by humans? How does the presence or absence of voltage relate to binary representation? What is the primary electronic component used in computers to process binary data? Briefly explain why binary is suitable for compute...

Math errors in calculation in programming

It is necessary to note that in programming math calculations may have errors. For example multiplying 0.1 by 10 must result in 1, however in programming by multiplying 0.1 by 10 may give us an answer 0.99999999 The errors happen because a computer needs to convert this number from base 10 to base 2 (zeros and ones). YouTube video Study Guide Quiz Why might mathematical calculations in programming produce unexpected results? Explain the concept of base 10 and base 2 number systems. What is a floating-point number, and how is it represented in a computer? Describe the issue that can arise when representing 0.1 in binary. Why does multiplying 0.1 by 10 sometimes result in 0.99999999 in programming? What are the potential implications of floating-point errors in software applications? Provide an example of a scenario where floating-point errors could be problematic. What strategies can programmers employ to mitigate the risks of floating-point errors? How can you test your code to ensure ...

Boolean logic

Boolean logic can be expressed by the following statements: ==, !=, >, <, >=, <= (the last two are greater than or equal and less then or equal) != means not equal. Boolean logic has a few commonly used operators if needed to find a result of more than one Boolean operation. AND OR It is possible to negate the result of Boolean operation, by using keyword NOT . YouTube video Boolean Logic Study Guide Quiz Instructions: Answer the following questions in 2-3 sentences each. What is the purpose of Boolean logic? List the comparison operators used in Boolean logic. Explain the difference between the operators "==" and "!=". Describe the function of the "AND" operator in Boolean logic. Provide an example. How does the "OR" operator work in Boolean logic? Give an example. What is the role of the "NOT" operator? Illustrate with an example. Can you combine multiple Boolean operators in a single expression? If so, how? What is the ex...

Boolean variables

Boolean variables have have two values either True or False . Please imagine a switch it has either ON or OFF position. Similar to a switch Boolean variables have only two values. YouTube link Short Answer Quiz Instructions: Answer the following questions in 2-3 sentences each. What are the two possible values of a Boolean variable? How does the analogy of a switch relate to the concept of Boolean variables? What is the significance of Boolean logic in computer programming? Give an example of a situation where a Boolean variable might be used in everyday life. What are some common Boolean operators used in programming? Explain the difference between the Boolean operators AND and OR. What is the result of the Boolean expression True AND False? What is the result of the Boolean expression True OR False? How can Boolean logic be used to control the flow of a program? Provide an example of how Boolean logic is used in search engines. Answer Key The two possible values of a Boolean variable...

Exiting from a loop before it finishes

In Python it is possible to exit a loop before the loop exit condition is met. In order to do so, it is possible to use break statement. If it is used, then the program will exit the loop and continue further execution. It useful to use break, the loop if the final result, which was done in a loop was already found and no further iteration is needed. Exiting a loop prematurely will make code more optimal an execution of the program that relies on this logic more quicker. YouTube link Study guide Quiz Instructions: Answer the following questions in 2-3 sentences each. What is the purpose of the break statement in Python loops? In what scenario might you use a break statement within a for loop? How does the break statement affect the execution flow of a program? Can you use a break statement outside of a loop? Explain your answer. What happens to any code within the loop that comes after the break statement? Differentiate between the break statement and the loop's exit condition. Pro...

Loops in programming

In programming same logic can be repeated. If logic is the same for all of the iterations, than it is possible to place this code inside of a loop. There are several types of loop, naming of these will depend on the programming language. The easiest loop to understand is a  for  loop. for loop has three sections. 1. Initialization. 2. Exit condition. 3. How to change the value of a loop variable. This is optional. Default setting is 1. There are two more cases of loops: while loop, and repeat until loop. The difference between these two loops is that the value of a variable is checked before entering a loop (while loop case) and value of a variable is checked at the end (repeat until) loop case. In a  for loop, loop variable is changed with each iteration, however it is necessary to adjust the variable manually with while loop and repeat until loop. An option exists with while and repeat until loops of having an infinite loop in a case when the exit condition is never...

Branching in code

Branching in code is done with if statement. If the condition in the if statement is TRUE , then the code in the if statement will be executed, if not it will not be executed.  If it is necessary to check more than one condition by adding else if condition in python it is elif statement (it is Python syntax, in other languages it may be different, the idea is to add optional condition to if statement). The fall back is else statement. It will be executed, if all the statements returned FALSE. The only statement that is required is IF statement, all other statements are optional. In PHP it is possible to use SWITCH statement to specify multiple cases. Whichever case is TRUE, than code within that case will be executed. Switch statement simplifies IF statement and makes code more understandable. YouTube link Python Conditional Statements Study Guide Quiz Instructions: Answer the following questions in 2-3 sentences each. What is the purpose of an if statement in Python? How does a...

Patching computer issues

Patching an issue is to resolve a computer issue. Patch can be a temporary one or a permanent one. A temporary patch will fix an immediate issue, but a permanent one will prevent this issue from happening again. A time that is needed to create a temporary patch is usually less then creating a permanent fix. Why am I saying that creating a temporary fix USUALLY takes less time. There are two reasons for it: 1. Temporary patching may not always be an option, a permanent fix may need to developed and put in place. 2. Temporary fix does not go through the same level of scrutiny as a permanent fix. Knowledge required to create a temporary fix is usually less then creating a permanent solution for a problem. YouTube link Software Patching: Temporary vs. Permanent Solutions Short Answer Quiz Instructions: Answer the following questions in 2-3 sentences. What is the primary purpose of patching in software development? Differentiate between a temporary patch and a permanent patch. Why might a t...