📖 Scenario: You are working as a developer for a company that wants to explore how blockchain technology can be used beyond cryptocurrencies. Your task is to create a simple Python program that lists some real-world blockchain use cases and filters them based on a category.
🎯 Goal: Build a Python program that stores a dictionary of blockchain use cases with their categories, sets a category filter, selects use cases matching that category using dictionary comprehension, and prints the filtered results.
📋 What You'll Learn
Create a dictionary called use_cases with exact entries of blockchain use cases and their categories
Create a variable called filter_category with the exact string value to filter use cases
Use dictionary comprehension with use_cases.items() to create a filtered dictionary called filtered_use_cases containing only use cases matching filter_category
Print the filtered_use_cases dictionary
💡 Why This Matters
🌍 Real World
Blockchain technology is used in many fields beyond cryptocurrencies, such as securing digital identities, improving supply chains, and managing healthcare records. This project helps understand how to organize and filter such information programmatically.
💼 Career
Understanding how to handle and filter data related to blockchain use cases is useful for roles in blockchain development, data analysis, and technology consulting.
Progress0 / 4 steps
1
DATA SETUP: Create the blockchain use cases dictionary
Create a dictionary called use_cases with these exact entries: 'Supply Chain': 'Logistics', 'Digital Identity': 'Security', 'Healthcare Records': 'Health', 'Voting Systems': 'Governance', 'Real Estate': 'Property'
Blockchain / Solidity
Hint
Use curly braces {} to create a dictionary with keys and values separated by colons.
2
CONFIGURATION: Set the category filter
Create a variable called filter_category and set it to the string 'Security'
Blockchain / Solidity
Hint
Assign the string 'Security' to the variable filter_category.
3
CORE LOGIC: Filter use cases by category using dictionary comprehension
Use dictionary comprehension with use_cases.items() to create a new dictionary called filtered_use_cases that contains only the entries where the category equals filter_category
Blockchain / Solidity
Hint
Use {key: value for key, value in dictionary.items() if condition} to filter the dictionary.
4
OUTPUT: Print the filtered use cases
Write a print statement to display the filtered_use_cases dictionary
Blockchain / Solidity
Hint
Use print(filtered_use_cases) to show the filtered dictionary.
Practice
(1/5)
1. Which of the following is a common use of blockchain technology beyond cryptocurrency?
easy
A. Creating new digital currencies only
B. Running traditional centralized databases
C. Tracking the origin and movement of goods in supply chains
D. Replacing all internet servers
Solution
Step 1: Understand blockchain beyond money
Blockchain is used to keep safe and clear records, not just for digital money.
Step 2: Identify common non-crypto uses
Tracking goods in supply chains is a popular use case to ensure transparency and trust.
Final Answer:
Tracking the origin and movement of goods in supply chains -> Option C
Quick Check:
Blockchain use beyond crypto = Tracking goods [OK]
Hint: Think of blockchain as a secure record keeper beyond money [OK]
Common Mistakes:
Thinking blockchain only creates cryptocurrencies
Confusing blockchain with regular databases
Assuming blockchain replaces all internet servers
2. Which syntax correctly describes a smart contract in blockchain?
easy
A. contract SmartContract { function run() public {} }
B. smart contract run() {}
C. contract = SmartContract()
D. function smartContract run()
Solution
Step 1: Recognize smart contract syntax
Smart contracts are written like small programs with a contract keyword and functions.
Step 2: Check syntax correctness
contract SmartContract { function run() public {} } uses correct syntax with 'contract' keyword and function declaration.
Final Answer:
contract SmartContract { function run() public {} } -> Option A
Quick Check:
Correct smart contract syntax = contract SmartContract { function run() public {} } [OK]
Hint: Look for 'contract' keyword and function inside braces [OK]
Common Mistakes:
Missing 'contract' keyword
Using assignment instead of declaration
Incorrect function declaration syntax
3. What will be the output of this simplified blockchain smart contract code snippet?
mapping(address => uint) public votes; function vote() public { votes[msg.sender] += 1; } vote() called twice by same address.
medium
A. votes[msg.sender] = 1
B. votes[msg.sender] = 2
C. votes[msg.sender] = 0
D. Error: duplicate voting not allowed
Solution
Step 1: Understand the vote function
Each call to vote() increases the caller's vote count by 1 in the votes mapping.
Step 2: Calculate votes after two calls
Calling vote() twice adds 1 twice, so votes[msg.sender] becomes 2.
Final Answer:
votes[msg.sender] = 2 -> Option B
Quick Check:
Two votes increment count to 2 [OK]
Hint: Each call adds 1, so two calls add up to 2 [OK]
Common Mistakes:
Assuming only one vote allowed
Thinking votes reset after each call
Confusing mapping with array
4. Identify the error in this blockchain voting smart contract snippet:
mapping(address => bool) public voted; function vote() public { require(!voted[msg.sender]); voted[msg.sender] = true; votes += 1; }
medium
A. votes variable is not declared
B. require statement syntax is wrong
C. voted mapping should be uint not bool
D. Function vote() missing return type
Solution
Step 1: Check variable declarations
The code uses 'votes += 1' but 'votes' is not declared anywhere.
Step 2: Verify other parts
require syntax and voted mapping type are correct; vote() functions in Solidity do not need return type.
Final Answer:
votes variable is not declared -> Option A
Quick Check:
Undeclared variable 'votes' causes error [OK]
Hint: Check if all variables used are declared [OK]
Common Mistakes:
Assuming require syntax is wrong
Thinking bool mapping is incorrect
Expecting return type in void functions
5. You want to build a blockchain system to manage digital rights for music tracks. Which feature is most important to include beyond basic blockchain storage?
hard
A. Anonymous voting for favorite tracks
B. A cryptocurrency token for trading music
C. A centralized database for faster queries
D. Smart contracts to automate royalty payments
Solution
Step 1: Understand digital rights management needs
Managing rights requires automatic, trustworthy payment distribution to artists.
Step 2: Identify blockchain feature for automation
Smart contracts can run code to automate royalty payments when music is used or sold.
Step 3: Evaluate other options
Cryptocurrency tokens and voting are unrelated; centralized database loses blockchain benefits.
Final Answer:
Smart contracts to automate royalty payments -> Option D
Quick Check:
Automate payments with smart contracts [OK]
Hint: Use smart contracts to automate rules and payments [OK]
Common Mistakes:
Choosing cryptocurrency token instead of automation
Using centralized database losing blockchain trust
Confusing voting with rights management
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.