0% found this document useful (0 votes)
1 views10 pages

Unit 1 Notes

The document provides an overview of problem-solving concepts, programming, and Python programming, detailing steps in problem-solving, types of problems, and the role of computers in problem-solving. It discusses modularization, design approaches, and the software development life cycle (SDLC), along with features and history of Python. The document emphasizes the importance of clear problem definition and structured methodologies in programming and problem-solving processes.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views10 pages

Unit 1 Notes

The document provides an overview of problem-solving concepts, programming, and Python programming, detailing steps in problem-solving, types of problems, and the role of computers in problem-solving. It discusses modularization, design approaches, and the software development life cycle (SDLC), along with features and history of Python. The document emphasizes the importance of clear problem definition and structured methodologies in programming and problem-solving processes.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Programming and Problem Solving

Unit- 1 Notes

Unit I: Problem Solving, Programming and Python Programming

1.1General Problem Solving Concepts

1.1.1 Problem Solving in Everyday Life:

Q.1. Define Problem. What are steps in problem solving?


Definition of problem
Problem is defined as a situation or issue or condition which needs to be solve
to achieve a specific goal.
Steps in problem solving
1. Identify the problem - You need to be clear about what exactly the problem
is. If the problem is not identified then it cannot be solved. example- when
you want to learn a language then first identify which language do you want to
learn
2. Understand the problem - Here problem should be defined properly so that
it helps in understanding the problem more. It helps to understand knowledge
base of the problem. It helps in finding a target for what you want to achieve.
3. Identify alternative ways to solve the problem - This step is very crucial
because until and unless we explore all options, finding a correct solution is
next to possible. This involves the process to create a list of solutions.
4. Select the best way to solve the problem - Identify and evaluate pros and
cons of each possible solution and then select the best solution. Selecting
proper way from alternatives require a lot of study and need to study con
sequences as well.
5. List instructions that enable you to solve the problem using
selected solution - Here we need to list out the steps which should be
followed so that anyone can solve the problem. This should be in detail
and precise at the same time.
6. Evaluate the solution - It mean to test the solution and check if the
result is satisfactory or not.
Example: I am always late for college
(i) Identification: getting late for college.
(ii) Understanding: (List out probable reasons of or getting late)
(Sleeping late, waking up late, Transportation, etc.)
(iii) List out alternative ways – (Solutions)
(a). Sleeping early at home.
(b). Waking up early.
(c). Waking alarm.
(d). Resolving travelling issue.
(iv) Select the best way – Sleeping early in night.
(v) List out the procedure
(a). Having dinner as early as possible.
(b). Avoid use of mobile phones in night.
(c). Completing homework as early as possible. (d). Then going early to
bed. (vi) Evaluate the solution: Reached College on time.

1.1.2 Types of problems:

Q. 2. Explain types of problems in detail?


Ans:
Problem can be categorized into two types depending on how the solution is found out or
the approach which is followed to get that solution.
(i) Algorithmic solution
(a) These problems are solved by following some procedure or steps. (b) For
example: baking a cake. It can be done by following a series of instruction And
we can expect results.
(c) Here following some predefined process needs to be done.
(d) Here solution is quite straight forward.
(ii) Heuristic solution
(a) These types of problems solved using knowledge based i.e. by collecting
information about the problem.
(b) For example: Expanding one’s business.
(c) In this type of approach there is no straight forward defined path which we can
follow to solve a problem.
(d) We need to build that path based on trial and error.
(e) In this approach experience and knowledge is very important.

1.1.3 Problem Solving with computers:

Q. 3. Write a note on Problem solving with computers.


Ans: Computer is a multi-purpose electronic machine which is used for storing,
organizing and processing the data.
Computer is not able to find the solution by itself; rather the computer is a machine
which follows the instruction given by programmer to solve any problem. So all the
efforts required to understand the problem and define procedure to solve that problem are
taken by programmer ( a human being).

Problem Definition:
Before a program is written for solving a problem, it is important to define the
problem clearly.
Define problem: Problem is defined as a situation or issue or condition
which needs to solve to achieve the goal.
For most of the software projects, the system analyst approach system
users to collect user requirements and define the problem that the system
aims to solve.
System analyst typically looks at following issues:
o What input is required for achieving expected output?
o Expected output of the problem.
o Current method of solving the problem.
o Can the problem or part of the problem be more effectively solved by a
software solution?
o Computers are built to deal with algorithmic solutions, which are often
difficult or very time consuming for humans.

Solution:
o Solution means the instructions listed during problem solving – the instructions
that must be followed to produce the best results.
o The result may be: More efficient, faster, more understandable or reusable.
Results:
o The result is outcome or the completed computer assisted answer. o May
take any form: Printout, updated files, output to monitor speakers, etc. Program:
o Program is the set of instructions that make up the solution after they have been
coded into a particular computer language.

1.1.4 Difficulties with problem solving:

Q.4. Explain the difficulties with Problem solving?


Ans:
o Some people may not have got training regarding how to solve problems. o
Some may not able to make a decision for fear it will not be the correct one. o
There may be inaccuracy in defining the problem correctly or may not generate the
sufficient list of alternatives.
o While selecting best alternative, they may skip better alternative due to urgency.
o The problem solving process is difficult. It takes practice as well as time to
perfect, but in the long run the process proves to be of great benefit.
o Illogical sequencing of instructions: In the process of problem solving on the
computer, one of the most complicated jobs for the problem solver is writing the
instructions. Example: Consider a task to find which number is the maximum
from a set of three numbers. Near about everyone is immediately able to tell
which is the largest but several of them are unable to explain the steps they
followed to get the result. Computer is nothing but a machine that will perform
only task that the user can explain.

1.1.5 Problem Solving Aspects

Q.6. What is modularization? Explain different approaches to design an algorithm.


Ans:
Modularization:
For a complex problem, its algorithm is often divided into smaller units called modules.
This process of dividing an algorithm into modules is called as modularization.

Top down design approach:


∙ A top-down design approach starts by dividing the complex algorithm into one
or more functions.
∙ These functions can further be decomposed into one or more sub-functions, and
this process of decomposition is iterated until the desired level of module
complexity is achieved.
∙ Top-down design method is a form of stepwise refinement where we begin with
the topmost module and incrementally add functions that it calls. ∙ Therefore, in a
top-down approach, we start from an abstract design and then
at each step, this design is refined into more concrete levels until a level is
reached that requires no further refinement.
Diagram: Top Down Approach

Bottom up design approach:


∙ It is just reverse of top down approach.
∙ In bottom up design, we start with designing the most basic or concrete modules
and then proceed towards designing higher level modules.
∙ The higher level modules are implemented by using the operations performed by
lower level modules.
∙ Thus, in this approach sub-modules are grouped together to form higher level
module.
∙ All the higher level modules are clubbed together to form even higher level
modules.
∙ This process is repeated until the design of the complete algorithm is obtained.

Difference between Top down and Bottom up approach:


Top-Down Approach Bottom-Up Approach

Divides a problem into smaller units and then Starts from solving small modules
solve it. and adding them up together.
This approach contains redundant information. Redundancy can easily be eliminated.

A well-established communication is not required. Communication among steps is


mandatory.

The individual modules are thoroughly analysed. Works on the concept of data-hiding
and encapsulation.

Structured programming languages such as C OOP languages like C++ and Java,
use top-down approach. etc. uses bottom-up mechanism.

Relation among modules is not always required. The modules must be related for
better communication and work
flow.

Primarily used in code implementation, test case Finds use primarily in testing.
generation, debugging and module
documentation.

1.1.6 Problem Solving Strategies:

Q.5. Explain the problem solving Strategies?


Ans.
Computer is a very powerful and versatile machine and can do any task given to it
provided that the programmer has already fed correct instructions to direct what, how and
when the steps have to be done to solve a particular problem. For this he should work to
develop a step by step solution to problem. These steps can be given as:
∙ Clearly define the problem in very simple and precise language.
∙ Analyse the problem to find out different ways to solve problem and decide the
best possible solution.
∙ Define the selected solution in a detailed step by step manner.
∙ Write the steps in a particular programming language so that it can be executed by
the computer.
The entire software development process is divided into a number of phases where each
phase performs a well defined task. Moreover, the outputof one phaseprovides the input
for subsequent phase. The phases in the software development life cycle (SDLC) process
are summarized as follows:
Fig: Software Development Life cycle (SDLC)

∙ Requirement Analysis: In this phase, the user’s expectations are gathered to know
why the software has to be built. The gathered requirements are analyzed to
decide scope of software. The last activity in this phase includes documenting
every identified requirement of the users in order to avoid any doubts regarding
functionality of software. The functionality, capability, performance and
availability of hardware and software components are all analyzed in this phase.

∙ Design: The requirements documented in previous phase act as an input to the


design phase. In the design phase, core structure of the software is broken down
into modules. The solution of the program is specified for each module in the
form of algorithms or flowcharts.

∙ Implementation: In this phase, the designed algorithms are converted into program
code using any of the high level languages. The particular choice of language will
depend on the type of program, such as whether it is system or application
program. This phase is also called as construction phase as the code of the
software is generated in this phase. While constructing the code, the development
team checks whether the software is compatible with available hardware that are
mentioned in requirement specification document.

∙ Testing: In this phase all modules are tested together to ensure that the overall
system works well as a whole product. In this phase the software is tested using a
large number of varied inputs, also known as test data, to ensure the software is
working as expected by user’s requirements.
∙ Software development, training and support: After the code is tested and the
software or the program has been approved by the users, it is installed or
deployed in the production environment. In this phase it becomes very crucial to
have training classes for users of software

∙ Maintenance: Maintenance and enhancement are ongoing activities that are done to
cope with newly discovered problems or new requirements. Such activities may
take a long time to complete as the requirement may call for the addition of new
code that does not fit original design or an extra piece of code, required to fix an
unforeseen problem.

Q.15. Explain various features of python.


Ans.
1. Simple: Python is simple and small language. Reading a program written in
python feels like reading English.
2. Easy to Learn: Python programming is clearly defined and easily readable. 3.
Versatile: Python supports wide variety range of applications ranging from text
processing to Web applications
4. Free and Open Source: Python software is freely available on internet
5. High Level Language: Programmers don’t have to worry about low level details
like managing memory used by program etc.
6. Interactive: Programs in python works in interactive mode
7. Portable (Platform Independent): Python is portable language. Program can
work similarly on different platform like window, Linux, Macintosh, Solaris etc.

8. Object Oriented: Python supports Object oriented style of programming like C+


+, Java languages. It support features like C class, Objects, Inheritance etc.

9. Interpreted: Python is processed at run time by the interpreter. So no need to


compile program before executing it.
10. Scalability: Python support modular programming, so programmer can add
module at any stage of the program
11. Secure: Python programming environment is secure from

tempering

1.4 History and Future of Python

∙ Python is a general purpose interpreted interactive object oriented and high level
programming language.
∙ It was first introduced in 1991 by Guido van Rossum, a Dutch computer
programmer.
∙ The language places strong emphasis on code reliability and simplicity so that

the programmers can develop applications rapidly

∙ Python is multi-paradigm programming language, which allows user to code in


several different programming styles.
∙ Python supports cross platform development and is available through open source.
Python is widely used for scripting in Game menu applications effectively

History of Python:

∙ Python is created by Guido Van Rossum in the 1980s.


∙ Rossum published the first version of Python code (0.9.0) in February 1991 at the
CWI (Centrum Wiskunde & Informatics) in the Netherlands , Amsterdam. ∙ Python
is derived from ABC programming language, which is a general-purpose
programming language that had been developed at the CWI.
∙ Rossum chose the name "Python", since he was a big fan of Monty Python's Flying
Circus.
∙ Python is now maintained by a core development team at the institute, although
Rossum still holds a vital role in directing its progress.

Future of Python:

∙ Python’s userbase is vast and growing – it’s not going away any time soon. ∙ Utilized
by the likes of Nokia, Google, and even NASA for it’s easy syntax, it looks to have a
bright future ahead of it supported by a huge community of OS developers. ∙ Its support
of multiple programming paradigms, including object-oriented Python programming,
functional Python programming, and parallel programming models makes it a highly
adaptive choice – and its uptake keeps growing.

1.5 Writing and Executing Python Programs

∙ Open IDLE.
∙ Go to File > New.
∙ Write Python code in the file.
∙ Then save the file with .py extension. For example, [Link], [Link] etc.
You can give any name to the file. However, the file name should end with .py ∙
Run the program.

You might also like