Page 76 - ModularV1.1 _c8_flipbook
P. 76
CREATING SIMPLE PYTHON PROGRAMS
Let’s write some simple programs using input( ) and print( ) statements and operators.
Example 1: To accept length and breadth of a rectangle from the user and calculate the area
and perimeter.
Program code Program output
Note: The int ( ) function used in this example, converts the user‘s input into integer data type
to calculate the area and perimeter of the rectangle.
Example 2: To find the amount to be paid.
Program code Program output
Example 3: To find the final wages of a worker.
Program code Program output
Recap
Python is a powerful, high-level, general-purpose, interpreted, interactive, multi-platform,
and object-oriented programming language.
The print( ) statement in Python is used to display text on the screen.
Python variables are memory locations used to store values.
Keywords are the reserved words in Python.
Data types decide which type of data is stored in the variables.
Operators are special symbols used to perform arithmetic or logical computations.
Comments are the text written inside the code that are ignored by the Python interpreter.
The input( ) statement is used to take the input from the user.
Variables are memory locations that are used to store values.
74 Modular (Ver. 1.1)-VIII

