Programming fundamentals & Data Types

Cards (47)

  • What type of loop is a for loop?
    Count controlled
  • What type of loop is a while loop?
    Condition controlled
  • Variable
    A memory location within a computer program where values are stored.
  • name= "John"
    What is 'name' an example of?
    A variable
  • Constant
    A constant allows a value to be assigned a name. Unlike a variable, the value assigned to a constant cannot be changed whilst the program is running.
  • Integer
    A whole number
  • Real/float
    A number with a decimal point
  • Char/Character
    A single character or symbol which can be typed
  • String
    Zero or more characters enclosed in quote marks e.g. "Hello"
  • Boolean
    Can only take the value True or False
  • Is == a comparison operator or arithmetic?
    Comparision
  • x= "Hello"
    print(x.upper)
    What does this print?
    HELLO
  • x= "Hello"
    print(x.lower)
    What does this print?
    hello
  • x= "Hello"
    print(x.length)
    What does this print?
    5
  • Sequence
    The statements are written one after the other and execution follows the this order
  • Selection
    Selection statements involve if statements
  • password = input("Please enter password: ")
    if password != "SP123" then
    print("Invalid password")
    endif
    What does this code do?
    Checks if the user has inputted the correct password and if not outputs "Invalid password"
  • Iteration
    The repetition of a block of statements within a computer program.
  • Casting
    A way of changing from one data type to another
  • x= 12
    x= str(x)
    What is this an example of and what will this do?
    Casting and it will change 12 from being an integer to being a string
  • x= "12"
    x= int(x)
    What is this an example of and what will this do?

    Casting and it will change 12 from being a string to being an integer
  • x=2.2
    What data type is x?
    Float/real
  • x=True
    What data type is x?
    Boolean
  • ==
    Equal to
  • !=
    Not equal to
  • <
    Less than
  • >
    More than
  • <=
    Less than or equal to
  • >
    Greater than
  • >=
    Great than or equal to
  • +
    Addition
  • -
    Subtraction
  • *
    Multiplication
  • /
    Division
  • MOD
    Modulus- returns the remainder when one integer is divided by another
  • 22 MOD 5
    What is the result?
    2
  • DIV
    Quotient- the result of the whole number without the remainder
  • 17 DIV 5
    What is the result?
    3
  • 17==17 AND 45>46
    What is the result?
    False
  • 17==17 OR 45>46
    What is the result?

    True