Module 1_Lecture 1 Algorithm and Flowchart
Module 1_Lecture 1 Algorithm and Flowchart
Python
(ITFC0101)
Dr. Kusum Kumari Bharti
Course Outline/Curriculum & Lecture/Tutorial Count
Module
Topics
No.
S.
Evaluative Components and tentative dates of examination Marks
No.
Mid Sem Examination
1 30
Total 100
Need of the programming language
• Enable communication with computers and execution of tasks.
• Facilitate software development and feature implementation.
• Support a wide range of applications, from web to mobile to systems
programming.
• Offer tools for efficiency, performance, and resource management.
• Provide frameworks and libraries to streamline development.
• Foster problem-solving, innovation, and custom solutions.
• Support cross-platform and compatible development.
• Apply to various fields including science, finance, and business.
• Enhance career skills and educational opportunities.
• Encourage community involvement and open-source contributions.
Steps for writing program
Writing a program involves several systematic steps to ensure that the software is
well-designed, functional, and efficient
– Understand the Problem: Define requirements and constraints.
– Plan the Solution: Design the algorithm or solution approach.
– Choose a Programming Language: Select the appropriate language for the task.
– Set Up the Development Environment: Install and configure tools and environment.
– Write the Code: Implement the algorithm in code.
– Test the Program: Run tests and debug issues.
– Optimize the Code: Improve performance and refactor as needed.
– Document the Code: Add comments and create necessary documentation.
– Deploy the Program: Prepare and release the program to users.
– Maintain and Update: Monitor and update the program based on feedback and changing needs.
Steps for writing program
• Algorithm
• Pseudo code
• Flowchart
• Program
Algorithm
• First algorithm was written by Ada Lovelace in year 1843.
• She is often credited with writing the first algorithm intended for
implementation on a computer.
1. Take a number n
2. If the number n is less than or equal to 1, it is not a prime
3. If number n is 2 or 3, it is prime
4. If n is even and greater than 2, it is not a prime
5. For each integer i to n-1, check if n is divisible by i. If n is divisible by any i,
then n is not prime.
Algorithm for Prime number
1. Take a number n
2. If the number n is less than or equal to 1, it is not a prime
3. If number n is 2 or 3, it is prime
4. If n is even and greater than 2, it is not prime
5. For odd numbers greater than 3, check if the number is divisible by any
integer from 3 up to sqrt(n). If it is divisible by any of these is is not prime.
check if n is divisible by i. If n is divisible by any i, then n is not prime.
Pseudocode
Pseudocode SumOfTwoNumbers
1. Read A
2. Read B
3. sum = A + B
4. Print sum
Start
// Input section
1. Prompt the user to enter the first number
2. Read the first number and store it in variable A
3. Prompt the user to enter the second number
4. Read the second number and store it in variable B
5. // Processing section
6. Calculate the sum of A and B
7. Store the result in variable sum
8. // Output section
9. Print the value of sum
End
Characteristics - Pseudocode
•Level of Detail:
•Algorithm: Generally more abstract and conceptual, without specific syntax.
•Pseudocode: More detailed and structured, resembling code but not bound by syntax rules.
•Use:
•Algorithm: Used for conceptualizing and designing solutions before coding.
•Pseudocode: Used for planning and explaining algorithms in a way that can be easily translated
into actual code.
•Language Dependence:
•Algorithm: Independent of programming languages.
•Pseudocode: Designed to be translated into code and uses language-like constructs for clarity.
• Algorithm: A high-level description of steps to solve a problem.
• Pseudocode: A detailed, human-readable way to describe an algorithm that
resembles programming language syntax but is not actual code.
Flowchart
The oval symbol in The rectangle symbolizes the guide your audience Indicate that a
flowcharts represents the process steps involved in the along the flowcharting decision point
start and end of the process. diagram journey
It is commonly used to
indicate the beginning and Parallelogram is
conclusion of the flowchart. used to represent
input and
Output data
Types of business flowchart
• Decision flowchart. Your business can use this diagram if you want to justify decisions.
Creating the flowchart allows you to anticipate the possible consequences of various
choices.
• Logic flowchart. This flowchart is used to uncover bottlenecks and loopholes which could
cause issues or disruptions.
• Product flowchart. Companies can develop a product flowchart to illustrate the processes
of product creation. The diagram is also helpful when your business is launching a new
product or improving production processes.
• Process flowchart. This shows how a specific process can achieve the desired outcomes.
In most cases, the process flowchart is essential for teams who opt to improve current
processes.