Page 14 - tp_Modula_v2.0
P. 14

The general syntax of the print( ) function is as follows:

                  print [<expression 1> , <expression 2>...]

                  For example:

                  print("Python is easy")

                  Let's create a program to use the input( ) and print( ) functions.

                      Program1.py
                   File  Edit  Format   Run   Options  Window    Help
                   age = input("Enter your age: ")
                   name = input("Enter your name: ")
                   print(name, "Your age is", age)




                                                              Using input( )
                      Output

                   Enter your age: 15
                   Enter your name: Ankit
                   Ankit Your age is 15





                                                             print( ) functions
                      VARIABLES IN PYTHON


                  Variables  are  memory  reference points  where  we  store  values  which  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 dynamically typed language and

                  it identifies the variable type automatically. Let’s understand this with the help of the given
                  examples.

                      num = 0.4

                      _price = 30.3
                      TOTAL = round(_price * num,2)
                      print(TOTAL)

                  Declaring and Initializing a Variable


                  In Python, variables are declared and initialized at the same time in the following way:
                    a = 10

                    b = 20




                   12     Touchpad MODULAR (Version 2.0)
   9   10   11   12   13   14   15   16   17   18   19