Programming: How Do We Write Codes?
Programming: How Do We Write Codes?
Examples:
1. Python
2. Java
3. JavaScript
4. C
5. C++
Variable
~A variable is a value that can change, depending on conditions or
on information passed to the program.
Data types
Examples:
1. Integer (int)
2. Floating Point (float)
3. character (char)
4. String (str)
5. Boolean (bool)
Integer
~Is a data type used to represent real numbers that do not have
fractional values
Floating Point
~A floating-point or float is a variable type that is used to store
floating-point number values. A floating-point number is one where
the position of the decimal point can "float" rather than being in a fixed
position within a number. Examples of floating-point numbers are 1.23,
87.425, and 9039454.2.
Character
~Sometimes abbreviated as char, a character is a single visual object
used to represent text, numbers, or symbols. For example, the letter
"A" is a single character. With a computer, one character is equal to one
byte, which is 8 bits.
String
~Most programming languages have a data type called a string, which is
used for data values that are made up of ordered sequences of characters,
such as "hello world". A string can contain any sequence of characters,
visible or invisible, and characters may be repeated. The number of
characters in the string is called its length, and "hello world" has length
11 - made up of 10 letters and 1 space. There is usually a restriction on
the maximum length of a string. There is also such a thing as an empty
string, which contains no characters - length 0.
Boolean
~In the world of computer programming, one only takes one kind of test:
a boolean test — true or false. A boolean expression(named for
mathematician George Boole) is an expression that evaluates to either
true or false.
Functions
~Functions (also called 'procedures' in some programming languages
and 'methods' in most object oriented programming languages) are a set
of instructions bundled together to achieve a specific outcome.
Functions are a good alternative to having repeating blocks of code in a
program.
Every programming language lets you create blocks of code that, when
called, perform tasks. Imagine a dog that does the same trick only when
asked. Except you do not need dog treats to make your code perform. In
programming, these code blocks are called functions.
All programming functions have input and output. The function contains
instructions used to create the output from its input. It’s like a cow that
eats grass (the input) which its body turns into milk which a dairy farmer
then milks (the output).