Python Code Snippets and Programming Concepts

HW9: Shift String

Function caesar shifts letters in a string:

def caesar(left, shift): 
ref = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
con = ""
letf = left.strip().upper()
for x in range(0, len(left)):
if letf[x] not in ref:
con += letf[x]
else:
con += ref[(ref.find(left[x]) + shift) % 26]
return con

CW10: Recursion

Function fib calculates Fibonacci numbers recursively:

def fib(n): 
if n in [1, 2]:
return 1
else:
return fib(n - 1)
Read More

Network Fundamentals: MAC, IP, Routing, and Protocols

1.1. Addressing Physical Layer

To connect a computer to a network, you need a network interface card (NIC) with a unique Media Access Control (MAC) address.

  • A MAC address is a 48-bit (12 hexadecimal digits) number.
  • Each NIC must have a different MAC address.
  • There are approximately 248 (281 trillion) possible MAC addresses.

1.2. Routing Logic and IP Addresses

Your machine uses an Internet Protocol (IP) address for routing. An IP address is composed of 32 bits, grouped into four 8-bit bytes (octets).

Example:

Read More

8085 Microprocessor: Flags, Memory, Pipelining, and DMA

What is a Flag Register? 8085 Flags Explained

The Flag Register in the 8085 microprocessor is an 8-bit register reflecting the outcome of arithmetic and logical operations. It contains 5 main flags, each occupying one bit, indicating conditions arising during instruction execution. These flags help the microprocessor make decisions and control operations based on specific conditions.

The 8085 microprocessor has five flags:

1. Zero Flag (Z): Set when the result of an arithmetic or logical operation

Read More

VTP and Spanning Tree Protocol (STP) for Network Management

VLAN Trunking Protocol (VTP)

VTP allows a network administrator to propagate VLAN configurations across a network.

Benefits of VTP

  • Consistency in VLAN configuration.
  • Accurate VLAN tracking and monitoring.
  • Dynamic reports on added VLANs.
  • Dynamic trunk configuration.

VTP automatically synchronizes domain and VLAN configurations. Use show vtp status to display network status and recommended actions.

VTP Modes

  • Server: Create, modify, and delete VLANs (default mode).
  • Client: Receives and applies VTP information
Read More

DHCP Protocol

Introduction

DHCP (Dynamic Host Configuration Protocol) is a TCP/IP layer application. It’s a standard designed to simplify IP address management on a network.

This protocol uses a client/server model, enabling centralized network management. A server maintains a pool of dynamic IP addresses.

The server assigns IP addresses to connecting clients, providing necessary configuration information without prior network knowledge.

The server logs IP address usage, tracking which addresses are in use and for

Read More

Data Protection Rules and Security Measures

Data Protection Rules for Employees

Working with Personal Data Files

  1. Understand which personal data files are relevant to your job.
  2. Obtain explicit consent from the individual before processing their data.
  3. Refrain from using personal data files for unauthorized purposes.
  4. Report the cessation of use of a specific file.
  5. Notify the relevant department of any changes to the structure or purpose of Data Protection Commission (DPC) files to ensure GDPR compliance.
  6. Communicate to the relevant authority when a
Read More