Professional Documents
Culture Documents
Class Notes
Class Notes
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:
- Data Types: The classification of data items. It tells the compiler or interpreter how the programmer
- Functions: A block of code which only runs when it is called. You can pass data, known as
- Control Structures: Instructions that determine the flow of control in a program (e.g., if statements,
loops).
```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
can contain data, in the form of fields (often known as attributes or properties), and code, in the form
Key Concepts:
- 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.
```python
class Person:
self.name = name
self.age = age
def greet(self):
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.