Skip to content

Latest commit

 

History

History
83 lines (81 loc) · 1.5 KB

10. Unit 1 - Lesson 10.md

File metadata and controls

83 lines (81 loc) · 1.5 KB

Assignment Operators

Q1.

x=int(input("x: "))
y=int(input("y: "))
print("x += y: x =",x+y,"and y =",y)
print("x -= y: x =",x-y,"and y =",y)
print("x *= y: x =",x*y,"and y =",y)
print("x /= y: x =",x/y,"and y =",y)
print("x **= y: x =",x**y,"and y =",y)
print("x //= y: x =",x//y,"and y =",y)
print("x %= y: x =",x%y,"and y =",y)
x=y
print("x = y: x =",x,"and y =",y)

Q2.

# Assignment Operators =, +=, -=, *=
x=int(input("x: "))
y=int(input("y: "))
print("x = y:",y)
print("x += y:",x+y)
print("x -= y:",x-y)
print("x *= y:",x*y)

Q3.

# Assignment Operators  /= , %=, **=, //=
x= int(input("x: "))
y = int(input("y: "))
print('x /= y:', x/y)
print ('x %= y:', x%y)
print ('x **= y:', x**y)
print ('x //= y:', x//y)

Bitwise Operators

Q1. 1
Q2.

#Program to illustrate bit wise operators >>, <<
x=int(input("x: "))
y=int(input("y: "))
print(x, ">>",y, "is",x>>y)
print(x, "<<",y, "is",x<<y)

Q3.

#Program to illustrate the bitwise operators &, |
x=int(input("x: "))
y=int(input("y: "))
print(x,"&",str(y)+":",x&y)
print(x,"|",str(y)+":",x|y)

Q4. 1,4
Q5.

#Program to illustrate bitwise operators ~, ^
x=int(input("x: "))
y=int(input("y: "))
print("~",str(x)+":",~x)
print(x,"^",str(y)+":",x^y)

Q6.

x=int(input("x: "))
y=int(input("y: "))
print(x,">>",y,"is",x>>y)
print(x,"<<",y,"is",x<<y)
print(x,"&",y,"is",x&y)
print(x,"|",y,"is",x|y)
print("~",x,"is",~x)
print(x,"^",y,"is",x^y)

Q7.

x=int(input("num1: "))
y=int(input("num2: "))
print("difference:",x-y)