Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 147 - CodePilot V5.0 C6
P. 147

    Output

                       Enter the first number: 13
                       Enter the second number: 17
                       Enter the third number: 21
                       The average of the three numbers is: 17.0

                      Program 10     To calculate the cube of a number.

                          Program10.py
                       File  Edit  Format   Run   Options   Window    Help

                       num = float(input("Enter a number: "))
                       print("The cube of a number is:", num ** 3)

                          Output

                       Enter a number: 8
                       The cube of a number is: 512.0

                     TECH
                       T       ¢   Function: A reusable block of code that performs a specific task.
                       E
                       R       ¢   Library: A collection  of pre-written code,  including  functions  and modules,  that  helps
                       M          perform common tasks without writing code from scratch.
                       S

                     REWIND RUN

                     «   Python is a simple, powerful and versatile language with many applications.

                     «   Shell Mode allows you to execute Python code interactively.
                     «   Script Mode is used for writing longer Python programs that can be saved to your computer and run later.
                     «   The input() function is used to take input from the user.
                     «   The print() function is used to display output on the screen in Python.
                     «   A character set is the collection of characters a programming language recognises.
                     «   Keywords are reserved words with special meanings in Python.

                     «   An identifier is a name used to uniquely identify a variable, function, class or object in Python.
                     «   Operators are symbols that perform mathematical, logical or relational operations on values called
                        operands.

                                                                                                                      145
                                                                                                  Python–Start to Code

| 142 143 144 145 146 147 148 149 150 151 152 |