You are on page 1of 3

Class Notes

Week 1: Introduction to Programming

Programming is a process of creating a set of instructions that tell a computer how to perform a task.

Programming can be done using various programming languages, including Python, Java, C++, and

more.

Key Concepts:

- Variables: Containers for storing data values.

- Data Types: The classification of data items. It tells the compiler or interpreter how the programmer

intends to use the data.

- Functions: A block of code which only runs when it is called. You can pass data, known as

parameters, into a function.

- Control Structures: Instructions that determine the flow of control in a program (e.g., if statements,

loops).

Example of a simple Python program:

```python

def greet(name):

print(f"Hello, {name}!")

greet("Alice")

```

This program defines a function `greet` that takes a name as a parameter and prints a greeting. The
Class Notes

`greet` function is then called with the argument `"Alice"`.

Week 2: Object-Oriented Programming (OOP)

Object-oriented programming is a programming paradigm based on the concept of "objects", which

can contain data, in the form of fields (often known as attributes or properties), and code, in the form

of procedures (often known as methods).

Key Concepts:

- Classes: Blueprints for creating objects (a particular data structure).

- Objects: An instance of a class.

- Inheritance: A mechanism in which one class inherits the attributes and methods of another.

- Polymorphism: The ability of different objects to respond, each in its own way, to identical

messages.

Example of a simple class in Python:

```python

class Person:

def __init__(self, name, age):

self.name = name

self.age = age

def greet(self):

print(f"Hello, my name is {self.name} and I am {self.age} years old.")


Class Notes

alice = Person("Alice", 30)

alice.greet()

```

This example defines a `Person` class with a constructor `__init__` and a method `greet`. An

instance of the `Person` class is created with the name "Alice" and age 30, and the `greet` method

is called.

You might also like