📖 Scenario: You are a DevOps engineer helping a small company decide which container orchestration tool to use: Docker Swarm or Kubernetes. You will create a simple program that stores key features of both tools, sets a decision threshold, compares the features, and outputs a recommendation.
🎯 Goal: Build a small program that holds feature data for Docker Swarm and Kubernetes, sets a threshold for decision making, compares the features, and prints a recommendation on which tool to choose based on the threshold.
📋 What You'll Learn
Create a dictionary called features with keys 'Swarm' and 'Kubernetes' and integer values representing feature scores
Create a variable called threshold set to 7
Use an if statement to compare the feature scores to the threshold
Print the recommendation exactly as specified
💡 Why This Matters
🌍 Real World
Companies often need to choose the right container orchestration tool based on their needs. This project simulates making that choice using simple data and logic.
💼 Career
DevOps engineers must understand differences between tools like Swarm and Kubernetes and be able to automate decisions and configurations.
Progress0 / 4 steps
1
Create the features dictionary
Create a dictionary called features with these exact entries: 'Swarm': 6 and 'Kubernetes': 9
Docker
Hint
Use curly braces to create a dictionary with keys 'Swarm' and 'Kubernetes' and their scores as values.
2
Set the decision threshold
Create a variable called threshold and set it to the integer 7
Docker
Hint
Just assign the number 7 to a variable named threshold.
3
Compare features to threshold
Write an if statement that checks if features['Kubernetes'] is greater than or equal to threshold. If true, assign the string 'Use Kubernetes' to a variable called decision. Otherwise, assign 'Use Swarm' to decision.
Docker
Hint
Use an if-else block to compare the Kubernetes score with the threshold and assign the decision string accordingly.
4
Print the decision
Write a print statement to display the value of the variable decision
Docker
Hint
Use print(decision) to show the recommendation.
Practice
(1/5)
1. Which statement best describes Docker Swarm compared to Kubernetes?
easy
A. Docker Swarm is simpler and faster to set up than Kubernetes.
B. Docker Swarm has more features than Kubernetes.
C. Kubernetes is easier for beginners than Docker Swarm.
D. Kubernetes is only for small projects.
Solution
Step 1: Understand Docker Swarm's purpose
Docker Swarm is designed to be simple and quick to start for container orchestration.
Step 2: Compare with Kubernetes features
Kubernetes offers more advanced features and flexibility but is more complex to set up.
Final Answer:
Docker Swarm is simpler and faster to set up than Kubernetes. -> Option A
Quick Check:
Swarm simplicity = B [OK]
Hint: Swarm is simple; Kubernetes is feature-rich [OK]
Common Mistakes:
Thinking Kubernetes is easier for beginners
Believing Swarm has more features
Assuming Kubernetes is only for small projects
2. Which command initializes a Docker Swarm cluster on the current machine?