Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 118 - 2611_SmartGPT Pro V(5.0) C-6
P. 118

    Program 3. Write a program to calculate the average marks of three subjects.

                          Program3.py
                       File  Edit  Format   Run   Options  Window    Help

                       #Program to calculate the average marks of three subjects
                       Eng = float(input(" Enter English Marks: "))
                       Math = float(input(" Enter Math Marks: "))
                       Hindi = float(input(" Enter Hindi Marks: "))
                       avg=( Eng+ Math + Hindi)/3
                       print("Average is :", avg)

                      On running the above program, we get the following output:

                          Output
                       Enter English Marks: 90
                       Enter Math Marks: 95
                       Enter Hindi Marks: 80
                       Average is : 88.33333333333333

                                         Imagine, comments in Python are secret messages from a wise mentor. What advice
                                         or tips would you leave in your code for future programmers to discover?

                             Hashtag

                           #Python: Object-oriented high-level programming language
                           #IDLE: Stands for Integrated Development and Learning Environment

                            REVISIT

                        ▶   Interactive Mode and Script Mode are the two working mode in Python.
                        ▶   The input() function takes the user’s input while a program executes.
                        ▶   The print() function is used to display the content on the screen.
                        ▶   Variables are memory reference points where we store values which can be accessed or changed later.
                        ▶   A data type specifies the type of value a variable can contain.
                        ▶   Comments enable us to understand the way a program works.
                        ▶   Operators are special symbols which perform computation.

                       116  Computer Science (V5.0)-VI

| 113 114 115 116 117 118 119 120 121 122 123 |