Learning Objectives – before starting Solidity you should be able to:
  • Explain what a program, a variable, a data type and a function are.
  • Use operators, conditions and loops to control the flow of a program.
  • Describe the basic ideas of object-oriented programming (class, object, inheritance).
  • Understand the blockchain terms used throughout this course: account, address, transaction, gas.
Why this Prerequisite?

Solidity is a programming language. Its syntax looks like C, C++, Java and JavaScript, so anyone who knows the basics of programming will learn it much faster. This chapter (and the video below) quickly revises those basics and the blockchain ideas that Solidity is built on.

New to blockchain? Read the free Blockchain course first – especially the chapters on Ethereum, accounts, gas and transactions.
Core Programming Concepts
ConceptMeaningIn Solidity
VariableA named place that stores a value.uint count = 10;
Data typeThe kind of value a variable can hold (number, text, true/false …).uint, bool, string, address
OperatorA symbol that performs an operation on values.+ - * / % == && ||
ConditionExecutes code only when a test is true.if (x > 5) { ... }
LoopRepeats code while a condition holds.for (uint i = 0; i < 3; i++) { ... }
FunctionA reusable block of code with inputs (parameters) and outputs (return values).function add(uint a, uint b) ...
ArrayAn ordered list of values of the same type.uint[] marks;
Record / structureGroups related values into one unit.struct Student { ... }
Compiled vs Interpreted Languages
  • A compiled language (C, C++, Solidity) is translated by a compiler into lower-level code before it runs.
  • An interpreted language (Python, JavaScript) is executed line by line by an interpreter at run time.
  • Solidity source code is compiled by solc into EVM bytecode, which runs on every Ethereum node inside the Ethereum Virtual Machine.
  • Solidity is statically typed: every variable’s type is fixed when the code is written, and the compiler checks types before deployment.
Object-Oriented Ideas You Will Meet Again
OOP ideaGeneral meaningSolidity equivalent
ClassA blueprint containing data and methods.contract (Chapter 16)
ObjectAn instance of a class.A deployed contract at an address
ConstructorCode that runs when an object is created.constructor (Chapter 17)
InheritanceA child class reuses a parent class.contract B is A (Chapter 18)
InterfaceA list of methods without implementation.interface (Chapter 19)
EncapsulationHiding internal details.Visibility: private, internal (Chapters 5, 15)
Blockchain Terms Used in this Course
  • Smart contract – a program stored on a blockchain that runs exactly as written.
  • Account / Address – a 20-byte identifier (e.g. 0x5B38…) for a user wallet or a contract.
  • Transaction – a signed request that changes blockchain data (for example calling a function that writes a value).
  • Gas – the fee unit for computation; every operation that changes state costs gas, paid in Ether.
  • Ether (ETH) and wei – Ethereum’s currency; 1 ether = 1018 wei.
  • Immutability – once deployed, contract code cannot be edited, so bugs must be avoided before deployment.
Key Takeaways
  • Solidity uses familiar programming building blocks: variables, types, operators, conditions, loops and functions.
  • It is compiled, statically typed and runs on the Ethereum Virtual Machine.
  • Contracts behave like classes, and deployed contracts behave like objects that live on the blockchain.
Video : Prerequisite : Programming Basics for Solidity
Question / Answer (15 questions)

Answer : A variable is a named storage location that holds a value which can be read and changed by a program. In Solidity every variable has a fixed data type, for example uint count = 10;.

Answer : A data type defines what kind of value a variable can store (integer, boolean, text, address …) and which operations are allowed on it. It lets the compiler reserve the right amount of space and catch mistakes such as adding a number to text.

Answer : A compiled language is translated by a compiler into lower-level code before it runs; an interpreted language is executed line by line by an interpreter at run time. Solidity is compiled by solc into EVM bytecode.

Answer : In a statically typed language the type of every variable is known and checked at compile time. Solidity is statically typed, so type errors are reported by the compiler before the contract is deployed.

Answer : A function is a reusable block of code that performs a task. Its main parts are the name, the parameters (inputs), the body (statements) and the return values (outputs).

Answer : A parameter is an input passed into a function when it is called; a return value is the output the function sends back to the caller after it finishes.

Answer : Conditional statements such as if/else let a program choose which block of code to run depending on whether a condition is true or false.

Answer : Loops repeat a block of code while a condition remains true, avoiding duplicated code – for example adding up all the values in an array.

Answer : An array is an ordered collection of elements of the same data type, where each element is accessed by its index starting from 0.

Answer : A class is a blueprint that defines data (fields) and behaviour (methods); an object is a concrete instance created from that blueprint. In Solidity a contract plays the role of a class and a deployed contract instance plays the role of an object.

Answer : Inheritance lets a new (child) class reuse and extend the data and functions of an existing (parent) class. Solidity supports it with the is keyword, including multiple inheritance.

Answer : A smart contract is a program stored on a blockchain at a specific address. It contains data (state) and functions, and it executes exactly as written on every node of the network.

Answer : Gas is the unit that measures computational work on Ethereum. Every state-changing operation costs gas paid in Ether, so efficient code is cheaper for users and long loops can make a function too expensive to run.

Answer : Deployed contract code is immutable – it cannot simply be edited. Contracts often hold valuable assets, and bugs can be exploited by anyone, so mistakes are costly and hard to fix.

Answer : Solidity’s syntax was influenced mainly by C++, Python and JavaScript, so its curly-brace blocks, semicolons and operators look familiar to developers who know these languages.
MCQ Test : Check Your Understanding (5 questions)

Select an option and press Check Answer, or answer all questions and press Submit Test to see your score. Each answer comes with an explanation.

Q1. Solidity source code is converted into EVM bytecode by:

Show Answer

Correct Answer : B. The solc compiler
solc, the Solidity compiler, produces EVM bytecode and the ABI.

Q2. In Solidity, a contract is most similar to which OOP concept?

Show Answer

Correct Answer : C. Class
A contract groups state (data) and functions, like a class.

Q3. A statically typed language checks variable types:

Show Answer

Correct Answer : A. At compile time
Static typing means types are fixed and checked by the compiler.

Q4. Which statement about deployed smart-contract code is TRUE?

Show Answer

Correct Answer : D. It is immutable once deployed
Deployed bytecode cannot be changed; upgrades need special patterns.

Q5. 1 ether is equal to:

Show Answer

Correct Answer : C. 10^18 wei
wei is the smallest unit; 1 ether = 10^18 wei.

Bibliography/References

The notes, questions and MCQs on this page are original explanations written for this course. The works listed below were consulted and are cited for attribution and further reading. Product names, logos and trademarks belong to their respective owners. Short quotations, where used, are marked and attributed.

  1. Solidity Team. (n.d.). Solidity Documentation (latest). https://docs.soliditylang.org/en/latest/
  2. Solidity Team. (n.d.). Introduction to Smart Contracts. Solidity Documentation. https://docs.soliditylang.org/en/latest/introduction-to-smart-contracts.html
  3. ethereum.org. (n.d.). Introduction to smart contracts. Ethereum Developer Documentation. https://ethereum.org/en/developers/docs/smart-contracts/
  4. ethereum.org. (n.d.). Gas and fees. Ethereum Developer Documentation. https://ethereum.org/en/developers/docs/gas/
  5. Kernighan, B. W., & Ritchie, D. M. (1988). The C Programming Language (2nd ed.). Prentice Hall.
  6. Modi, R. (2018). Solidity Programming Essentials: A beginner’s guide to build smart contracts for Ethereum and blockchain. Packt Publishing. ISBN 978-1-78883-138-3.