---
# System prepended metadata

title: 'Week Four Learning Review: Vim Navigation and Python Programming Foundations'

---

# Week Four Learning Review: Vim Navigation and Python Programming Foundations

## Introduction

This week, I focused on improving my skills in two key areas: **Vim** and **Python programming**.

I explored the core concepts and advanced usage of the **Vim text editor**, including its different modes, navigation shortcuts, macros, and configuration using `.vimrc`. Simultaneously, I strengthened my understanding of **Python**, learning about variables, data types, string formatting, arithmetic operations, user input, and building interactive scripts.

This reflection highlights what I learned, how I applied it in practice, and how both tools are essential for efficient programming workflows.



## Vim Modes, Shortcuts, and Commands

I explored the five primary modes in Vim:

*  **Normal Mode** – for navigation and performing actions like copying or deleting text.
* **Insert Mode** – used to type or edit text.
* **Command-line Mode** (`:`) – used to run commands such as saving or quitting.
* **Visual Mode** (`v`) – used to highlight and manipulate text.
* **Ex Mode** – an advanced mode for executing Vim scripts.

### Entering Insert Mode

To enter Insert Mode, I learned several useful commands:

* `i` – insert at cursor position
* `I` – insert at the beginning of the line
* `A` – append after the cursor
* `O` – open a new line above
* `S` – delete the current line and insert
* `Insert` – toggles insert mode on some systems

### Displaying Line Numbers

```vim
:set number     " Show line numbers
:set nonumber   " Hide line numbers
```

### Navigation Commands

* `gg` – move to the top of the file
* `G` – move to the bottom of the file
* `25G` – jump to line 25

### Basic Editing Commands

* `x` – delete a character
* `dd` – delete the current line
* `v`, then `y` – yank (copy)
* `v`, then `p` – paste

### Additional Concepts

* `:!ls` – run external shell commands from within Vim
* `.vimrc` – configuration file for customizing Vim settings
* **Macros**:

  * `qa` – start recording into register `a`
  * `q` – stop recording
  *  @a` – play the macro stored in register `a`



## Computer Science Foundations

I learned about the **Input-Process-Output (IPO)** model, which explains how computers operate:

* **Input** – receiving data from the user
* **Process** – performing computations
* **Output** – displaying results



## Introduction to Python Programming

### Python Characteristics

* **Interpreted**: runs line by line
* **Beginner-friendly**: uses simple and readable syntax
* **Versatile**: used in AI, data science, game development, and web development

### Ways to Use Python

* **Interactive mode** – typing commands directly into the terminal
* **Scripting mode** – writing code in `.py` files and executing them


## Variable Naming and Data Types

### Naming Rules

* Variables must begin with a letter or underscore (\_)
* Cannot start with numbers or use Python keywords

### Naming Conventions

* `snake_case`: `user_name`
* `camelCase`: `userName`
* `PascalCase`: `UserName`

### Data Types and Examples

```python
# Integer
age = 25

# Float
height = 1.75

# String
name = "Praise"

# Dictionary
user = {"name": "Praise", "age": 20}

# Set
items = {"apple", "banana"}
```

### String Concatenation and Escape Sequences

```python
# Concatenation
first_name = "John"
last_name = "Doe"
print(first_name + " " + last_name)

# Escape sequences
print("Line1\nLine2")   # New line
print("Item\tPrice")    # Tab space
```



## String Formatting Examples

```python
# Example 1: Using .format() method
first_name = "Tom"
surname = "Jerry"
print("My name is {} {}".format(first_name, surname))  # Output: My name is Tom Jerry

# Example 2: Using comma separation in print
first_name = "Joy"
surname = "Daniel"
print("My name is", first_name, surname)  # Output: My name is Joy Daniel

# Example 3: Using f-string formatting (Python 3.6+)
first_name = "Suzan"
surname = "David"
print(f"My name is {first_name} {surname}")  # Output: My name is Suzan David

# Example 4: Using string concatenation with +
first_name = "Scholarstica"
surname = "Paul"
print("My name is " + first_name + " " + surname)  # Output: My name is Scholarstica Paul
```

Each method is valid, but **f-strings** are recommended in modern Python for their readability and efficiency.



## User Input and Output

```python
full_name = input("Enter your full name: ")
user_age = int(input("Enter your age: "))
user_height = float(input("Enter your height: "))
user_hobbies = input("What are your hobbies? ")

marital_status = input("Are you married? (yes or no): ")
is_married = marital_status.strip().lower() == "yes"

print(f"Full Name: {full_name}")
print(f"Age: {user_age}")
print(f"Height: {user_height}")
print(f"Hobbies: {user_hobbies}")
print(f"Married: {is_married}")
```



## Performing Arithmetic Operations

```python
a = 10
b = 5

print(a + b)    # Addition
print(a - b)    # Subtraction
print(a * b)    # Multiplication
print(a / b)    # Division
```



## Python Simulation: Microwave App

```python
import time

print("""
**************
Cohort III Microwave
**************
1. Open The Microwave
2. Put The Rice
3. Set the Time
""")

customer = {}

username = input("Enter your name:\n>>> ")
customer["username"] = username

time_to_heat = int(input("Duration (minutes):\n>>> "))
customer["duration"] = time_to_heat
customer["amount"] = time_to_heat * 1000

print("You are charged: #", customer["amount"], "only")
print(f"Your rice will be ready in {time_to_heat} minute(s), {username}")
print("4. I will let you know when it is ready...")

time.sleep(time_to_heat * 60)
print("5. Your food is ready.")
```



## Summary

This week strengthened my ability to work with both **text editors** and **Python scripts**. I now have a deeper understanding of how to:

* Use Vim efficiently
* Apply the IPO model in computing
* Handle variables and data types in Python
* Format strings in multiple ways
* Collect and process user input
* Create simple, interactive Python programs


