Edexcel GCSE Computer Science Topic 7 Operators Operator

  • Slides: 5
Download presentation
Edexcel GCSE Computer Science Topic 7 - Operators

Edexcel GCSE Computer Science Topic 7 - Operators

Operator Arithmetic Operators Arithmetic operators take numerical values as the operands, and produce a

Operator Arithmetic Operators Arithmetic operators take numerical values as the operands, and produce a single numerical value. Operands (the data) • Addition (+) = sum of values e. g. x + y • Subtraction (-) = difference between values e. g. x - y • Division (/) = division of real numbers (those with fractional parts) so the result may be fractional e. g. x / y • Multiplication (*) = product of values e. g. x * y • Integer Division ( or sometimes //) = division in which the remainder is usually discarded, so your result is usually just the quotient e. g. x y • Modul 0 operation (% or MOD)= returns the remainder when one number is divided by another (so what integer division ‘discards’) e. g. x MOD y. Python examples:

Relational Operators These operations compare two operands to determine their relationship, and evaluate to

Relational Operators These operations compare two operands to determine their relationship, and evaluate to a Boolean value (True/ False or 0/1) Equal to, = or == Greater than, > Not equal to, ≠ or != or <> Less than or equal to, ≤ or <= Less than, < Greater than or equal to, ≥ or >= (Just a reminder so you don’t get tricked) When you multiply or divide both sides of an inequality by a negative number you have to reverse the sign:

Boolean Operators Boolean operators are used to manipulate True/ False values in Boolean algebra

Boolean Operators Boolean operators are used to manipulate True/ False values in Boolean algebra NOT = This reverses the input e. g. NOT False = True AND = This returns true if both conditions are true, else the result is false. E. g. Age > 11 AND Year > 2010 will be False if Year = 2009 OR = This returns true if either of the conditions are true. It will only return false if both conditions are false. E. g. True OR False = True