Embryology
Embryology
List of Experiments
2
Name: Athul Registration
Index Sheet
No Lab Experiment Lab document Viva
.
3
Name: Athul Registration
5 Loop statements 12
7 Functions 16
8 File handling 18
9 Data structures 21
4
Name: Athul Registration
Laboratory 1
Title of the Laboratory Exercise: Introduction to Python programming environment
3. Experimental Procedure
Students are given a set of Python programs. Edit and execute Python programs using
Python command line
Using IDE
o Interactive mode
o Script mode
4. Presentation of
Fig 1.1
Output:
5
Name: Athul Registration
Fig 1.2
Fig 1.3
Script mode:
Fig 1.4
Fig 1.5
Fig 1.6
Fig 1.7
6
Name: Athul Registration
Fig 1.8
Fig 1.9
5. Conclusions
1.Fig 1.1 ,1.2, 1.3 describes the python used in interactive mode
2.Fig 1.4, 1.5, 1.6, are the python progams used in script mode
3. Fig 1.7, 1.8, 1.9, describes the output of fig 1.4 , 1.5, 1.6 , respectively
4. These experiments helped me to learn the basics of python programming and different
7
Name: Athul Registration
Laboratory 2
Title of the Laboratory Exercise: Variables, data types, operators and expressions
1. Introduction and Purpose of Experiment
Variables are the basic data objects that are manipulated in a program. Every value in
Python has a datatype. Operators specify what is to be done to them. Expressions combine
variables and constants to produce new values. These building blocks are the topics of this
Lab. By solving the given programming problems, the students will be able to apply the
concepts of variables, data types, operators and expressions.
2. Aim and Objectives
Aim
To develop programs using variables of basic data types and compute simple
expressions involving operators
Objectives
At the end of this lab, the student will be able to
Use variables of the basic data types
Apply various operators in expressions
Create Python programs to solve simple numeric problems
3. Experimental Procedure
i. Analyse the problem statement
ii. Design an algorithm for the given problem statement and develop a
flowchart/pseudo-code
iii. Implement the algorithm in Python language
iv. Execute the Python program
v. Test the implemented program
vi. Document the Results
vii. Analyse and discuss the outcomes of the experiment
4. Questions
a. Write a Python program to exchange the values of two variables using a temporary
variable.
b. Write a Python program to find the area and perimeter of a rectangle.
5. Calculations/Computations/Algorithms.
8
Name: Athul Registration
a.Write a Python program to exchange the values of two variables using a temporary variable.
Step 1 = Start
Step 4 = a=temp
Step 5 = a=b
Step 6 =
b=temp
Step 9 = End
Step 1 = Start
Step 4 = area=l*b
Step 5 = perimeter=2(l+b)
Step 7 = End
6. Presentation of
Results a.code:
9
Name: Athul Registration
1
Name: Athul Registration
Fig2.1
Output:
Fig 2.3
b.code:
Fig 2.2
Output:
Fig 2.4
7. Conclusions
Figure 2.1 describes the python program for swapping of two numbers
Figure 2.3 describes the out put of fig 2.1 in which we can clearly see how by using python
we can clearly change the values or swap the values easily
1
Name: Athul Registration
Fig 2.2 helps us to find the area and perimeter of a rectangle use python easily
Fig 2.4 gives us the result or output of area and perimeter of a rectangle
8. Comments
1. Limitations of Experiments
The limitation of above experiment is simple and common technique that may not be best when
handling the huge datasets, and the problem assumes the variables are of compatible types for
swapping.
The limitation lies in its specificity to rectangles. If there is a need for different shape, Then the
code will require some modification.
2. Limitations of Results
The result is independent on the input values or non numeric inputs might lead to unexpected
outcomes. It is important to validate the input to make sure the programme gives the correct
output
The precision of the results might be affected by the data type used for calculations. Floating
point arithmetic limitations could result in small errors, especially with very large or very small
dimensions.
3. Learning happened
From the above experiment a basic understanding of variable assignments, and the concept of
temporary storage was implemented.
This program allowed for practical application of geometry concepts, enhancing understanding
in the context of programming.
4. Recommendations
1
Name: Athul Registration
Considering the Incorporation of exception handling for invalid inputs or extending the
functionality to handle various shapes could enhance the program’s versatility.
1
Name: Athul Registration
Laboratory 3
Title of the Laboratory Exercise: Input Output operations
1. Introduction and Purpose of Experiment
Python provides the Input-Output facility to interact with the user. Some of the functions
such as input() and print() are widely used for standard input and output operations
respectively. By solving the problems, students will be able to develop programs to read
input from screen and display output to the screen.
3. Experimental Procedure
i. Analyse the problem statement
ii. Design an algorithm for the given problem statement and develop a
flowchart/pseudo-code
iii. Implement the algorithm in Python language
iv. Execute the Python program
v. Test the implemented program
vi. Document the Results
vii. Analyse and discuss the outcomes of the experiment
4. Questions
a. Write a Python program to accept three numbers from the user (in a single line
separated by spaces) and display their average.
b. Write a Python program to enter an integer number and perform the following
operations (use built in methods) on the integer
Square, Cube, and Factorial
5. Calculations/Computations/Algorithms
1
Name: Athul Registration
a. Algorithm to accept the three numbers from the user ( in a single line separated by spaces)
and display their average
Step 1: start
Step 4: sum=a+b+c
Step : Stop
Step 1:start
Step 4:square=a*a
Step 6 :stop
Step 1:start
Step 4:cube=b*b*b
Step 6:stop
1
Name: Athul Registration
Step 1: start
Step 5: fact=fact*i
Step 8: stop
6. Presentation of Results
3a. code:
Fig 3.1
Output:
Fig 3.3
3b. code:
1
Name: Athul Registration
Fig 3.2
Output:
Fig 3.4
7. Conclusions
Fig 3.1 describes the python program to find the average of 3 numbers
Fig 3.3 Gives the result or output of the average of the three numbers
fig 3.2 and fig 3.4 we can conclude that how easily we can use python to calculate the square
cube and factorial of the given numbers
8. Comments
1. Limitations of Experiments :
This program is specifically designed for calculating the average of three numbers. If we need
to calculate the average of a different number of values, we would need to modify the
program accordingly.
2. Limitations of Results
The second programme is not applicable for other data types like float
1
Name: Athul Registration
3. Learning happened
To find average of 3 numbers and to perform the mathematics operations to calculate the
square cube and factorial of any number using python
4. Recommendations
We can create a programme with more inputs to find average
1
Name: Athul Registration
Laboratory 4
Title of the Laboratory Exercise: Logic operations and decision making
1. Introduction and Purpose of Experiment
Python provides number of control flow instructions/statements to control the flow of
program execution conditionally. By solving the problems, students will be able to apply
conditional control statements to control the program execution.
4. Questions
a. Write a Python program to check whether the given number is zero, positive or
negative.
b. Write a Python program to display the roots of a quadratic equation.
5. Calculations/Computations/Algorithms
a. Algorithm to check the whether the given number is zero, positive or negative.
Step 1:start
Step 2:the variable taken is a
1
Name: Athul Registration
Step 2: start
Step 8: root_2=(-b-math.sqrt(discriminant))/(2*a).
6. Presentation of Results
4a.code.
Fig 4.1
2
Name: Athul Registration
Fig 4.3
Fig 4.3
Fig 4.3
2
Name: Athul Registration
Fig 4.2
Output:
Fig 4.4
7. Conclusions
Fig 4.1, 4.3 details us that by using python how easily we can determine the value of given
number whether the number is positive negative or zero
Similarly fig 4.2 gives us the code for finding the roots of quadratic equation
Fig 4.4 gives the roots of the given values in the code above
8. Comments
1. Limitations of Experiments
If we enter a non numeric value such as a , b the python code doesn’t work
2.Limitations of Results
2
Name: Athul Registration
3. Learning happened
We learned to find the roots of quadratic equation using python and determine the
positivity or negativity of a given number
4.Recommendations
Can be done by other method also and we can use float and process the code
2
Name: Athul Registration
Laboratory 5
Title of the Laboratory Exercise: Loop statements
3. Experimental Procedure
i. Analyse the problem statement
ii. Design an algorithm for the given problem statement and develop a
flowchart/pseudo-code
iii. Implement the algorithm in Python language
iv. Execute the Python program
v. Test the implemented program
vi. Document the Results
vii. Analyse and discuss the outcomes of the experiment
4. Questions
a. Write a Python program to accept an integer number and find sum of digits in the
number.
b. Write a program to perform addition and subtraction of two matrices
i. Without using numpy module
ii. Using numpy module
5. Calculations/Computations/Algorithms
a. Write algorithm to accept an integer number and find sum of digits in the number.
2
Name: Athul Registration
Step1: start
Step2: input the number and assign it to n
Step3: take sum is equal to zero
Step4: n is not equal to zero
Step5:take digit equal to remainder of n/10
Step6:take sum is eqal to the sum+digit
Step7:take n I sequal to n/10
Step8:output sum
Step9:go to step 4
Step10:stop
b.Algorithm to perform addition and subtraction of two matrices.
I Without using numpy module.
Step 1: start
Step 2: Define two matrices matrix1 and matrix2.
Step 3: print the elements of matrix1 and matrix2 using nested loops.
Step 4: Define an empty matrix result of the same size has matrix1.
Step 5: perform suitable addition and subtraction operations for elements of matrix1
and matrix2 using nested loops and store the result in the result matrix.
Step 6: print the result matrix.
Step 7: stop
II Using numpy module.
Step 1: start
Step 2: Import numpy has np into the program.
Step 3: Declare matrix 1 and give values.
Step 4: Declare matrix 2 and give values.
Step 5: perform suitable addition and subtraction operations for elements of matrix1
and matrix2.
Step 6: print the
result.
Step 7: stop.
6. Presentation of Results
5a.code:
2
Name: Athul Registration
Fig 5.1
Output:
Fig 5.3
5b.code Without using numpy module
fig 5.2
output
Fig 5.4
2
Name: Athul Registration
Fig 5.2
Output:
Fig 5.4
7. Conclusions
The first programme takes integers as inputs and interprets the the sum of the digits using
the logic and displays result
Second programme has 2 parts in the first we calculate sum of 2 matrices using inbuilt
function And In the second part we use numpy
8. Comments
1. Limitations of Experiments
In second Matrice part 1 matrices can be added or subtracted only they have same number
of rows and columns and the code is also long
And in the second part User should have numpy package download in the device using by him
2.Limitations of Results
The first program is lengthy as it contains more line of codes .we can use numpy instead
The second program is short but it lacks the foundation and logic behind the built in
function which is required for beginners to build their understanding in terms of matrices
3. Learning happened
Code can be done in two ways
4. Recommendations
We can compare both programs and find the code which takes the least time to execute.
2
Name: Athul Registration
Laboratory 6
Title of the Laboratory Exercise: Character and String operations
3. Experimental Procedure
i. Analyse the problem statement
ii. Design an algorithm for the given problem statement and develop a
flowchart/pseudo-code
iii. Implement the algorithm in Python language
iv. Execute the Python program
v. Test the implemented program
vi. Document the Results
vii. Analyse and discuss the outcomes of the experiment
4. Questions
a. Write a Python program to find duplicate characters in the given string and store
them in a list.
b. Write a Python program to count the numbers of occurrences of characters in the
given string and store them in a dictionary.
5. Calculations/Computations/Algorithms
a.Write a algorithm find duplicate characters in the given string and store them in a list.
2
Name: Athul Registration
Step1: start
Step2: ask the user to input a string
Step3:store the input string in the variable n
Step4:create an empty list called d
Step5:for each character I in the input string n
Step6:count the number of occurances of I in the input string n using count()method
Step7:if the count of I is greater than 1
Step8:check if I is already present in the list d using the not in operatot
Step9:if I is not in d append I in list d
Step10:print the list d containing duplicate characters
Step11:stop
b.write algorithm to count the numbers of occurrences of characters in the given string and
store them in a dictionary.
Step 1:start
Step 2: input a string
Step 3 : create an empty dictionary called d
Step 4: take character ch in string st
Step 5: count is equal to st.count(ch)
Step 6 : d[ch] is equal to count
Step 7:print the dictionary
step 8: end
6. Presentation of
Results 6a.code:
2
Name: Athul Registration
Output:
6b.code
Output:
3
Name: Athul Registration
7. Conclusions
a).In conclusion, the Python program effectively identifies duplicate characters within a
provided string. By systematically traversing the string and utilizing a list to store duplicates,
it offers a clear representation of the repeated characters present. Such a solution
underscores Python's capabilities in string manipulation and algorithmic problem-solving.
b). In summary, the Python program adeptly analyzes a given string to determine the
frequency of each character. By leveraging a dictionary to map characters to their respective
counts, it offers a concise and organized representation of character occurrences. This
approach exemplifies Python's versatility in data structuring and efficient counting
methodologies.
8. Comments
1. Limitations of Experiments
1. In code 1 to find sum of all items in a list if we have only 1 item the code is not valid
2. to find the code for the largest number all the elements in the given list should be
different in not the code fails
3.the length of a string in python
4. The above code is case sensitive and it cant handle all Unicode characters given in input
2. Limitations of Result
This algorithm is not applicable in other data types except lists.
3. Learning happened
Learned about lists and strings
4.Recommendations
We can implement the same in logic in other data types and check the output.
3
Name: Athul Registration
Laboratory 7
Title of the Laboratory Exercise: Functions
4. Questions
i. Write a Python program to find factorial of a number using recursion.
ii. Write a Python function to reverse a string (without using slicing or built in method).
Use the returned result to check whether the given string is palindrome or not.
5. Calculations/Computations/Algorithms
3
Name: Athul Registration
6. Presentation of Results
7a.code
Output:
3
Name: Athul Registration
7b.code
Output:
7. Conclusions
a). In conclusion, the Python program elegantly employs recursion to determine the factorial
of a given number. By breaking down the factorial calculation into iterative multiplications of
decreasing values, the program efficiently computes the desired result. This recursive
approach underscores Python's capability to handle complex mathematical operations with
a concise and structured methodology.
3
Name: Athul Registration
b). In summary, the Python function ingeniously reverses a string without relying on built-in
methods or slicing techniques. By comparing the original string with its reversed
counterpart, the function adeptly determines whether the string is a palindrome or not. This
approach exemplifies Python's flexibility in string manipulation and its capacity to tackle
fundamental programming challenges with clarity and efficiency.
8. Comments
1. Limitations of Experiments
The above given code is case sensitive and it may not handle all Unicode characters
2. Limitations of Results
3. Learning happened
Learned about dictionary and string usages in python which makes it very easy for us to
understand
4. Recommendations
The output is only stored in dictionary format which is not useful for accessing in other
functions,