Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 88 - 2606_PlugGPT_C6_Flipbook
P. 88

    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.

                       86   Premium Edition-VI

| 83 84 85 86 87 88 89 90 91 92 93 |