We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2
VARIABLES: o Common operations: Addition,
DEFINITION: A named storage location subtraction, multiplication, division,
in computer memory that can hold modulus different values during program Floating point or Real: execution. o Definition: Numbers with decimal PURPOSE: To store and manipulate data points in a program. o Examples: 3.14, -0.5, 2.0 CHARACTERISTICS: o Common operations: Same as o Can change value during program integers, but may introduce execution rounding errors o Have a specific data type String: o Must be declared before use in o Definition: A sequence of many programming languages characters NAMING CONVENTIONS: o Representation: Usually enclosed in o Usually start with a letter or single or double quotes underscore o Examples: "Hello, World!", '42', o Can contain letters, numbers, and "Python Programming" underscores o Common operations: o Are case-sensitive in most Concatenation, slicing, length languages calculation, searching o Should be descriptive and follow Boolean: camelCase or snake_case o Definition: A data type with only ASSIGNMENT AND REASSIGNMENT: two possible values: True or False o Use of assignment operator (often o Use cases: Conditional statements, '=') flags, logic operations o Examples of initial assignment and o Representation: Often as 1 (True) value changes and 0 (False) in memory o Common operations: AND, OR, NOT CONSTANTS: DEFINITION: A named storage location IMPORTANCE OF DATA TYPES: in computer memory that holds a fixed Memory allocation: value that cannot be changed during o Different data types require program execution. different amounts of memory PURPOSE: To store values that should o Efficient use of memory improves remain unchanged throughout the program performance program. Operation behavior: WHEN TO USE CONSTANTS: o Data types determine how o For mathematical constants (e.g., operations are performed pi,) o Example: Integer division vs. o For configuration values (e.g., floating point or Real division maximum number of attempts) Type checking and error prevention: o To improve code readability and o Helps catch errors early in maintainability development NAMING CONVENTIONS: o Prevents unintended operations o Often in ALL_CAPS to distinguish (e.g., adding a string to an integer) from variables Code readability and maintainability: o May use underscores for multi- o Clearly defined data types make word names (e.g., MAX_ATTEMPTS) code easier to understand and modify DATA TYPES: Integer: DECLARING VARIABLES AND o Definition: Whole numbers without CONSTANTS: decimal points Examples of declarations and o Examples: -3, 0, 42 assignments: o Integer: age = 25 o Floating point or Real: pi = o Boolean: is_student = True 3.14159 o Constant: MAX_ATTEMPTS = 3 o String: name = "John Doe"