Programming Concepts: Constants, Constructs, and Operators

Classified in Computers

Written at on English with a size of 1.72 KB.

Programming Fundamentals

What is a Constant?

A constant is a data value that remains unchanged during the execution of a program.

Three Programming Constructs

The three fundamental programming constructs are: selection, iteration, and sequence.

Logical Operators

One example of a logical operator is AND.

  • Operator: and
  • Description: Logical AND: True if both operands are true.
  • Syntax: x and y

Functions vs. Procedures

Difference: A function is typically used to calculate a value from a given input, while a procedure is a set of commands executed in a specific order.

Similarity: Functions must return a value, but in stored procedures, it is optional. Procedures can return zero or multiple values. Functions usually have only input parameters, whereas procedures can have both input and output parameters.

Benefits of Modular Code

Modular code makes it easier to code. If a change is needed, you can modify it in one place, making the code faster to update and maintain.

Integer Division (%) Operator

The % (integer divide) operator divides two numbers and returns the integer part of the result. For example, 6%2 = 0.

Floor Division (//) Operator

The // operator returns the closest integer value that is less than or equal to a specified expression or value. For example, 5//2 returns 2.

Data Types

  • Integers
  • Strings
  • Decimals
  • Text Data

Entradas relacionadas: