Page 34 - 2501_KVS_C-7
P. 34

Example 2: Printing message

                  print("This is a Python Program.")     #  here  message  given  in  double
                                                                         quotes
                  You will get output as:

                  This is a Python Program.

                  Example 3: Printing value and message together

                  A=5

                  B=6
                  S=A+B
                  print("Sum of A and B is " , S)                            #  message  is  given  in  double
                                                                           quotes and variable S is printed
                                                                           afterwards.
                  You will get output as:

                  Sum of A and B is 11

                  3.1.4 Creating Simple Programs

                  Program 1:  Write a program to display           Code:
                  a message "Hello Friends, How are you?"          print("Hello Friends, How are you?")

                  Output: Hello Friends, How are you?

                  Program 2: To find area of a square,             Code:
                  if side of square is 5.
                                                                   side=5
                  Process: side*side                               Area=side*side
                  Output: Area of Square= 25                       print("Area of Square=",Area)


                  Program 3:  To find area of a rectangle,
                  if the length is 10 cm and the breadth is        Code:
                  6 cm.                                            Length, Breadth=10, 6
                                                                   Area=Length*Breadth
                  Process: Length* Breadth
                                                                   print("Area of Rectangle=",Area)
                  Output: Area of Rectangle= 60




                          Check Your Knowledge



                  A.    Answer the following questions:
                        1.   Write the steps required to create and run a Python program.

                        2.   What is the full form of IDLE?


                32                         KVS DELHI REGION 2025
   29   30   31   32   33   34   35   36   37   38   39