Programming Methodology

This page contains the CBSE Computer Science with Python class 11 Unit-2 chapter 2 Programming Methodology. You can find the solutions for chapter 2 of CBSE class 11 Computer Science with Python Exercise. So is the case if you are looking for CBSE class 11 Computer Science with Python related topic Programming Methodology questions and answers for the Exercise.
Multiple choice questions.
Question 1
1. User Define name.
(a)
Identifier ✔
(b)
constant
(c)
syntax
(d)
expression
Answer 1
Correct option: (a) Identifier.
A user-defined name in programming is called an identifier, so this choice correctly names user-defined entities like variables and functions.
Question 2
2. If we overcome the rules of the programming language, we get
(a)
Runtime error
(b)
Syntax error ✔
(c)
logical error
(d)
None of the above.
Answer 2
Correct option: (b) Syntax error.
Breaking the grammar rules of a programming language produces a syntax error, so option (b) is correct.
Question 3
3. Correcting the program code:
(a)
Testing
(b)
Syntax error
(c)
Runtime error
(d)
Debugging ✔
Answer 3
Correct option: (d) Debugging.
Correcting program code is called debugging because it involves finding and removing errors.
Question 4
4. Designing the problem
(a)
Testing
(b)
Debugging
(c)
logical error
(d)
Algorithm ✔
Answer 4
Correct option: (d) Algorithm.
Designing a problem means planning clear step-by-step logic, which is exactly what an algorithm provides.
Question 5
5. Algorithm when translated into a programming language is called
(a)
Flowchart
(b)
Identifier
(c)
Code ✔
(d)
Debugging
Answer 5
Correct option: (c) Code.
When an algorithm is written in a programming language, it becomes program code, so option (c) is correct.
Question 6
6. The program must be able to handle unexpected situation like wrong input or no
(a)
Error
(b)
Expression
(c)
Portability
(d)
Reliability ✔
Answer 6
Correct option: (d) Reliability.
Handling unexpected or missing input is a reliability feature, so reliability is the right choice.
Question 7
7. Leading white space at the beginning of each statement, which is used to
(a)
Testing
(b)
Indentation ✔
(c)
Debugging
(d)
None of the above
Answer 7
Correct option: (b) Indentation.
Leading whitespace that groups statements into blocks is called indentation, especially in Python.
Question 8
8. It refers to the ability of an application to run on different platforms with or
(a)
Error
(b)
Flexibility
(c)
Portability ✔
(d)
Reliability
Answer 8
Correct option: (c) Portability.
Running an application across different platforms with minimal changes refers to portability.
Question 9
9. It is a combination of Operators, Operands and Constants.
(a)
Identifier
(b)
Expression ✔
(c)
Syntax
(d)
Task
Answer 9
Correct option: (b) Expression.
A combination of operators, operands, and constants forms an expression that evaluates to a value.
Question 10
10. Each module should also be divided into sub modules according to software
(a)
Top down method ✔
(b)
Bottom up method
(c)
Coding
(d)
None of the above
Answer 10
Correct option: (a) Top down method.
Dividing each module into smaller submodules follows the top-down method of program design.
Answer the following questions.
Question 1
1. What is a good program?
Answer 1
A good program is one that is easy to use, easy to understand, reliable, portable, and properly documented. It should solve the given problem correctly and should interact with the user through clear and meaningful messages. A user should be able to enter input easily and understand the output without confusion.
A good program should also be portable, which means it should run on different computer systems with little or no change. It should be reliable, that is, it should work correctly and handle unexpected situations such as wrong input or no input. In addition, a good program should be self-documenting, which means meaningful names should be used for variables, methods, and other parts of the program so that the code is easier to read and understand.
Thus, a good program is not only one that gives the correct output, but also one that is user friendly, dependable, and easy to maintain.
Question 2
2. What is an identifier?
Answer 2
An identifier is a user-defined name given to different elements of a program, such as variables, functions, methods, classes, etc. It is used to identify these items in the program and refer to them whenever needed. In simple words, an identifier is the name created by the programmer for use in the code.
Identifiers help in making the program organized and readable. If meaningful names are used, the purpose of a variable or function becomes easier to understand. For example, names like totalMarks, sum, or findArea are better identifiers because they clearly indicate their use.
Thus, an identifier is an important part of programming because it gives a proper name to program elements and helps in writing clear and understandable code.
Question 3
3. How to write comments in a program?
Answer 3
Comments are notes written in a program to make the code easier to read and understand. As a program becomes longer, it may become difficult to understand what each part is doing. Therefore, comments are added to explain the purpose of statements or sections of the program.
In Python, a comment starts with the # symbol. Anything written after # on the same line is ignored by the interpreter, so it does not affect the execution of the program. A comment may be written on a separate line, or it may also be written at the end of a statement.
Example:
# Calculating area of a square
area = side ** 2   # formula for area
Thus, comments are very useful because they make the program clearer, easier to understand, and easier to maintain.
Question 4
4. What is the purpose of expression? Explain with an example.
Answer 4
An expression is a combination of operators, operands, and constants. Its main purpose is to perform a calculation or evaluation and produce one final value. In a program, expressions are used whenever some value has to be computed before it is stored, displayed, or used in another statement.
The value of an expression is obtained according to the precedence of operators. Operators with higher precedence are evaluated first. If operators have the same precedence, then associativity decides the order of evaluation.
Example:
9 + 4 + 2
In this expression, first 9 + 4 is evaluated, which gives 13. After that, 13 + 2 is evaluated, which gives 15. So, the complete expression gives a single result, that is 15.
Thus, the purpose of an expression is to combine values and operators in order to obtain a meaningful result needed in the program.
Question 5
5. Write and explain all steps of programming methodology.
Answer 5
Programming methodology is the proper step-by-step process followed to develop a correct program. The problem solving process starts with the problem specification and ends with a concrete and correct program. This process consists of four main steps.
The steps are as follows:
1.
Designing the problem (Algorithm)

In this step, the problem is studied carefully and the solution is planned in a logical way. An algorithm is prepared so that the steps needed to solve the problem become clear. This helps in understanding the problem before writing the actual program.
2.
Coding

After the solution is designed, the algorithm is translated into a programming language. This written form of the solution is called code. In this step, the programmer writes the instructions in the proper syntax of the language.
3.
Debugging

After coding, the program may contain errors. The process of finding and correcting these errors is called debugging. It helps in making the program free from mistakes so that it can run properly.
4.
Testing

In this step, the program is run and checked with different inputs to see whether it gives the correct output. Testing is done to make sure that the program works properly in different situations and solves the problem correctly.
Thus, the steps of programming methodology are designing, coding, debugging, and testing. These steps make program development more systematic, clear, and reliable.
Question 6
6. Differentiate between runtime errors and logical errors.
Answer 6
Basis
Runtime Errors
Logical Errors
Meaning
These are errors that occur during the execution of a program.
These are errors in the logic or design of a program.
Effect on program
The program may stop suddenly or terminate abnormally.
The program usually runs successfully, but gives the wrong output.
Cause
They are caused by illegal operations while the program is running.
They are caused by using the wrong formula, wrong condition, or wrong sequence of steps.
Detection
They are noticed only when the program is executed.
They are harder to detect because no error message may be shown.
Example
Division by zero or trying to open a file that does not exist.
Using an incorrect condition in a loop or a wrong calculation formula.
A runtime error occurs when the program is running and the computer is unable to continue a particular operation. In such a case, the program may stop and display an error message. For example, if a program tries to divide a number by zero, a runtime error occurs.
A logical error, on the other hand, occurs when the programmer makes a mistake in the logic of the program. The program may execute without stopping, but the result produced will be incorrect. For example, if the wrong formula is used to find the area of a triangle, the program will run but the answer will be wrong.
Thus, runtime errors affect the execution of the program, whereas logical errors affect the correctness of the output.
Question 7
7. Define documentation.
Answer 7
Documentation means the written details related to a program. It includes all the important information that helps in understanding, using, and maintaining the program properly. Documentation is an essential part of program development because it provides a clear record of how the program was designed and how it should be used.
It may include the problem definition, design details, description of tests performed, history of program development, different versions of the program, and the user manual. These details are useful not only for the programmer, but also for other users or developers who may work with the program later.
Thus, documentation helps in making a program easier to understand, operate, and maintain.
Question 8
8. What is program maintenance?
Answer 8
Program maintenance means all the activities that are performed after a program starts operating. Even after a program has been written and put into use, some work may still be needed to keep it working properly. Therefore, program maintenance is an important stage in the life of a program.
It includes tasks such as finding and removing hidden errors, improving the performance of the program, making changes to suit new hardware or operating systems, adding new features, and updating the documentation. These changes help the program remain useful and correct over time.
Thus, program maintenance is the process of keeping a program updated, efficient, and suitable for future use.
Question 9
9. Define modular programming.
Answer 9
Modular programming is a method of program development in which a large program is divided into smaller parts called modules. Each module is designed to perform a particular task, and together all the modules make up the complete program.
This method makes a program easier to understand, write, test, and maintain. Instead of handling one large and complex program at once, the work is divided into smaller manageable parts. If there is an error, it becomes easier to find and correct it in a specific module.
A module can also be divided further into sub-modules when needed. Thus, modular programming helps in making the program more organized, systematic, and easier to manage.
Question 10
10. Differentiate between top down and bottom up methods of modular
programming.
Answer 10
Basis
Top Down Method
Bottom Up Method
Approach
The program is developed by starting from the main problem and dividing it into smaller modules.
The program is developed by starting from small individual modules and then combining them to form the complete program.
Direction of development
It moves from higher level to lower level.
It moves from lower level to higher level.
Focus
It focuses first on the overall structure and main logic of the program.
It focuses first on building small reusable parts.
Module design
Each main module can be divided further into sub-modules.
Small modules are created first and then linked together.
Usefulness
It is useful when the complete problem is understood clearly from the beginning.
It is useful when small parts can be developed and tested independently first.
In the top down method, the programmer first looks at the whole problem and then breaks it into smaller and smaller modules. This makes the solution more systematic and organized. In the bottom up method, the programmer starts by creating small modules first and then combines them to build the complete solution.
Thus, the main difference is that top down starts from the whole and moves to parts, while bottom up starts from parts and builds the whole.
Question 11
11. Explain types of errors with examples.
Answer 11
There are three main types of errors that generally occur during the compilation or execution of a program. These are:
1.
Syntax Error
2.
Logical Error
3.
Runtime Error
1) Syntax Error
A syntax error occurs when the rules of the programming language are not followed. Every programming language has its own syntax, and if a statement is written in the wrong form, the program shows a syntax error. Such errors are usually detected at compilation time.
Example:
If a while statement is written without a colon :, it will produce a syntax error.
while a < 10 ← incorrect because : is missing
2) Logical Error
A logical error is an error made by the programmer in the logic of the program. In this case, the program may run, but it gives an incorrect or unexpected result. Such errors are often difficult to find because the program may not show an error message.
Example:
If the wrong formula is used to calculate the area of a triangle, the program will execute, but the answer will be wrong.
3) Runtime Error
A runtime error occurs during the running time of the program and may cause the program to stop abnormally. These errors appear only when the program is executed.
Examples:
Division by zero
A = 10, B = 0, then print A/B will cause a runtime error.
Trying to open a file that does not exist on the hard disk also causes a runtime error.
Thus, syntax errors are related to language rules, logical errors are related to wrong program logic, and runtime errors occur while the program is being executed.
Question 12
12. How to maintain programs?
Answer 12
Programs are maintained by carrying out the activities included in program maintenance after the program starts operating. Even after a program has been developed and put into use, changes may still be required to keep it working properly and efficiently. Therefore, regular maintenance is necessary for the smooth and continued use of the program.
A program can be maintained in the following ways:
Finding and removing hidden or previously undetected errors
Improving the performance of the current program
Modifying the program to suit new hardware or operating systems
Adding new features or improving the user interface
Updating the documentation regularly so that the program details remain clear and current
Thus, programs are maintained by making necessary corrections, improvements, and updates from time to time so that they remain useful, accurate, and suitable for future needs.