Back to 课程

Computer Science GCES EDEXCEL

0% Complete
0/0 Steps
  1. Decomposition And Abstraction Edexcel
    2 主题
  2. Algorithms Edexcel
    11 主题
  3. Truth Tables Edexcel
    3 主题
  4. Binary Edexcel
    6 主题
  5. Data Representation Edexcel
    4 主题
  6. Data Storage And Compression Edexcel
    2 主题
  7. Hardware Edexcel
    5 主题
  8. Software Edexcel
    3 主题
  9. Programming Languages Edexcel
    2 主题
  10. Networks Edexcel
    7 主题
  11. Network Security Edexcel
    2 主题
  12. Environmental Issues Edexcel
    1 主题
  13. Ethical And Legal Issues Edexcel
    3 主题
  14. Cybersecurity Edexcel
    2 主题
  15. Develop Code Edexcel
    6 主题
  16. Constructs Edexcel
    4 主题
  17. Data Types And Data Structures Edexcel
    5 主题
  18. Operators Edexcel
    1 主题
  19. Subprograms Edexcel
    2 主题
课 Progress
0% Complete

Exam code:1CP2

Variables, Constants & Assignments

What is a variable?

  • A variable is a named memory location that holds data that during the execution of a program, the data can change

  • Variables can store a variety of different types of data such as numbers, text or true/false values

  • To store data in a variable, the process of assignment is used

What is a constant?

  • A constant is fixed data that during the execution of a program cannot change

  • A constant can store a variety of different types of data, similar to variables

  • Pi is an example of a mathematical fixed value that would typically be stored as a constant

What is assignment?

  • Assignment is the process of storing data in a variable or constant under a descriptive name

  • Assignment is performed using the ‘=‘ symbol

Assigning variables & constants

Concept

Python

Variables

x = 3

name = "Save My Exams"

Constants

VAT = 0.2

PI = 3.142

Data Types

What is a data type?

  • A data type is a classification of data into groups according to the kind of data they represent

  • Computers use different data types to represent different types of data in a program

  • The basic data types include:

Data type

Used for

Example

Integer

Whole numbers

10, -5, 0

Real

Numbers with a fractional part

3.14, -2.5, 0.0

Character 

Single character

‘a’, ‘B’, ‘6’, ‘£’

String

Sequence of characters

“Hello world”, “ABC”, “@#!%”

Boolean

True or false values

True, False

  • It is important to choose the correct data type for a given situation to ensure accuracy and efficiency in the program

  • Data types can be changed within a program, this is called casting

Responses

您的邮箱地址不会被公开。 必填项已用 * 标注