0
0
Blockchain / Solidityprogramming~10 mins

Why handling value is core to blockchain - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a simple transaction object with a value field.

Blockchain / Solidity
transaction = {"sender": "Alice", "receiver": "Bob", "[1]": 50}
Drag options to blanks, or click blank then click option'
Avalue
Bhash
Ctimestamp
Dnonce
Attempts:
3 left
💡 Hint
Common Mistakes
Using keys like 'hash' or 'nonce' instead of 'value' for the amount.
2fill in blank
medium

Complete the code to add the transaction value to the sender's balance check.

Blockchain / Solidity
if sender_balance >= [1]:
    print("Transaction approved")
Drag options to blanks, or click blank then click option'
Atransaction['hash']
Btransaction['value']
Ctransaction['timestamp']
Dtransaction['nonce']
Attempts:
3 left
💡 Hint
Common Mistakes
Checking against 'hash' or 'nonce' which are unrelated to the amount.
3fill in blank
hard

Fix the error in the code to correctly update the receiver's balance by adding the transaction value.

Blockchain / Solidity
receiver_balance = receiver_balance [1] transaction['value']
Drag options to blanks, or click blank then click option'
A+
B*
C/
D-
Attempts:
3 left
💡 Hint
Common Mistakes
Using subtraction or multiplication instead of addition.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps each user to their transaction value if the value is greater than 10.

Blockchain / Solidity
{user: [1] for user, [2] in transactions.items() if [1] > 10}
Drag options to blanks, or click blank then click option'
Avalue
Bamount
Cval
Dbalance
Attempts:
3 left
💡 Hint
Common Mistakes
Using different keys like 'amount' or 'val' which may not exist.
5fill in blank
hard

Fill all three blanks to create a filtered dictionary of users with transaction values above 100, using uppercase usernames as keys.

Blockchain / Solidity
filtered = {user.[1](): [2] for user, [3] in transactions.items() if [2] > 100}
Drag options to blanks, or click blank then click option'
Alower
Bvalue
Ctransaction_value
Dupper
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'lower' instead of 'upper' or wrong keys for transaction amounts.