0
0
Blockchain / Solidityprogramming~15 mins

Why data location affects cost in Blockchain / Solidity - See It in Action

Choose your learning style9 modes available
Why Data Location Affects Cost in Blockchain
📖 Scenario: Imagine you are managing a blockchain network where storing data in different locations costs different amounts. You want to calculate the total cost of storing data based on where it is stored.
🎯 Goal: Build a simple program that calculates the total cost of storing data in various locations on a blockchain, showing how location affects cost.
📋 What You'll Learn
Create a dictionary with data locations and their storage sizes
Create a dictionary with cost per unit storage for each location
Calculate total cost for each location using dictionary comprehension
Print the total cost per location
💡 Why This Matters
🌍 Real World
Blockchain networks often charge different fees depending on where data is stored. Understanding how location affects cost helps manage expenses.
💼 Career
Blockchain developers and network managers need to calculate storage costs accurately to optimize resource use and pricing.
Progress0 / 4 steps
1
Create data storage dictionary
Create a dictionary called data_storage with these exact entries: 'NodeA': 100, 'NodeB': 200, 'NodeC': 150 representing storage size in MB.
Blockchain / Solidity
Need a hint?

Use curly braces {} to create a dictionary with keys as node names and values as storage sizes.

2
Create cost per MB dictionary
Create a dictionary called cost_per_mb with these exact entries: 'NodeA': 0.05, 'NodeB': 0.03, 'NodeC': 0.04 representing cost per MB in dollars.
Blockchain / Solidity
Need a hint?

Use curly braces {} to create a dictionary with keys as node names and values as cost per MB.

3
Calculate total cost per location
Use a dictionary comprehension to create a dictionary called total_cost where each key is a node from data_storage and the value is the product of storage size and cost per MB from cost_per_mb.
Blockchain / Solidity
Need a hint?

Use dictionary comprehension syntax: {key: value for key in iterable}.

4
Print total cost per location
Write a print statement to display the total_cost dictionary.
Blockchain / Solidity
Need a hint?

Use print(total_cost) to show the dictionary with costs.