Answer to Question #267139 in Python for Matteo Villamor

Question #267139

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.


1
Expert's answer
2021-11-17T06:28:19-0500
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)))



Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS