Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 82 - 2606_PlugGPT_C6_Flipbook
P. 82

    To do so, Python provides following functions:

                          int(): It is used to change the input data value into integer. For example,
                          a = int(input("Enter a number "))
                          Now, the entered value is converted into integer value.
                          float(): It is used to change the input value into floating-point value. For example,

                         a = float(input("Enter a number "))
                          Now, the entered value is converted into floating-point value.

                      THE print() FUNCTION
                      We use the print() function to display the result on the screen. The content is written within the
                      parenthesis. To get the output, follow the given steps:

                      Step  1   Open the Python Shell window.

                      Step  2    In front of the command prompt, type print("Hello Students") and press the Enter key.
                                Do not forget to include the double quotes (" ").
                      Step  3   The output is displayed in the next line in the same Python Shell window.

                           Tick ( ) if you know this.

                           ▶  Python is an interpreted language that executes code line by line.
                           ▶  The Python Shell window executes one command at a time.

                                VARIABLES IN PYTHON

                      A Variable is the name of the memory location that is used to store data values that can be
                      accessed or changed later. The names given to the variables are known as identifiers. In Python,
                      we do not need to specify the type of variable because Python is a dynamic language and it also
                      identifies the variable type automatically.

                      DECLARING AND INITIALISING A VARIABLE

                      In Python, variables are declared and initialised at the same time in the following way:
                      a = 10
                      b = 20
                      print ("+a=", a)
                      print ("b=", b)

                       80   Premium Edition-VI

| 77 78 79 80 81 82 83 84 85 86 87 |