Program 1: # print “hello world”
Code:
print(“hello world!”)
Output:
hello world!

Program 2 : #write a python program to do arithmetic addition operation by taking value from user.
Code:
num1=int(input(“Enter your first number”))
num2=int(input(“Enter your first number”))
sum_result=num1 +num2
print(sum_result)
Output:
Enter your first number 4
Enter your first number 6
10

Program 3: #write a python program to do arithmetic division operation by taking value from user.
Code:
num3=float(input(“Enter your first number”))
num4=float(input(“Enter your first number”))
if num4==0:
print(“Zero division Error”)
else:
num5=num3/num4
print(f”The division of num3 and num4 is :{num5}”)
Output:
Enter your first number 4
Enter your first number 2
the division of num3 and num4 is :2.0

Program 4: # write a python program to find area of the triangle.
Code
base=float(input(“Enter the base of the triangle”))
height=float(input(“Enter the height of the triangle”))
area_of_triangle = 0.5* side1 * side2
print(f”The area of triangle is {area_of_triangle}”)
Output:
Enter the base of the triangle 2
Enter the height of the triangle 3
The area of triangle is 3.0

Program 5: # write a python program to swap two variables.
Code:
num1=float(input(“Enter your first number”))
num2=float(input(“Enter your first number”))
print(f”original values are : {num1} ,{num2} “)
c= num1
num1=num2
num2=c
print(f”swapped values are : {num1}, {num2} “)
Output:
Enter your first number 1
Enter your first number 2
original values are : 1.0 ,2.0
swapped values are : 2.0, 1.0

Leave a comment