0% found this document useful (0 votes)
38 views

Programming: How Do We Write Codes?

Programming involves creating instructions to tell a computer how to perform tasks. This is done through programming languages and integrated development environments that allow writing and debugging code, which is then converted to machine code the computer can understand. Programs use variables to store changing values, and data types like integers, floats, characters, strings, and booleans to classify data and tell the compiler how it will be used. Functions are blocks of reusable code that take input, perform tasks, and return output.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views

Programming: How Do We Write Codes?

Programming involves creating instructions to tell a computer how to perform tasks. This is done through programming languages and integrated development environments that allow writing and debugging code, which is then converted to machine code the computer can understand. Programs use variables to store changing values, and data types like integers, floats, characters, strings, and booleans to classify data and tell the compiler how it will be used. Functions are blocks of reusable code that take input, perform tasks, and return output.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Programming

~Programming is the process of creating a set of instructions that tell


a computer how to perform a task.
~Attempting to get a computer to complete a specific task without
making mistakes.

Examples:
1. Python
2. Java
3. JavaScript
4. C
5. C++

How do we write codes?


~Can’t simply type words into a text document and expect that the
computer is able to carry out a task.

~To properly send instructions to the computer we need programming


languages. (But we also can’t type in a certain language and expect the
same thing.)

~ We use IDE’s (Integrated Development Environments) to write a


code. (A place to write, run, and debug code and also convert it to
machine code.)

Variable
~A variable is a value that can change, depending on conditions or
on information passed to the program.

Data types

~A data type is a classification of data which tells the compiler or


interpreter how the programmer intends to use the data.

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).

For example, programming functions might take as input any integer or


number. The function might create output by multiplying the input times
two. Therefore, the output of the function would be double its input.

You might also like