Problem Solving and Python Programming Question and Answers Unit-I
Problem Solving and Python Programming Question and Answers Unit-I
3. Discuss a pseudo code to accept two numbers add the numbers and to print the result.
BEGIN
GET X,Y
ADD Z=X+Y
PRINT Z
END
1
8. Define the term hardware and software.
Hardware is any physical device used in or with your machine.
Examples of hardware devices in the computer are output devices like printer, monitor, input devices
like keyboard, and mouse.
Software is a collection of code installed onto your computer's hard drive.
9. Define function.
Function is a sub program which consists of block of code (set of instructions) that performs a particular
task. For complex problems, the problem is been divided into smaller and simpler tasks during algorithm
design.
Problem solving
Proper documentation
Instant communication
Effective analysis
2
13. Draw a flowchart to calculate average of three numbers.
15. Write a pseudo code to check whether the given number is positive or negative.
Step 1: Start.
Step 2: Read n
Step 3: If n>=0 then
Display “n is the Positive number”.
Otherwise.
Display “n is the Negative number”.
Step 4: Stop
17. Explain in detail the building blocks of algorithm with an example. Ans: Pg.No 1.5 to 1.8
18. Discuss about iteration. Write an algorithm, pseudo code and draw the flowchart to find the
factorial of a given number. Ans: Pg.no: 1.8 &1.32,
19. Write an algorithm, pseudo code and draw a flowchart to find minimum in a list.
Ans :Pg.no 1.18 to 1.20
20. Draw a flow chart and write an algorithm, pseudo code to check whether a given number is prime
or not. Ans: Pg.no 1.34, 1.48
21. Draw a flowchart and write an algorithm, pseudo code and to find the sum of first n natural
numbers. Ans: Pg.no 1.36, 1.55
22. Draw a flowchart and write an algorithm, pseudo code to insert a card in a list of sorted cards.
Ans: Pg.No 1.20 to 1.24
23. Draw a flowchart and write an algorithm, pseudo code to find the largest of three numbers.
Ans: Pg.No 1.7, 1.9, 1.14
24. Draw a flowchart and write an algorithm, pseudo code guess an integer number in a range.
Ans: Pg.no 1.24 to 1.27
25. Draw a flowchart and write an algorithm, pseudo code to find whether the given number is odd or
even. Ans: Pg.No 1.31, 1.35
26. Draw a flowchart and write an algorithm, pseudo code for Towers of Hanoi.
Ans: Pg.No 1.27 to 1.29
4
Unit - I : PART-C
5
Flowchart:
28. Write Draw flowchart and write an algorithm to solve a quadratic equation.
Algorithm
Step 1. Start
Step 2. Read a, b, c
Step 3. Calculate d = SQRT(b * b – 4 * a * c)
Step 4. Calculate r1 = (-b + d ) / (2 * a)
Step 5. Calculate r2 = (-b - d ) / (2 * a)
Step 4. Write r1, r2
Step 5. Stop
Flowchart
6
29. Describe the algorithm to find the simple interest and draw the flowchart for the same.
Algorithm
Step 1. Start
Step 2. Read P, N, R [Principle amount, Number of years, Rate of interest]
Step 3. Compute SI = P * N * R / 100
Step 4. Write SI
Step 5. Stop
Flowchart :
30. Draw flowchart and write an algorithm to find the net salary of an employee.
Algorithm
Step 1: Start
Step 2: Read Basic Salary as basic
Step 3: Calculate Dearness Allowance as da = (10*basic)/100
Step 4: Calculate Travelling Allowance as ta = (12*basic)/100
Step 5: Calculate House Rent Allowance as hra = (20*basic)/100
Step 6: Calculate Gross Salary as gs = basic + da + ta + hra
Step 7: Calculate Tax as tax=gs*9/100
Step 8: Calculate Net Salary as ns = gs - tax
Step 9: write „Net Salary‟, ns
Step 10: Stop
7
Flowchart:
31. Draw flowchart and write an algorithm to find the area of circle and rectangle.
Algorithm Algorithm
Step 1. Start Step 1. Start
Step 2. Read Radius Step 2. Read Length, Breadth
Step 3. Compute Area = 3.14 * Radius * Radius Step 3. Compute Area = Length * Breadth
Step 4. Write Area Step 4. Write Area
Step 5. Stop Step 5. Stop
Flowchart Flowchart