برنامج ياخذ رقمين صحيحين ويقوم بإرجاع ضربهم وإذا كان ضربهم أكبر من 1000 يرجع مجموعهم

  • برمجة
  • برمجة بايثون

اكتب برنامج ياخذ رقمين صحيحين ويقوم بإرجاع ضربهم وإذا كان ضربهم أكبر من 1000 يرجع مجموعهم 

الأجوبة

def multiplication_or_sum(num1, num2):
    # calculate product of two number
    product = num1 * num2
    # check if product is less then 1000
    if product <= 1000:
        return product
    else:
        # product is greater than 1000 calculate sum
        return num1 + num2


# first condition
result = multiplication_or_sum(20, 30)
print("The result is", result)

# Second condition
result = multiplication_or_sum(40, 30)
print("The result is", result)
هل كان المحتوى مفيد؟

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...