How Do You Use the .copy() Feature in Python?

Problem scenario
You want to use the copy feature in Python. What do you do?

Solution
To see the different types of copying, use a mutable object such as a list. Here is an example:

import copy

var1 = [1, 2, 3, 4]
shallow_copy = var1
deep_copy = copy.deepcopy(var1)
var1.append(999999999999)

print()
print(shallow_copy)
print(” — Shallow copy above and deep copy below —.”)
print(deep_copy)

For most (or perhaps all) intents and purposes,

Why Should You Use virtualenv when Using Python?

Question
You were told to write a Python program in virtualenv (a layer of virtualization). Why are you being asked to do this?

Answer
Isolation of dependencies is one of the dozen factors in 12 Factor App. Using pip or pip3 on an entire Linux system to install packages for PyPI is inadvisable (according to page 32 of Expert Python Programming).

How Do You Get the Linux Command “lsns” to Work?

One of the following scenarios apply:

Problem scenario #1
You are trying to view namespaces on a Linux server. You run “lsns” but you get “lsns: command not found.”

Problem scenario #2
You run this: sudo apt -y install util-linux

You see “util-linux is already the newest version (2.27.1-6ubuntu3.8)”

What should you do on a Debian derivative of Linux (e.g.,

How Do You Install MongoDB on RHEL 8.x?

Problem scenario
You want to install MongoDB on a RHEL server. What do you do?

Solution
1. Create this file: /etc/yum.repos.d/mongodb-org-4.4.repo

[mongodb-org-4.4]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.4/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.4.asc

  1. Run these commands:

sudo yum -y update
sudo yum -y install mongodb-org

  1. Test the installation by running this: mongod -version

If you are using Debian or Ubuntu,

How Do You Get the Water to Spurt Out of a Water Flosser Immediately?

Problem scenario
You have a Water pick for your gums and teeth (also known as a water flosser, Waterpik, or an oral irrigator). It takes time for the pressure to become optimal when you turn it on. You want the pressure to be forceful and not take time once the water basin is full and the device is on. It used to work quickly; it would start spitting out water immediately.

How Do You Deploy a Windows 2019 Server in AWS?

Problem scenario
You want to create a Windows 2016 server in AWS.  How do you do this?

Solution
1.  In the AWS Console go to the EC2 Dashbaord.
2.  Go to Launch Instance -Find the AMI for Microsoft Windows Server 2016 Base and click “Select.”
3.  Click “Next: Configure Instance Details”
4.  Click “Next: Add Storage”
5.  Click “Next: Add Tags”
6. 

How Does a Python Docstring Work?

Problem scenario
You know that Python has a feature for documentation strings that can print out when your program runs. How does it work as comments and as something that is displayed at the time the code is executed?

Solution
To best illustrate how one works, create a file called test.py with this code and run it:

def cool_function(n):
”’This is an example of a docstring. …

How Do You Find the amd/i386 Architecture Indication for your Linux OS (to know what type of Debian Package you will need)?

Problem scenario
You are trying to find out what .deb file you need (e.g., from pkgs.org). How do you find out if you need to decide between options like i386, arm, or amd64 on a Debian or Ubuntu server? What should you do?

Solution
Run this command:

sudo dpkg –print-architecture …

How Do You Troubleshoot the Error “An error occurred (InvalidParameterException) when calling the CreateNodegroup operation: The provided nodeRole is invalid.”?

Problem scenario
From the AWS CLI you try to create a node group. But you get this error: “An error occurred (InvalidParameterException) when calling the CreateNodegroup operation: The provided nodeRole is invalid.”

Solution
The above can happen when you use a role’s name but not the ARN string (such as arn:aws:iam::123456:role/foobar). Use the ARN string of the role instead of what you were using.