GoConqr has a new look! Let us know what you think.

Mind map

Programming Basics

Paul Lawrence English

Map content

Programming Basics

  1. Data Types

    • Programming languages have Five Main Data Types
    • Each data types is allocated to a different amount of memory
    • Using the correct data types makes code more memory more efficient, robust (hard to break) and predictable
    • Casting is used to change the Data Type
    • Languages have functions that let you manually convert between data types - this is known as casting. This can be done using the int() / float() / bool() / str() commands
      • int("1")
        • Converts the string "1" to the integer 1
      • float(1)
        • Converts the integer 1 to the float 1.0
      • bool(1)
        • Converts the integer 1 to the Boolean value True
      • str(True)
        • Converts the Boolean value True to the string "True"
    • It's important to realise that the integer 1, the real 1.0 and the strings "1" and "1.0" are all different
    • You can also find the ASCII number of characters and vice versa using ASC() and CHR() functions
      • ASC("b")
        • Converts the character "b" into its ASCII number 98
      • CHR(98)
        • Converts the ASCII number 98 into its equivalent character "b"
    • Using the Correct data types for different variables
  2. Strings

    • Strings are written inside Quotation Marks
      • Strings can be joined together to form new strings - this is called concatenation. It's often done using + operator
      • Strings are usually written inside double quotation marks ", but sometimes single quotes are used '.
    • Programs let you Manipulate Strings in a variety of ways
      • Characters in a string are usually numbered starting at zero
      • x.upper
        • Changes all characters in string x to upper case
          • HELLO
      • x.lower
        • Changes all characters in string x to lower case
          • hello
      • x.length
        • Returns the number of characters in string x
          • 5
      • x[i]
        • Extracts the character position I from string x
          • x[1] = e
      • x.subString(a,b)
        • Extracts a string starting at position a with length b from string x
          • x.subString(3,2) = lo
    • Example - An electricity company generates a customer's 7 character username from:
      • 1. the first 3 letters of their town as uppercase letters
        • 2. the customer's age when they sign up (2 digits)
          • 3. the first letter and last letters of the customer's surname as lowercase letters
    • Strings are a data type made up of characters
  3. Program Flow

    • IF statements usually have an IF-THEN-ELSE structure
      • IF statements allow you to check if a condition is true or false, and carry out different actions depending on the outcome. You can think about them as a flow diagram.
      • If there is nothing for the program to do when the condition is false, leave out the ELSE part.
    • Nested IF statements allow multiple outputs
      • More complex IF statements can be made by putting one IF statement inside another one - this type of selection statement is called a nested IF statement.
      • Nested IF statements allow you to check more conditions once you've established that the previous condition is true.
      • IF-ELSEIF statements can also be used to check multiple conditions. They are different from nested IF statements as they only check more conditions if the previous condition is false

Information

Description
Mind Map on Programming Basics, created by Paul Lawrence on 06/06/2019.
Created by
Paul Lawrence
Views
0
Rating

Feedback

What is it about?

What do you think of the new look?

How do you like it?