We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 9
—_———
Science and Numerical
Methods
Book: A Journey Through Computational Science and Numerical
Methods: An Undergraduate Guide
Prof. John B. Oladosu
Lecture 3: Programming FundamentalsIntroduction
* Programming is the heart of
computational science. It provides the
means to implement algorithms,
simulate scientific phenomena, and
analyze data. In this Lecture, we'll
explore the essential programming
fundamentals necessary for success in
computational science.3.1 Choosing a Programming Language
‘Selecting the right programming language is crucial in computational science. The choice often depends on factors
like application domain, ease of use, performance, and available libraries. Common languages used in computational
science include
41 Python: Knoven for its simplicity and readability, Python is a popular choice, it has a vast ecosystem of libraries for
scientific computing (e.g., NumPy, SciPy) and data analysis (e.g. Pandas).
Download Python -free latest version at:
https www anole com/uri?chentsinternal-element-cse&cx=0126843313801678081 Ode So}-mdt a
softonic com/downloadé.sa=Uaved=7ah UKEW|/kNzblouAxUzlokE HDRTCKWOF noECACOANBLSG=
‘OwVan2yEwivimv@yB4DEIHK36L
The Pthon Tela: hps:/é0cs pthon ory tone nex rd
C/C++: These languages provide high performance but demand more low-level control. They are commonly used in
‘numerical simulations and high-performance computing
os:f/python.en
J. MATLAB: MATLAB is renowned for its numerical computing capabilities and an extensive set of toolboxes. I's widely
used in academia and industry for mathematical modeling and simulation.
is a language specifically designed for statistical analysis and data visualization. i's a preferred choice for
Statisticians and data scientists,
|. Julia: Julia is gaining popularity for its high-performance numerical computing capabilities and ease of use. it's
designed for scientific computing
+The choice of language depends on the specific requirements of your computational tasks and your personal
preferences.3.2 Basics of Coding: Syntax and Semantics
+ Towrite effective code, you must understand the syntax (the rules for constructing
statements) and semantics (the meaning behind the statements) of the programming
language you're using, Here are some common elements:
{i Variables: Variables store data, and their names are case-sensitive. Declare and
initialize variables before using them.
{| Data Types: Different programming languages support various data types, such as
integers, floating-point numbers, strings, and arrays. Understanding data types is crucial
for memory management and type safety.
Operators: Operators allow you to perform operations on data. Common operators
include arithmetic (+, -, *, /), comparison (==, ), and logical (&&, ||).
Control Structures: Control structures, like loops (for, while) and conditionals (if else),
enable you to control the flow of your program.3.3 Variables, Data Types, and Operations
+ 3.3.1 Variables and Data Types
ii Integers: Whole numbers, both positive and negative.
Floating-Point Numbers: Numbers with decimal points,
representing real numbers.
§ Strings: Sequences of characters used for text processing.
i Boolean: Represents true or false values.
ii Arrays: Ordered collections of elements, often of the same data
type.3.3.2 Operations
Xt Arithmetic Operations: Addition (+), subtraction
(-), multiplication (*), division (/), modulus (%),
and exponentiation (**).
Comparison Operations: Equal to (==), not equal
to (!=), greater than (>), less than (=), and less than or equal to (