Download in
Google Play
19
Share
Save
Sign up
Access to all documents
Join milions of students
Improve your grades
By signing up you accept Terms of Service and Privacy Policy
Sign up
Access to all documents
Join milions of students
Improve your grades
By signing up you accept Terms of Service and Privacy Policy
Sign up
Access to all documents
Join milions of students
Improve your grades
By signing up you accept Terms of Service and Privacy Policy
Sign up
Access to all documents
Join milions of students
Improve your grades
By signing up you accept Terms of Service and Privacy Policy
Sign up
Access to all documents
Join milions of students
Improve your grades
By signing up you accept Terms of Service and Privacy Policy
charset="7php bloginfo( "viewport" content="width-de php up title( '/', true, 'right' rel"profile" href="http://gmpg.org/xfa/11 rela"pingback" href="<?php bloginfol pinghack ar e fruitful_get_favicon(); ?> lit it IE 9]><script src="<?php echo pet template ho wp_head(); ?> ody <?php body_class(); ?>> <div id="page-header" class="hfeed sites <?php $theme_options = fruitful get the commi $logo_pos= $menu_pos= if (isset($theme_options['no $logo_pos= esc_attrist 2.1.2 Programming Fundamentals fruit if (isset($theme options menu posesc attri Computing MOC Constants and Variables Data can either be stored as a constant or a variable. The name of the constant or variable is linked to a memory location that stores the data value. A constant <-> A data value that can't be changed, usually assigned to at the start of a program A variable <-> A data value that can be changed at any time Assigning constants You might have to assign to a constant using code (something like const SIZE = 40 depending on the language you're using). It is good practice to assign constants in all upper-case Operators Programming languages have different types of operator to assign, compare and do arithmetic between different variables. Assignment Operator There is one assignment variable, that is used to assign values to constants or variables. For example: name = "Gregg" favorite food = "Cheese" age = 34 Comparison Operators Comparison operators compare one value to another Operator Meaning != < V <= >= Is equal to Is not equal to Is less than Is greater than Is less than or equal to Is greater than or equal to = and == Don't get...
iOS User
Stefan S, iOS User
SuSSan, iOS User
mixed up between = and == operators, one will assign a value, and one will check if the value is true Function Addition Arithmetic Operators Arithmetic operators take two values and perform a maths function on them Subtraction Multiplication Division Exponentiation Quotient Remainder Operator + * ^ DIV MOD or % These operators can work on integers or real data values, or a combination of the two. Computers will always use BIDMAS, so make sure to use operators in the right order, or use brackets so it does the right program. Boolean Operators Boolean operators are used in 2.4.1 Boolean logic and there are three we need to know: Boolean operator AND OR NOT && || For example: ! Example that returns true 3<5 AND 2>1 1>8 OR 2 ==2 NOT (5>8 You can combine Boolean operators, but you must use brackets so the computer knows what part to do first Program Flow Sequence Sequence -> executing each instruction once in the order its given in a program name = input "What is your name? >>>" print("Hello + "+name+" , my name is Andy") This program is executed in order Selection Sometimes, you don't want to execute all your code at once. You may need the program to select what top execute at different times. We use conditional statements to test a variable against another and see what to execute. For example, this flow chart shows selection: Start Print "Access granted." True if x == "GO" else: Input x X == "GO"? Stop False x = input "Please input the special word >>>" "Access denied." print "Correct, access granted" print "Incorrect, access denied" Print In this example, there are two bits of code the program could print, depending on user input. You can nest if statements to make more complex programs and more outputs. Or you can use else if statements to make more checks on a condition. For loops For loops will repeat code inside them for a fixed number of times for k = 1 to 100: # this will repeat 100 times print k next k Or you can use them to iterate over lists, like in python list = ["Mouse", "Keyboard", "Monitor" for item in list. print item # This will print each item in the list While Loops While Loops continue until an condition is met Is the condition true? Yes Part of the program to repeat No
19
Share
Save
Reuben Cowell
75 Followers
my notes on programming fundamentals
75 Followers
0
OCR Computer Science Paper 2 GCSE
4
Learn about Bubble, Insertion, and Merge sort algorithms, their advantages, disadvantages, and examples. Understand how each sort works for exam preparation.
86
computer science notes ocr
4
Print statements,data types,comments,variables (will be doing more soon !!)
0
notes for everything we need to know for the nat 5 computing science exam in the software section(from achieve and from my class notes)
43
This guide and summary of python will allow you to understand the basics of python coding and allow you to do basic coding which you can then develop into advanced coding
charset="7php bloginfo( "viewport" content="width-de php up title( '/', true, 'right' rel"profile" href="http://gmpg.org/xfa/11 rela"pingback" href="<?php bloginfol pinghack ar e fruitful_get_favicon(); ?> lit it IE 9]><script src="<?php echo pet template ho wp_head(); ?> ody <?php body_class(); ?>> <div id="page-header" class="hfeed sites <?php $theme_options = fruitful get the commi $logo_pos= $menu_pos= if (isset($theme_options['no $logo_pos= esc_attrist 2.1.2 Programming Fundamentals fruit if (isset($theme options menu posesc attri Computing MOC Constants and Variables Data can either be stored as a constant or a variable. The name of the constant or variable is linked to a memory location that stores the data value. A constant <-> A data value that can't be changed, usually assigned to at the start of a program A variable <-> A data value that can be changed at any time Assigning constants You might have to assign to a constant using code (something like const SIZE = 40 depending on the language you're using). It is good practice to assign constants in all upper-case Operators Programming languages have different types of operator to assign, compare and do arithmetic between different variables. Assignment Operator There is one assignment variable, that is used to assign values to constants or variables. For example: name = "Gregg" favorite food = "Cheese" age = 34 Comparison Operators Comparison operators compare one value to another Operator Meaning != < V <= >= Is equal to Is not equal to Is less than Is greater than Is less than or equal to Is greater than or equal to = and == Don't get...
charset="7php bloginfo( "viewport" content="width-de php up title( '/', true, 'right' rel"profile" href="http://gmpg.org/xfa/11 rela"pingback" href="<?php bloginfol pinghack ar e fruitful_get_favicon(); ?> lit it IE 9]><script src="<?php echo pet template ho wp_head(); ?> ody <?php body_class(); ?>> <div id="page-header" class="hfeed sites <?php $theme_options = fruitful get the commi $logo_pos= $menu_pos= if (isset($theme_options['no $logo_pos= esc_attrist 2.1.2 Programming Fundamentals fruit if (isset($theme options menu posesc attri Computing MOC Constants and Variables Data can either be stored as a constant or a variable. The name of the constant or variable is linked to a memory location that stores the data value. A constant <-> A data value that can't be changed, usually assigned to at the start of a program A variable <-> A data value that can be changed at any time Assigning constants You might have to assign to a constant using code (something like const SIZE = 40 depending on the language you're using). It is good practice to assign constants in all upper-case Operators Programming languages have different types of operator to assign, compare and do arithmetic between different variables. Assignment Operator There is one assignment variable, that is used to assign values to constants or variables. For example: name = "Gregg" favorite food = "Cheese" age = 34 Comparison Operators Comparison operators compare one value to another Operator Meaning != < V <= >= Is equal to Is not equal to Is less than Is greater than Is less than or equal to Is greater than or equal to = and == Don't get...
iOS User
Stefan S, iOS User
SuSSan, iOS User
mixed up between = and == operators, one will assign a value, and one will check if the value is true Function Addition Arithmetic Operators Arithmetic operators take two values and perform a maths function on them Subtraction Multiplication Division Exponentiation Quotient Remainder Operator + * ^ DIV MOD or % These operators can work on integers or real data values, or a combination of the two. Computers will always use BIDMAS, so make sure to use operators in the right order, or use brackets so it does the right program. Boolean Operators Boolean operators are used in 2.4.1 Boolean logic and there are three we need to know: Boolean operator AND OR NOT && || For example: ! Example that returns true 3<5 AND 2>1 1>8 OR 2 ==2 NOT (5>8 You can combine Boolean operators, but you must use brackets so the computer knows what part to do first Program Flow Sequence Sequence -> executing each instruction once in the order its given in a program name = input "What is your name? >>>" print("Hello + "+name+" , my name is Andy") This program is executed in order Selection Sometimes, you don't want to execute all your code at once. You may need the program to select what top execute at different times. We use conditional statements to test a variable against another and see what to execute. For example, this flow chart shows selection: Start Print "Access granted." True if x == "GO" else: Input x X == "GO"? Stop False x = input "Please input the special word >>>" "Access denied." print "Correct, access granted" print "Incorrect, access denied" Print In this example, there are two bits of code the program could print, depending on user input. You can nest if statements to make more complex programs and more outputs. Or you can use else if statements to make more checks on a condition. For loops For loops will repeat code inside them for a fixed number of times for k = 1 to 100: # this will repeat 100 times print k next k Or you can use them to iterate over lists, like in python list = ["Mouse", "Keyboard", "Monitor" for item in list. print item # This will print each item in the list While Loops While Loops continue until an condition is met Is the condition true? Yes Part of the program to repeat No