Page 95 - 2502_Pakistan-kifayat_C-8
P. 95

Double Tap                                                      Century   #Technology Literacy
                                                                                            21 st
                                                                                               #Critical Thinking
                                                                                           Skills
                        Guess! who am I?

                        1.  I join two Boolean blocks together and give one combined result.
                        2.   I check a condition and run one set of blocks if it is true, and another set if it is false.



                        3.   I return the opposite of a Boolean value, flipping true to false and false to true.




                      UNDERSTANDING FUNCTIONS


                 In programming, a function is a set of instructions grouped together to do a specific task. In Scratch,
                 functions are called My Blocks. These help you reuse code easily without writing it again and again.

                 Benefits of Functions in Programming

                 The following are the advantages of functions:

                     Functions help programmers store a set of instructions that can be used again and again by simply
                   calling the function.
                     Functions help avoid writing the same code repeatedly.

                 How to Create a Function in Scratch

                 To create a function in Scratch, use the following steps:





                       2   Click on the Make                                                Enter a name for
                           a Block button.                                                                       3
                                                                                            your custom block.



















                         1   Click on the My
                             Blocks category.
                                                                                        4
                                                                                            Click on OK button.

                 The define block name block will appear in the scripting area.



                                                                                     #Intermediate Level Programming  93
   90   91   92   93   94   95   96   97   98   99   100