Programming Lessons
Programming Lessons
Lesson #1
FLOWCHART SYMBOLS
Terminator
Process
Decision
Document
Stored Data
Flow arrow
Comment or Annotation
On-page connector
Off-page connector
Errors in programming
Lesson #5
Errors in programming refer to issues or defects that arise within the program,
resulting in abnormal behavior. Even experienced developers can make these
mistakes, which are also referred to as bugs or faults. The process of eliminating
these errors is called debugging. These errors in Programming can be identified
during the program’s compilation or execution, and it’s crucial to remove them to
ensure the program runs smoothly. Here we will discuss the various types of errors
in programming and some of the common causes behind them. So, let’s dive straight
into the topic of Types of Errors in Programming.
Syntax Error
A syntax error is the most common type of error in programming. It occurs when the
programmer writes code that is not in accordance with the syntax of the
programming language. Syntax errors are detected by the compiler, and the compiler
reports an error message to the programmer.
Common examples of syntax errors include,
Forgetting to add a semicolon,
Spelling a keyword incorrectly
Missing a closing brace.
Example of Syntax Error
Here is an example code having a syntax error.
Run-time Error
A run-time error occurs during the execution of a program. These errors occur when
a program tries to perform an illegal operation, such as dividing by zero or
attempting to access an invalid memory address. The program compiles without
errors, but when it runs, it encounters an error that causes it to terminate abnormally.
Run-time errors are often difficult to detect because they do not show up until the
program is executed.
Example of Run-Time Error
Let us see a C++ code that throws a runtime error.
Linker Error
A linker error occurs when a program references a function or variable that is not
defined in the program or the libraries it is linked against. Linker errors typically
occur when a program is compiled and linked. The linker will report an error if it
cannot find the necessary files or libraries to link the program.
Example of Linker Error
Here is the code that will show the linker error.
Logical Error
A logical error occurs when the program compiles and runs without any syntax, run-
time, or linker errors, but the output is incorrect. These errors occur when the
program's logic or algorithms are incorrect. Logical errors are challenging to detect
because the program does not generate any error messages.
Example of Logical Error
Let us understand this error with the help of an example.
Semantic Error
Semantic errors are errors that occur when the code written by the programmer
makes no sense to the compiler, even though it is syntactically correct. They are
different from syntax errors, which indicate errors in the structure of the program, as
semantic errors are related to the meaning and implementation of the program.
For example,
Using a string instead of an integer or accessing an array index that is out of
bounds can cause semantic errors.
Uninitialized variables and type incompatibility are other common types of
semantic errors.
Example of Semantic Error
Here is the code for a better understanding of Semantic Errors in Programming.
Introduction to python
Lesson #6
What is Python?
Python is a popular programming language. It was created by Guido van Rossum,
and released in 1991.
It is used for:
web development (server-side),
software development,
mathematics,
system scripting.
What can Python do?
Python can be used on a server to create web applications.
Python can be used alongside software to create workflows.
Python can connect to database systems. It can also read and modify files.
Python can be used to handle big data and perform complex mathematics.
Python can be used for rapid prototyping, or for production-ready software
development.
Why Python?
Python works on different platforms (Windows, Mac, Linux, etc.).
Python has a simple syntax similar to the English language.
Python has syntax that allows developers to write programs with fewer
lines than some other programming languages.
Python runs on an interpreter system, meaning that code can be executed as
soon as it is written. This means that prototyping can be very quick.
Python Syntax compared to other programming languages
Python was designed for readability, and has some similarities to the
English language with influence from mathematics.
Python uses new lines to complete a command, as opposed to other
programming languages which often use semicolons or parentheses.
Python relies on indentation, using whitespace, to define scope; such as the
scope of loops, functions and classes. Other programming languages often
use curly-brackets for this purpose.
Python syntax
Lesson #7