Write simple Python program using operators: Arithmetic Operators, Logical Operators, Bitwise Operators
1.Write a program to convert U.S. dollars to Indian rupees.
#Byte to MB , GB and TB
bt = int(input("Enter Bit value = "))
byte= bt/8
mb = byte/1000000
gb = mb/1000
tb= gb/1000
print("\n" + str(bt) + " bit" + " = " + str(mb) + " mb")
print("\n" + str(bt) + " bit" + " = " + str(gb) + " gb")
print("\n" + str(bt) + " bit" + " = " + str(tb) + " tb")
Output -
Write simple Python program using operators: Arithmetic Operators, Logical Operators, Bitwise Operators |
2.Write a program to convert bits to Megabytes, Gigabytes and Terabytes
#Byte to MB , GB and TB
bt = int(input("Enter Bit value = "))
byte= bt/8
mb = byte/1000000
gb = mb/1000
tb= gb/1000
print("\n" + str(bt) + " bit" + " = " + str(mb) + " mb")
print("\n" + str(bt) + " bit" + " = " + str(gb) + " gb")
print("\n" + str(bt) + " bit" + " = " + str(tb) + " tb")
Output-
Write simple Python program using operators: Arithmetic Operators, Logical Operators, Bitwise Operators |
3. Write a program to find the square root of a number
# Write a program to find the square root of a number
number = int(input("Enter number to find square root = "))
sqrt = number ** 0.5
print("\nSquare root of " + str(number) + " = ",sqrt)
Output -
Write simple Python program using operators: Arithmetic Operators, Logical Operators, Bitwise Operators |
4.Write a program to calculate area and
perimeter of the square
# Write a program to calculate area and perimeter of the square
side = int(input("Enter side of square = "))
print("\nArea of square = " , (side * side))
print("\nPerimeter of square = " , (4 * side))
Output-
Write simple Python program using operators: Arithmetic Operators, Logical Operators, Bitwise Operators |
5.Write a program to calculate surface volume and area of a cylinder.
# Write a program to calculate surface volume and area of a cylinder.
PI = 3.14
radius = int(input("Enter radius of cylinder = "))
height = int(input("Enter height of cylinder = "))
print("\nSurface volume of cylinder = " + str(2 * PI * radius * radius + 2 * PI * radius * height))
print("\nArea of cylinder = " + str(PI * radius * radius * height))
Output-
Write simple Python program using operators: Arithmetic Operators, Logical Operators, Bitwise Operators |
6.Write a program to swap
the value of two variables
# Write a program to swap the value of two variables
x = int(input("Enter first number = "))
y = int(input("Enter second number = "))
print("\nBefore swap : ")
print("\nx = " + str(x) + " , y = " + str(y))
temp = x
x = y
y = temp
print("\nAfter swap : ")
print("\nx = " + str(x) + " , y = " + str(y))
Output-
Write a program to swap the value of two variables |