Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 142 - 2609_Logicode
P. 142

    You will get the following output:

                          Output
                       Calculate Area for: Rectangle, Square, or Circle
                       Enter the name of the shape whose area you want to find: Circle
                       Enter the radius of the circle: 4.5
                       The area of the circle is:  63.585

                      Program 19: To access string characters
                          Program19.py
                       File  Edit  Format    Run   Options   Window    Help

                       #Accessing string characters in Python
                       str = 'Orange Education'
                       print('str = ', str)
                       print('str[0] = ', str[0])                  #First character
                       print('str[-1] = ', str[-1])                #Last character

                      You will get the following output:

                          Output

                       str =  Orange Education
                       str[0] =  O
                       str[-1] =  n

                      Program 20: To check whether the side of the triangle given by the user form a scalene, isosceles or
                      equilateral triangle

                          Program20.py
                       File  Edit  Format    Run   Options   Window    Help

                       #Program to check if a triangle is Equilateral, Isosceles or Scalene

                       A = 5
                       B = 6
                       C = 5

                       if (A == B == C):
                           print('Equilateral triangle')
                       elif (A == B) or (B == C) or (A == C):
                           print('Isosceles triangle')
                       else:
                           print('Scalene triangle')

                      140   Premium Edition-VIII

| 137 138 139 140 141 142 143 144 145 146 147 |