0
0
Blockchain / Solidityprogramming~30 mins

Layer 2 solutions overview in Blockchain / Solidity - Mini Project: Build & Apply

Choose your learning style9 modes available
Layer 2 Solutions Overview
📖 Scenario: You are working with blockchain data and want to organize information about Layer 2 solutions. Layer 2 solutions help blockchains handle more transactions quickly and cheaply by working on top of the main blockchain.
🎯 Goal: You will create a dictionary of Layer 2 solutions with their types, set a filter type, extract solutions of that type using dictionary comprehension, and finally print the filtered solutions.
📋 What You'll Learn
Create a dictionary called layer2_solutions with exact entries for solutions and their types
Create a variable called filter_type with the exact string value to filter solutions
Use dictionary comprehension to create a new dictionary called filtered_solutions containing only solutions matching filter_type
Print the filtered_solutions dictionary
💡 Why This Matters
🌍 Real World
Layer 2 solutions are important in blockchain to improve speed and reduce costs. Organizing and filtering these solutions helps developers and users understand options available.
💼 Career
Understanding how to manage and filter data structures like dictionaries is essential for blockchain developers working with Layer 2 technologies and other blockchain data.
Progress0 / 4 steps
1
Create the Layer 2 solutions dictionary
Create a dictionary called layer2_solutions with these exact entries: 'Optimism': 'Optimistic Rollup', 'Arbitrum': 'Optimistic Rollup', 'Polygon': 'Sidechain', 'zkSync': 'ZK Rollup', 'Loopring': 'ZK Rollup'
Blockchain / Solidity
Need a hint?
Use curly braces {} to create a dictionary with keys and values separated by colons.
2
Set the filter type
Create a variable called filter_type and set it to the string 'Optimistic Rollup'
Blockchain / Solidity
Need a hint?
Assign the string 'Optimistic Rollup' to the variable filter_type.
3
Filter solutions by type using dictionary comprehension
Use dictionary comprehension to create a new dictionary called filtered_solutions that contains only the entries from layer2_solutions where the value equals filter_type
Blockchain / Solidity
Need a hint?
Use a dictionary comprehension with a condition to filter by filter_type.
4
Print the filtered solutions
Write a print statement to display the filtered_solutions dictionary
Blockchain / Solidity
Need a hint?
Use print(filtered_solutions) to show the filtered dictionary.