Which statement correctly describes the difference between Ethereum Mainnet and Testnet?
Think about where real money is involved versus where developers try out code safely.
Mainnet is the official Ethereum blockchain where real Ether has value and transactions cost real money. Testnets are separate blockchains used by developers to test smart contracts and applications without risking real funds.
What is the output of the following code snippet that checks the Ethereum network by chain ID?
chain_id = 5 network = "Mainnet" if chain_id == 1 else "Goerli Testnet" if chain_id == 5 else "Unknown" print(network)
Chain ID 1 is Mainnet; 5 is a popular testnet.
The code checks if the chain ID is 1 for Mainnet or 5 for Goerli Testnet. Since chain_id is 5, it prints 'Goerli Testnet'.
What is the output of this Python code that calculates the total cost of a transaction on a testnet?
gas_price_gwei = 20 gas_used = 21000 total_cost_eth = (gas_price_gwei * gas_used) / 1_000_000_000 print(f"Total cost in ETH: {total_cost_eth}")
Remember 1 Gwei = 10⁻⁹ ETH. Multiply gas price by gas used, then convert.
Gas price is 20 Gwei = 20 * 10⁻⁹ ETH. Total cost = 20 * 21000 / 1,000,000,000 = 0.00042 ETH.
What error does the following code raise when trying to select the Ethereum network?
def select_network(chain_id):
if chain_id == 1:
return "Mainnet"
elif chain_id == 3:
return "Ropsten Testnet"
else:
return "Unknown"
print(select_network(1))Check the if statement condition syntax carefully.
The code uses '=' (assignment) instead of '==' (comparison) in the if condition, causing a SyntaxError.
Given the list of network names below, how many unique Ethereum testnets are included?
networks = ["Mainnet", "Goerli", "Ropsten", "Kovan", "Mainnet", "Goerli", "Rinkeby"]
Count only testnets, ignore Mainnet duplicates.
The testnets in the list are Goerli, Ropsten, Kovan, and Rinkeby. That's 4 unique testnets.