DEV Community

Cover image for 6.0001 Introduction to Computer Science and Programming in Python : Lecture 01 : What is Computation ?
Suraj Singh
Suraj Singh

Posted on

6.0001 Introduction to Computer Science and Programming in Python : Lecture 01 : What is Computation ?

Computation refers to the process of using algorithms and computational devices to perform calculations, solve problems, and process information. It involves transforming data or inputs into desired outputs through a series of well-defined steps or instructions.

Type of Knowledge

  1. Declarative Knowledge:

    Declarative knowledge focuses on describing "what" needs to be accomplished or the desired outcome, without specifying "how" to achieve it. It emphasizes the use of logic and facts to represent knowledge. Declarative knowledge is commonly associated with declarative programming languages and logic-based systems.

  2. Imperative Knowledge

    Imperative knowledge, on the other hand, focuses on providing a step-by-step procedure or a series of commands to achieve a specific goal. It describes "how" to accomplish a task by explicitly stating the sequence of actions or operations to be performed. Imperative knowledge is often more detailed and specific, providing a clear set of instructions for the computer to follow. It is well-suited for tasks that require precise control over the execution flow or complex state manipulation.

Fixed program computer VS Stored program computer

  1. Fixed Program Computer: A fixed program computer, also known as a dedicated computer, is a type of computer that is designed to perform a specific task or set of tasks. The computer's program or instructions are permanently built into its hardware, and they cannot be changed or modified once the computer is manufactured. The program is typically hardwired or implemented using specialized circuits.
  2. Stored Program Computer: A stored program computer, also known as a general-purpose computer, is a type of computer architecture where both the program instructions and data are stored in memory. It allows the computer to store and execute different programs, enabling versatility and flexibility.

Basic Primitives

In programming, "BASIC primitives" refer to the fundamental operations or basic building blocks available in a programming language. These primitives are the simplest and most essential instructions or constructs that form the foundation for writing more complex programs. The specific set of BASIC primitives may vary depending on the programming language. example Variables, Data types, Arithmetic Operations, Conditional Statements etc.

Static Semantic

Static semantics in programming languages refers to the set of rules and constraints that determine the validity and correctness of a program's structure and its components at compile-time, without executing the program. It focuses on the analysis of program elements such as variables, expressions, types, and their relationships to ensure they adhere to the language's specifications. for example

In English: "I are hungry" → syntactically valid but it is static semantic error
In programming language:

3.2*5 → syntactically valid
but 3+"hi" → static semantic error

Program

In computer science, a program refers to a set of instructions or statements written in a programming language that directs a computer to perform a specific task or solve a particular problem. It is a sequence of instructions that defines the algorithmic steps to be executed by a computer or computing device.

Python Program

In python program, everything is a object and each object is a type. There are two type of object in python Scalar object and Non-Scalar object.

In Python, a scalar object refers to a basic or primitive data type that represents a single value. Scalar objects are immutable, meaning their values cannot be changed once assigned. They are atomic and cannot be further divided into smaller components.

Python provides several built-in scalar object types, including:

  1. Integers (int): Integers represent whole numbers without fractional parts. For example, 1, 10, -5 are all integers.
  2. Floating-Point Numbers (float): Floating-point numbers represent numbers with decimal points. For example, 3.14, -0.5, 2.0 are all floating-point numbers.
  3. Booleans (bool): Booleans represent truth values and can have two possible values: True or False. They are often used in logical expressions and control flow statements.
  4. None: None is commonly used to indicate the absence of a return value or to initialize variables when no specific value is assigned. None is a singleton object in Python, meaning there is only one instance of it throughout the program. It is of type NoneType.

Expressions

In programming, an expression is a combination of values, variables, operators, and function calls that can be evaluated to produce a result. Expressions represent computations or operations that manipulate data and produce a value of a certain type.

Here are some example of expressions:

Arithmetic Expression:

result = 2 + 3 * 4
Enter fullscreen mode Exit fullscreen mode

In this expression, 2 + 3 * 4, the operators + and * are applied to the operands 2, 3, and 4 to perform arithmetic calculations. The result will be stored in the variable result.

Comparison Expression:

is_equal = (x == y)
Enter fullscreen mode Exit fullscreen mode

Here, the expression (x == y) compares the values of variables x and y using the equality operator ==. The result will be either True or False depending on whether x and y are equal.

Top comments (0)