---
description: Lesson 2 Introduction and outline
---

# Lesson 2: Outline

## Lesson 2: Basic Data Types and Control Structures in Solidity

**Objective:** To understand and apply the basic data types and control structures in Solidity. This knowledge is essential for writing efficient and effective smart contracts.

### **Part 1: Data Types**

* **Primitive Data Types**:
  * `uint`: Unsigned integers, non-negative integers of various sizes (e.g., `uint256`).
  * `int`: Signed integers, can hold negative values (e.g., `int256`).
  * `bool`: Boolean value, true or false.
  * `address`: Holds a 20-byte value (size of an Ethereum address).
  * `bytes`: Dynamic array of bytes. `bytes1`, `bytes2`, ..., `bytes32` are fixed-size byte arrays.
* **Variables**:
  * Understanding state variables and local variables.
  * Storage, memory, and stack as data location options.
* **Constants and Immutables**:
  * How to declare and use constant and immutable variables for optimization.

### **Part 2: Control Structures**

* **Conditionals**:
  * `if`, `else`, and `else if` statements for decision-making.
  * Importance and usage of conditionals in smart contracts.
* **Loops**:
  * `for`, `while`, and `do while` loops.
  * Understanding the gas cost implications of loops.
  * Best practices for using loops in smart contracts (e.g., avoiding infinite loops, managing gas costs).

### **Part 3: Operators**

* **Arithmetic Operators**: Addition, subtraction, multiplication, division, modulo.
* **Comparison Operators**: Equals, not equal, greater than, less than, etc.
* **Logical Operators**: AND, OR, NOT.
* **Bitwise Operators**: AND, OR, XOR, NOT, SHIFT (left and right).



***

This lesson will deepen your understanding of how Solidity handles basic programming constructs. It's important to grasp these fundamentals as they form the building blocks of more complex contract logic. After completing this lesson, you'll be better equipped to write smart contracts that are not only functional but also optimized for efficiency and cost-effectiveness.
