Page 149 - CodePilot V5.0 C8
P. 149

21 st   #Critical Thinking
                      INTERDISCIPLINARY LEARNING                                          Century   #Technology Literacy
                                                                                           Skills

                   Create a Python program to find the HCF and LCM of two numbers using function.


                                                                                            mathematics








                     Write a Python program to find the          Approximately, 1.2% of all websites on the Internet
                    cube of any number using a function.         use Python as a server-side programming language.




                  RAPID RECALL                             Tick ( ) if you know this.



                     1.  A function is defined as a block of reusable code that performs a specific task.
                     2.  Every function definition must begin with the def keyword.








                        STRINGS

                 A group of characters enclosed in single or double or triple quotes is called a string in Python.

                 The characters can be alphabets, digits or symbols. The string is a basic Python data type used
                 for storing, manipulating and formatting text.


                 CREATING A SINGLE-LINE STRING
                 Single-line strings can be created by enclosing characters inside single or double quotes. It is
                 like assigning a value to a variable.


                  Program 3 A program to create and print a single-line string.


                      Program3.py                                                      Output
                   File  Edit  Format   Run   Options   Window    Help              Hello World

                  str = "Hello World"
                  print(str)












                                                                                                                  147
                                                                                            Step Ahead with Python
   144   145   146   147   148   149   150   151   152   153   154