1.
TO ADD TWO NUMBERS
Aim:
To write a python program to add two numbers.
Coding:
a=8
b=9
c=a+b
print(c)
Output:
Result:
The given program has been executed successfully.
2. Find the maximum of two numbers in python
Aim:
To write a python program to find the maximum of given two numbers.
Coding:
a=8
b=3
print(max(a, b))
Output:
Result:
The given program has been executed successfully.
3. To Multiply two numbers
Aim:
To write a python program to multiply two numbers.
Coding:
num_1 = float(input("Enter the first number: "))
num_2 = float(input("Enter the second number: "))
product = num_1 * num_2
print(f"Product of {num_1} and {num_2} is {product}")
Output:
Enter the first number: 5
Enter the second number: 7
Product of 5.0 and 7.0 is 35.0
Result:
The given program has been executed successfully.
4. To find the factorial of a number
Aim:
To write a python program to find the factorial of a number
Coding:
n=6
fact = 1
for i in range(1, n + 1):
fact *= i
print(fact)
Output:
720
Result:
The given program has been executed successfully.
4. To find simple interest
Aim:
To write a python program to find the simple interest.
Coding:
def fun(p, t, r):
return (p * t * r) / 100
p, t, r = 8, 6, 8
res = fun(p, t, r)
print(res)
Output:
3.84
Result:
The given program has been executed successfully.
5. To find the largest number in a list
Aim:
To write a python program to find the largest number in a list.
Coding:
a = [10, 24, 76, 23, 12]
largest = max(a)
print(largest)
Output:
76
Result:
The given program has been executed successfully.
6. To check the number is even or odd
Aim:
To write a python program to check the number is even or odd.
Coding:
num = int(input("Enter a number: "))
if (num % 2) == 0:
print("{0} is Even".format(num))
else:
print("{0} is Odd".format(num))
Output :
Enter a number: 43
43 is Odd
Enter a number: 18
18 is Even
Result:
The given program has been executed successfully.
6. To check prime number in python
Aim:
To write a python program to check prime number in python
Coding:
import math
n = 11
if n <= 1:
print(False)
else:
is_prime = True
for i in range(2, int(math.sqrt(n)) + 1):
if n % i == 0:
is_prime = False
break
print(is_prime)
Output :
True
Result:
The given program has been executed successfully.