fork download
  1. class SimpleCalculator:
  2. def add(self, x, y):
  3. return x + y
  4.  
  5. def subtract(self, x, y):
  6. return x - y
  7.  
  8. def multiply(self, x, y):
  9. return x * y
  10.  
  11. def divide(self, x, y):
  12. if y == 0:
  13. return "Error! Division by zero."
  14. else:
  15. return x / y
  16.  
  17. def modulus(self, x, y):
  18. return x % y
  19.  
  20. def square(self, x):
  21. return x ** 2
  22.  
  23. # إنشاء مثال على الآلة الحاسبة
  24. calculator = SimpleCalculator()
  25.  
  26. # استخدام الآلة الحاسبة كمثال
  27. # استبدل هذه القيم بالمدخلات الفعلية
  28. x = 10
  29. y = 5
  30.  
  31. # تنفيذ العمليات
  32. print(f"الجمع: {calculator.add(x, y)}")
  33. print(f"الطرح: {calculator.subtract(x, y)}")
  34. print(f"الضرب: {calculator.multiply(x, y)}")
  35. print(f"القسمة: {calculator.divide(x, y)}")
  36. print(f"المودولو: {calculator.modulus(x, y)}")
  37. print(f"التربيع: {calculator.square(x)}")
  38.  
Success #stdin #stdout 0.03s 9028KB
stdin
Standard input is empty
stdout
الجمع: 15
الطرح: 5
الضرب: 50
القسمة: 2.0
المودولو: 0
التربيع: 100