Write simple Python program using operators: Arithmetic Operators, Logical Operators, Bitwise Operators | programming yash
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 |
Tags -
"python operator"
"python logical operator"
"python bitwise operator"
"python programming"
"python for programmers"
"what's python programming"
"python programming basics"
"python programming examples"
"python programming practice"
"python programming language"
"python as programming language"
"python programming for beginners"
"python programming beginners"
"python for programmers pdf"
"python programming questions"
"python programming pdf"
"python programming hello world"
"python operators list"
"python programming interview questions"
"python and operator"
"python operators precedence"
"python programming online"
"python programming tutorial"
"python programming tutorialspoint"
"who developed python programming language"
"python programming book"
"python programming questions and answers"
"python programming learning"
"conditional operator in python"
"xor operator in python"
"modulo operator in python"
modulus operator in python"
python programming examples pdf
python programming book pdf
introduction to python programming
python programming code
Comments
Post a Comment