Mimpython 1

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

Experiment No: 04

Experiment Name: Solving Some Problems in Python.


Objectives:
1. Introduction to Python Software for Engineering Tools.
2. Learning Python fundamentals for Numerical Analysis.
3. Solving intricate problems with Python.
4. Exploring real-life problem-solving applications of Variables, Loops, Conditional Statements
and Arrays.
5. Applying Python to solve mathematical problems such as Matrix Multiplication.
6. Strengthening problem-solving and numerical analysis logic.
7. Grasping fundamental principles for algorithm development in problem-solving.

Introduction:
Python, recognized as a high-level programming language, has become widely popular for its
readability, simplicity and extensive libraries. This introductory overview will delve into
essential concepts that establish the groundwork of Python programming.

Problems:

1. Check if a number is Armstrong.


2. Cheak if a number is Strong or Weak
3. Cheak if a number String is palindrome or not.
4. Matrix Multiplication.

Armstrong Number in Python:


The Armstrong number in Python is the number in which the sum of each digit powered to the
total number of digits is the same as the given number. i.e. for a given number say
153,1^3+5^3+3^3 is equal to 153.
Let’s take another example :1634 = 1^4+6^4+3^4+4^4 is an Armstrong number. Any number in
any number system that exhibits this sum property will be called an Armstrong number.
Cheak a number is Armstrong.

Implement Code:
Strong number in Python:
A strong number is a special number whose sum of the all digit factorial should be equal to the
number itself.
To find a whether given number is strong or weak. We pick each from the given number and find
its factorial and we will do this every digit of the number.
Once we get the factorial of all digit, then we do the sum factorials. If the sum is equal to the
given number then the given number is strong otherwise not.
Cheak a number is Strong or Week:
Implement Code:
Palindrome in Python:
For a number or string to be palindrome in Python, the number or string must be the same when
inverted. If the string or number does not remain unaltered when reversed, it is not a Palindrome.
For instance, 11, 252, 1221 and 25952 are palindrome numbers in Python.
MOM, MADAM and RADAR are palindrome strings in Python.
Example: MIM
Output: Yes, a palindrome string.
Example: 1234321
Output: Yes, a palindrome number.
Therefore, a palindrome in Python is any word, number, sentence or string that reads the same
backward or forward.
Cheak if a number String is Palindrome or not:

Implement Code:
Matrix Multiplication:
Matrix multiplication is an operator that takes two matrices as input and produces single matrix
by multiplication rows of the first matrix to the column of the second matrix. In matrix
multiplication make sure that the number of columns of the first matrix be equal to the number of
rows of the second matrix.

Matrix Multiplication:

Implement Code:
Conclusion:

During this lab session, I explored the core principles of Python programming. I initiated by
grasping the fundamentals, including data types, variables, and elementary operations.
Subsequently, I delved into control flow mechanisms such as conditionals and loops, which aid
in decision-making and task repetition.

Moreover, I gained insight into functions, which facilitate the organization of code into reusable
components. These concepts form the bedrock of Python programming, empowering me to
develop efficient and well-structured code.

Through practical problem-solving exercises, I applied these foundational concepts to address


various challenges, such as palindrome checks and matrix operations. Overall, this lab provided a
sturdy groundwork in Python programming, equipping me with vital skills to approach a broad
spectrum of coding tasks with assurance and proficiency.

You might also like