📖 Scenario: You work in a small business that tracks sales data. You want to understand how to use Python, R, and Excel to analyze this data and find the best tool for your needs.
🎯 Goal: Build simple data analysis examples in Python, R, and Excel to compare how each tool handles data setup, filtering, and summarizing.
📋 What You'll Learn
Create a sales data dictionary in Python
Set a sales threshold variable
Filter sales above the threshold using a dictionary comprehension
Print the filtered sales dictionary
💡 Why This Matters
🌍 Real World
Businesses often need to analyze sales data to find top-performing months or products. Knowing how to filter data quickly helps make better decisions.
💼 Career
Data analysts and business users use Python, R, or Excel to clean and analyze data. Understanding these tools helps pick the right one for the task.
Progress0 / 4 steps
1
DATA SETUP: Create sales data dictionary
Create a dictionary called sales with these exact entries: 'January': 1500, 'February': 1800, 'March': 1200, 'April': 2200, 'May': 1700
Data Analysis Python
Hint
Use curly braces to create a dictionary with month names as keys and sales numbers as values.
2
CONFIGURATION: Set sales threshold
Create a variable called threshold and set it to 1600
Data Analysis Python
Hint
Just assign the number 1600 to the variable named threshold.
3
CORE LOGIC: Filter sales above threshold
Use a dictionary comprehension to create a new dictionary called high_sales that contains only the months and sales from sales where the sales value is greater than threshold
Data Analysis Python
Hint
Use dictionary comprehension syntax: {key: value for key, value in dict.items() if condition}
4
OUTPUT: Print filtered sales
Print the high_sales dictionary
Data Analysis Python
Hint
Use print(high_sales) to show the filtered dictionary.
Practice
(1/5)
1. Which tool is best suited for quick, visual data analysis without coding?
easy
A. Python
B. Excel
C. R
D. SQL
Solution
Step 1: Understand tool strengths
Excel is designed for easy, visual data work with minimal coding.
Step 2: Compare with other tools
Python and R require coding and are better for complex or large data tasks.
Final Answer:
Excel -> Option B
Quick Check:
Visual, no-code analysis = Excel [OK]
Hint: Visual and simple? Choose Excel [OK]
Common Mistakes:
Confusing Python's power with ease of use
Thinking R is for simple visuals
Assuming SQL is for visual analysis
2. Which of the following is the correct way to import a CSV file in Python using pandas?
easy
A. import pandas as pd\ndf = pd.read_csv('file.csv')
B. read.csv('file.csv')
C. import csv.read('file.csv')
D. load('file.csv')
Solution
Step 1: Recall pandas import syntax
Python uses 'import pandas as pd' to import pandas library.
Step 2: Use correct function to read CSV
'pd.read_csv()' is the correct function to load CSV files into a DataFrame.
Final Answer:
import pandas as pd\ndf = pd.read_csv('file.csv') -> Option A
Quick Check:
pandas CSV import = pd.read_csv() [OK]
Hint: Use pd.read_csv() to load CSV in Python [OK]
Common Mistakes:
Using 'import csv.read()' which is invalid
Confusing R syntax 'read.csv()' with Python
Using 'load()' which is not a pandas function
3. What will be the output of this Python code snippet?