Experiment-1
Aim:
Write a program to purposefully raise Indentation Error and correct it.
Procedure:
● Open the Jupyter Notebook
● Write the code of the loop or the function
● Make the space in the next line before the code start.
● Run the code
Code:
def say_hello():
print("Hello, World!") # This line is not indented properly say_hello()
def say_hello():
print("Hello, World!") # Properly indented
say_hello()
Output:
Result:
The program for raise indentation error is successfully executed.
Experiment-2
Aim:
Write a program to compute distance between two point taking input from the user(Pythagorean
Theorem).
Procedure:
● Open the Jupyter Notebook.
● Take the two input from the user
● Import the math function
● Use the formula for the distance
● Print the results.
Code:
import math
class point:
def distance(x,y):
return [Link]((x**2)+(y**2))
d=[Link](15,5)
print("The difference between the two point is ",d)
Output:
Result:
The program for distance between the two point by using the pythagorean is successfully
executed.
Experiment-3
Aim:
Write a program [Link] that takes 2 numbers as command line arguments and
prints its sum.
Procedure:
● Open the Jupyter Notebook.
● Take the two input from the user
● Addition of the two number
● Open the location of the file in the command prompt
● Run with the help of the python [Link]
● Print the results.
Code:
class sum:
def addition(x,y):
return x+y
a=[Link](15,25)
print("Addition of the two number is ",a)
Output:
Result:
The program for addition of the two number and the command line is successfully executed.
Experiment-4
Aim:
Write a program to swap two variables without using third variable.
Procedure:
● Open the Jupyter Notebook.
● Take the two input from the user
● Addition in the first variable
● Subtract from the second variable
● Print the results.
Code:
class swap:
def change(x,y):
x=x+y
y=x-y
x=x-y
return x,y
a=10
b=20
c=[Link](a,b)
print("The swapping of the two number before swapping is ",a,b)
print("The swapping of the two number is ",c)
Output:
Result:
The program for raise indentation error is successfully executed.
Experiment-5
Aim:
Write a program to verify the number is odd, even or prime.
Procedure:
● Open the Jupyter Notebook.
● Take the input from the user
● Check the number from the even or odd or prime
● Print the results.
Code:
class checking:
def even_odd(x):
if x%2==0:
return "Even number"
else:
return "Odd number"
def prime_number(x):
if x<=1:
return "Invalid input"
else:
for i in range(2,x):
if x%i==0:
return "It is not a prime number"
else:
return "Prime number"
c=checking.even_odd(20)
c1=checking.prime_number(20)
print("The odd or even number ",c)
print("The Prime Number ",c1)
Output:
Result:
The program for even,odd or prime number is successfully executed.
Experiment-6
Aim:
Write a program to find out the positive and negative number in list.
Procedure:
● Open the Jupyter Notebook.
● Take the two input from the user
● Check the number is greater than 0 or not.
● Print the results.
Code:
class positive:
def positives(x):
if x>0:
return "Positive number"
elif x==0:
return "Zero"
else:
return "Negative number"
p=[Link](26)
p1=[Link](-36)
print("The number is ",p)
print("The number is ",p1)
Output:
Result:
The program for checking the number is positive or negative is successfully executed.