What is Programming?
Programming is how you get computers to solve your problems. Simply put, programming is the “language of love” spoken by you to your computer. Computer programs are what make the computer work. Without software, modern computers are just complex devices that turn the electricity to heat. It’s the software on your computer that runs your OS, video games, browsers, music, emails and many more! Programming is a creative task. There is no right or wrong way to approach and solve a problem. There are choices that need to be made in order to improve the efficiency and functionality of the program but that doesn’t mean the alternative won’t work! With the right skills and the motivation to learn, anyone can be a programmer! From writing a small code to substitute a calculator to analysing large databases with millions of records, programming can do it all. The possibilities can only be constrained by our imagination.
Basic Data Types
In this section, we will be introducing basic data types. A data type is an attribute of data, which tells the compiler how the programmer plans on using the data. Most programming languages support basic data types, such as integers, floating-point numbers, characters, booleans and strings.
Integers
In computer science, integers are a datum of integral data type. They are a data type that represents a range of mathematical integers. Integer types store whole numbers, positive or negative, without decimals. These include numbers such as 143, -341 but not 124.56.
The integer data type stores whole numbers that range from -2,147,483,647 to 2,147,483,647, for 9 to 10 digits of precision. The number 2,147,483,648 is a reserved value and cannot be used. Arithmetic operations and sort comparisons are performed more efficiently on integer data types than float or decimal data.
Floating-Point Numbers
Floating-point numbers represent the numbers that contain a fractional part, with one or more decimals.
So how do floating-point numbers work?
The number is split into 2 parts:
A significand that contains the number’s digits (negative significands represent negative numbers). A significand can be thought of as an integer, as a fraction, or as some other fixed-point form by choosing an appropriate exponent offset. [Source: IEEE Computer Society]
An exponent that shows where the decimal or binary point is to be placed relative to the beginning of the significand. Negative exponents represent numbers that are very small and close to zero.
Nearly all hardware and programming languages use floating-point numbers in the same binary formats, which are defined in the IEEE 754-2019 standard. The usual formats are 32 or 64 bits in length.
Characters and Strings
A character is a unit of information that roughly corresponds to a grapheme. Character data types correspond to null-terminated character strings with a specified length. All character syntax is case-sensitive within the ASCII (American Standard Code for Information Interchange) range. Character data types can include letters and symbols and whitespace. Examples of character data types include “?”, “a”, “F” among many. Characters are typically combined into strings.
Computers and communication equipment represent characters using a character encoding that assigns each character to a value. The two most commonly used encoding systems are ASCII and the UTF-8 encoding for Unicode.
A string data type is used to represent text. It consists of a set of characters, that may also contain spaces and numbers. For example, the word “code” and the phrase “I wrote 20 lines of code today” are both strings.
Booleans
The boolean data type is a data type that has one of two possible values (most commonly true and false) which is intended to represent the two values of logic (0s and 1s) and boolean algebra. It was named after George Boole, who first defined an algebraic system of logic in the mid 19th century!
Conditionals
Conditional statements are features of a programming language that perform different computations or actions and are dependent on a programmer-specified boolean condition.
The If-Else statement is used to conditionally execute a statement or a block of statements. The conditions can be true or false, where one thing will be executed when the condition is true, and another thing when the condition is false.
Iteration
Algorithms consist of steps that are carried out (performed) one after another. Sometimes an algorithm needs to repeat certain steps until told to stop or until a particular condition has been met. Iteration is the process of repeating steps. It’s a process where a set of instructions or structures are repeated in a sequence a specified number of times or until a condition is met. When the first set of instructions is executed again, it is called an iteration. When a sequence of instructions is executed in a repeated manner, it is called a loop. Commonly, blocks of code are iterated using the While loop or the For loop.
Functions
A function is a block of organised, reusable code that is used to perform a related, single action. Functions provide better modularity for an application and a high degree of code reusing. Some functions like print() are known as built-in functions, which are provided by the language itself. Functions can also be written by the user. Different programming languages name them differently, for example, functions, methods, subroutines, procedures.
Object-Oriented Programming (OOP)
Object-Oriented Programming (OOP) is a computer programming model that organises software design around data or objects rather than functions and logic. An object is a data field that has unique attributes and behaviour. OOP focuses on the objects that the developers want to manipulate rather than the logic required to manipulate them. This approach to programming is more suitable for large programs that are complex and need to be actively updated.
Комментарии