if op == 5:
first = int(input("Give the first value: "))
second = int(input("Give the second value: "))
result = first % second
print("5. Modulus")
print(result)
if op == 6:
first = int(input("Give the base: "))
second = int(input("Give the power value: "))
result = first ^ second
print("6. Exponentiation")
print(result)
else:
print("Please enter the value from 0 - 6")
op = int(input("Option (1 ... 13): "))
if op == 1 or op == 2 or op == 3 or op == 4 or op == 5 or op == 6:
a = int(input("Enter first number"))
b = int(input("Enter second number"))
dict1 = {1: a+b, 2: a-b, 3: a*b, 4: a/b, 5: a % b, 6: a**b}
print("The result is : " + str(dict1.get(op)))
Question:
1. In this program, you are going to create a with getter and setter.
class Option:
def __init__(self):
self._firstnum = 0
def get_firstnum(self):
print("getter method called")
return self._firstnum
def set_firstnum(self, a):
print("setter method called")
self._firstnum = a
def del_firstnum(self):
del self._firstnum
age = property(get_firstnum, set_firstnum, del_firstnum)
mark = Option()
mark.firstnum = 10
#print(mark.firstnum)
op=int(input("Enter an option: "))
if op == 5:
first = int(input("Give the first value: "))
second = int(input("Give the second value: "))
result = first % second
print("5. Modulus")
print(result)
if op == 6:
first = int(input("Give the base: "))
second = int(input("Give the power value: "))
result = first ^ second
print("6. Exponentiation")
print(result)
else:
print("Please enter the value from 0 - 6")
op = int(input("Option (1 ... 13): "))
if op == 1 or op == 2 or op == 3 or op == 4 or op == 5 or op == 6:
print("a is:", mark.firstnum)
a = mark.firstnum
b = int(input("Enter second number"))
dict1 = {1: a+b, 2: a-b, 3: a*b, 4: a/b, 5: a % b, 6: a**b}
print("The result is : " + str(dict1.get(op)))
Comments
Leave a comment