1.4.1
Variables & Constants
Variables and Constants
Variables and Constants
Variables and constants allow us to store results in the main store.
![Illustrative background for Variables](https://image-v2.cdn.app.senecalearning.com/2018-07/050c73a9-e0c2-4651-b3f6-54dd46acdf0d/RAM-Random-Access-Memory-Computer-,h_400,q_80,w_640.jpg)
![Illustrative background for Variables ?? "content](https://image-v2.cdn.app.senecalearning.com/2018-07/050c73a9-e0c2-4651-b3f6-54dd46acdf0d/RAM-Random-Access-Memory-Computer-,h_400,q_80,w_640.jpg)
Variables
Variables
- Variables are named spaces in the memory where data can be stored.
- The value of a variable is the data stored inside it.
- The value can change whilst the program is running.
![Illustrative background for Constants](https://image-v2.cdn.app.senecalearning.com/2018-09/3fbc1670-5cce-406e-9b07-7d05f1b9aabc/motherboard,h_400,q_80,w_640.png)
![Illustrative background for Constants ?? "content](https://image-v2.cdn.app.senecalearning.com/2018-09/3fbc1670-5cce-406e-9b07-7d05f1b9aabc/motherboard,h_400,q_80,w_640.png)
Constants
Constants
- Constants are similar to variables, but the value cannot change whilst the program is running.
- Constants make the code easier to read.
![Illustrative background for Assignment](https://image-v2.cdn.app.senecalearning.com/courseImages/physics/AQA New Modules/1.3.1/chalk board equals sign,h_400,q_80,w_640.jpg)
![Illustrative background for Assignment ?? "content](https://image-v2.cdn.app.senecalearning.com/courseImages/physics/AQA New Modules/1.3.1/chalk board equals sign,h_400,q_80,w_640.jpg)
Assignment
Assignment
- To use a variable, we give it a name and a value. For example:
- x = 50
- We can then use this variable in other expressions by using its identifier (name).
1Introduction to Python
1.1Python
1.2Input & Output
1.3Data Types
1.4Variables & Constants
1.6Program Flow
2Data Structures
2.1Lists & Strings
2.2File Handling
3Modularity
3.1Subroutines
3.2Data Flow
4Good Practice
4.1Naming & Whitespace
4.2Comments
4.3Exceptions
Jump to other topics
1Introduction to Python
1.1Python
1.2Input & Output
1.3Data Types
1.4Variables & Constants
1.6Program Flow
2Data Structures
2.1Lists & Strings
2.2File Handling
3Modularity
3.1Subroutines
3.2Data Flow
4Good Practice
4.1Naming & Whitespace
4.2Comments
4.3Exceptions
![Go student ad image](/en-GB/revision-notes/_next/image?url=%2Fen-GB%2Frevision-notes%2Fimages%2Fgo-student-uk-ad.jpg&w=640&q=100)
Unlock your full potential with GoStudent tutoring
Affordable 1:1 tutoring from the comfort of your home
Tutors are matched to your specific learning needs
30+ school subjects covered