0
0
Blockchain / Solidityprogramming~10 mins

Balance checking in Blockchain / Solidity - Interactive Code Practice

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

Complete the code to get the balance of an account.

Blockchain / Solidity
balance = blockchain.get_balance([1])
Drag options to blanks, or click blank then click option'
Awallet_key
Bblock_number
Caccount_address
Dtransaction_id
Attempts:
3 left
💡 Hint
Common Mistakes
Using block number instead of account address
Using transaction ID instead of account address
2fill in blank
medium

Complete the code to check if the balance is greater than zero.

Blockchain / Solidity
if balance [1] 0:
    print('Balance is positive')
Drag options to blanks, or click blank then click option'
A<
B>
C==
D<=
Attempts:
3 left
💡 Hint
Common Mistakes
Using < instead of >
Using == which checks equality, not greater than
3fill in blank
hard

Fix the error in the code to correctly fetch the balance.

Blockchain / Solidity
balance = blockchain.[1](account_address)
Drag options to blanks, or click blank then click option'
Aretrieve_balance
Bbalance_of
Cfetch_balance
Dget_balance
Attempts:
3 left
💡 Hint
Common Mistakes
Using method names that do not exist in the blockchain API
Typo in method name
4fill in blank
hard

Fill both blanks to create a dictionary of account balances for accounts with balance greater than 100.

Blockchain / Solidity
balances = {account: blockchain.[1](account) for account in accounts if blockchain.[2](account) > 100}
Drag options to blanks, or click blank then click option'
Aget_balance
Bfetch_balance
Dretrieve_balance
Attempts:
3 left
💡 Hint
Common Mistakes
Using different method names for fetching balance
Using a method that does not exist
5fill in blank
hard

Fill all three blanks to create a dictionary of uppercase account names and their balances if balance is above 50.

Blockchain / Solidity
result = {account.[1](): blockchain.[2](account) for account in accounts if blockchain.[3](account) > 50}
Drag options to blanks, or click blank then click option'
Aupper
Bget_balance
Dfetch_balance
Attempts:
3 left
💡 Hint
Common Mistakes
Using inconsistent method names for balance fetching
Using wrong string method for uppercase