You are on page 1of 4

Program to add two numbers

x=10

y=20

z=x+y

print(z)

Program to find the area of rectangle


length= 10

breadth= 5

area= length* breadth

print("Area of rectangle = ",area)

Program to find the area of circle


#area of circle

radius=eval(input("Emnter the radius = "))

area = 3.14*radius * radius

print("Area of circle = ", area)

Program to show the use of various arithmetic operators


num1=input("Enter first number : ")

num2=input("Enter second number : ")

sum=float(num1)+float(num2)

sub=float(num1)-float(num2)

multiply=float(num1)*float(num2)

div=float(num1)/float(num2)

rem=float(num1)%float(num2)

floordiv=float(num1)//float(num2)

print("The sum of {0} and {1} is {2}".format(num1, num2, sum))


print("The subtraction = ", sub)

print("The product = ", multiply)

print("The division = ", div)

print("The remainder = ", rem)

print("The floor division = ", floordiv)

Program to show the use of various bitwise operators


a=int(input("Enter the first value"))

b=int(input("Enter the second value"))

print("Bitwise AND = ", a&b)

print("Bitwise OR = ", a|b)

print("Bitwise XOR = ", a^b)

print("Bitwise right shift = ", a>>b)

print("Bitwise left shift = ", a<<b)

print("Bitwise NOT = ", ~a)

Program to print your details on the screen using print( )


print("Name = Abhay")

print("Section = C1802")

print("Course = INT102")

print("Department = Civil")

print("University = LPU")

print("Hello \nStudents \nBye")

Program to show the use of various relational or comparison operators


a= int(input("Enter the first value = "))

b=int(input("Enter the second value = "))

print("Equals = ", a==b)


print("greater than = ", a>b)

print("less than = ", a<b)

print("Not Equals to = ", a!=b)

print("Greater than or equals to = ",a>=b)

print("less than or equals to = ",a<=b)

Program to print “Hello World” on the screen


print("Hello World")

Program to find the sum of two numbers using input( ) and eval( )
a=eval(input("Enter the first number = "))

b=eval(input("Enter the second number = "))

c=a+b

print("Sum of 2 numbers = ", c)

Program to show the use of logical operators


a=int(input("Enter the first value = "))

b=int(input("Enter the second value = "))

c=int(input("Enter the third value = "))

print("Logical AND = ",((a>b)and(a>c)))

print("Logical OR = ",((a>b)or(a>c)))

print("Logical NOT = ",not(a>b))

Program to swap two numbers using temporary variable


x=2

y=3

temp=x

x=y

y=temp
print(x,y)

You might also like