Part B Unit 5 Introduction to Python
Here’s a clear differentiation between Coding, Algorithm, Flowchart, and Pseudocode using
one example instance:
Instance: Calculate the sum of two numbers.
Aspect Algorithm Flowchart Pseudocode Coding (Python)
A diagrammatic A structured way
A step-by-step
representation of of writing an Actual implementation in a
Definition procedure to
the algorithm algorithm in plain programming language.
solve a problem.
using symbols. English.
python<br>num1 =
1. Start 2. Input int(input("Enter first number:
START INPUT
two numbers 3. "))<br>num2 =
num1, num2 sum
Steps Add the numbers int(input("Enter second
← num1 + num2
4. Display sum 5. number: "))<br>sum = num1
PRINT sum END
End + num2<br>print("Sum =",
sum)
Write logic in
Visualize the easy-to-read
Purpose Plan the logic. Execute and test the solution.
steps. format before
coding.
Programmers, Designers, Programmers,
Users Developers
Analysts Beginners Students
✅ Key Difference:
Algorithm → Logical steps (text form).
Flowchart → Visual diagram of steps.
Pseudocode → Language-independent textual logic.
Coding → Actual working program in a language.
Program- A program is a set of instructions written in a programming language to perform a
specific task.
Software- A Collection of Programs is referred to as software.
In order to develop software, Programmers write codes.
Writing Code in a systematic and logical order is called Programming.
Programming- The process of giving instruction to the computer to perform specific task is known
as Programming.
Data Types – A data type represents the type of data stored in a variable.
Following are the different datatypes:
Number - It has numeric value. Numeric Value can be integer, decimal, or a complex
number.
Data Types – Keyword Description For eg.
Values are
1. Integer and int It contains positive or negative 15, -85 ,26,
long whole numbers (without fraction or 45,-787
integer. decimal).
Integer has unlimited range, as per
available memory.
2. Float float These are real numbers. It contains 15.2, 455.23
decimal numbers. These numbers
can be positive or negative.
3. Complex complex -2+3j
Sequence – It is an ordered collection of similar or different data elements having the same or
different data types.
Data Type Keyword Description For eg.
Values are
1. String str It is a collection of one or more ‘&perfect’
characters enclosed in single ‘’’ Kind’’’
quotation, double quotation or triple “humble’
quotation mark
2. List It contain different datatypes. Employee=
The items stored in the list are [‘Kavita’,
separated by a comma(,)and with in ‘25’,
the square bracket[ ] . ‘Editor’]
It stores elements in a sequence one
after another.
It allows to modify the elements.
It is known as mutable because it
allows change in elements.
3. Tuple It is also an ordered data type. It can Employee=
also contain different datatypes. (‘Kavita’,
The items stored in the list are ‘25’,
separated by a comma(,)and with in ‘Editor’)
the parentheses ( ) .
It is Read only data structure, it
doesnot allow modification of size
and value.
It is known as immutable because it
doesn’t allow change in elements.
Sets – A set is an unordered collection of unique elements.
- It doesn’t allow duplicate entry.
- It consists of various data types.
Example – Output
A= {3,5,1,6,7, ‘AI’, 0,3,8,9} set([0, 1, 3, 5, 6, 7, 'AI', 9, 8])
print(A)
None- It is used for null value or no value.
- It is not same as 0 or an empty string.
Example-
A= None
Dictionary – It is a mapping data type, where a key is mapped to its corresponding value.
- It is an unordered collection of key-value pairs.
- It can be of any data type.
- It allows duplicate values.
- But the keys must be unique and case – sensitive too.
- It is best suited for large amount of data.
For instance, we can search someone’s detail using key, key will match the data and find the
appropriate output.
Operators –
1) Arithmetic - + (Addition), - (Subtraction) , *(Multiplicationn) , / (Division) , % (Modulus),
** (Exponentiation) , // (Floor Division)
2) Relational - > (Greater than), < (Less than) , = =( Equal to ) , !=( Not equal to),
>=(Greater than or equal to ) , <= (Less than or equal to)
3) Logical – And, Or, Not
4) Assignment - =
Operator precedence-
input( )
print( )
Type Conversion/Typecasting – It is the process of converting the value of one data type to
another.
Two Conversion types are-
1. Implicit – It converts lower data types to higher data types
2. Explicit – convert the data type of an object in to the required data type using in( ), float( ),
str( ) functions.