Python Unit 1 (2marks )
Python Unit 1 (2marks )
Write an algorithu to acvept two numbers, compute the sum and print the resuit.
(AU Jan 2022, R2021, AUJan 2018)
5. Stop
The complexity
T'he eticicncy of an algorithm is measured by its Complexity.
is how fast it is" and how
That
of an algorithm is measured in Time and Space.
either case (timne or space) the
much space it uses lo process agiven input. In techniques.
cficieney is evaluated by experimentaltechniques or by analytical
Pseudocode in the perspective
8. What is the use of algorithm, Flowchart and (AUNov/ Dec 2019, R2017)
of problem solving?
computer how to solve a
Algorithm is a step-by-step instruction that tells the
representation that illustrates the
particular problem. Flowchart is a diagrammatic
steps that must be performed to solve a problem. Pseudocode is a
scquence of
algorithm that uses the
compact and informal high-level description of an
structural conventions of aprogramming language.
and program. (AUDec/Jan 2019, R2017)
9. Distinguish between algorithm
Algorithm Program
Algorithm step-by-step Program is a formal definition for an
set of instructions
procedure for solving a task or a algorithm. It is a
for the computer to follow.
problem.
74
Problenm Solving and Python Programming
10. Write an algorithm to find the minimum number in a given list of
numbers.
(AUDec/Jan 2019, R2017)
1. Start.
2. Read n.
3. Read all n elements and store in list A.
4. Assumemin first element in the list.
5. Read all elenments in a list one by one
if A[i]<min then assign
min=A[)
6. Repeat step 5 till allelements are compared
7. Print min as minimum element.
8. Stop.
11. What is an algorithm? (AUJan 2018, R2017)
(AUNov/Dec 2015, Nov/Dec 2014, May/June 2013, Jan 2013, Jan 2012.
May/June 2012, Jan 2010)
Algorithm is an ordered sequence of finite, well defined, unambiguous
instructions for completing a task.
12. What is a pseudocode? (AUNov/Dec 2015, Jan 2013, May/June 2009)
Pseudocode is a of short, readable and formally styled English language
instructions used for explaining an algorithm.
13. What are flowcharts and list down their advantages?
(AUNov/Dec 2014, May/June 2013, May/June 2012)
Aflowchart is a diagrammatic representation of the logic for solving a task.
Advantages of flowcharts:
State
Control flow
Functions
76
Problem Solving and Python Programming
19. Draw a flowchart to find the
maximum among the three numbers.
(AU Jan 2009)
Start
Print big
is y> big Yes
No big = y Stop