Concepts of programming - Computers can Repeat Steps

Pybeginner
By -
0

 


Making Decisions


We have discussed two major abilities that computers have. Computers can name values. Computers can repeat steps. The third major ability that a computer has is the ability to make decisions. We make decisions all the time. Before we leave the house we may check to see if it will rain that day, and if it will, we bring an umbrella.

Computers can also make decisions or take action when something is true. More specifically, (1) a computer can test data and (2) a computer can execute instructions if that test is true.

The ability to test data and take actions on the result is what allows the computer to deal with input and take action on it (e.g., if the credit card is valid then charge the card), or deal with data from the world around (e.g., if I see a stop sign then stop.).

The computer’s ability to take action (execute some code) when something is true is also called conditional execution.

 

Working with Collections of Data


Computers can work with more than just single values like 34.2 or single words like Hi. They can also store large collections of numbers and letters and other objects. To manipulate the data, computers really just use the first three abilities that we have discussed: the ability to name things, the ability to repeat instructions, and the ability to make decisions. That means that computers have to be able to get single values out of those collections of data, and put single values back into them.

 

Concepts from computing


Block of Code - A block of code is one or more code statements that are part of a loop, conditional, function, or procedure.

Boolean Expression - A Boolean expression is one that is either true or false. This is also called a logical expression.

Complex Conditionals - A complex conditional has two or more logical expressions joined by the keywords and, or, or not.

Condition - A condition is something that is either true or false. This is also called a Boolean expression or a logical expression.

Conditional Execution - Conditional execution means that one or more statements are executed only when a condition (logical expression) is true. This is also called a conditional. The statements that are executed when the condition is true are called the body of the loop.

Decision - A decision is a choice between at least two choices.

Flowchart - A flowchart is a diagram that shows the execution paths for a program. The conditionals are shown as diamonds.

Logical Expression - A logical expression is one that is either true or false, like x == 3 which will return true if x is equal to 3. This is also called a Boolean expression.

Negation - When you negate a logical expression if the original expression is true the negated expression is false and if the original expression is false the negated expression is true.

Post a Comment

0Comments

Post a Comment (0)