-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDemo.py
More file actions
23 lines (19 loc) · 686 Bytes
/
Demo.py
File metadata and controls
23 lines (19 loc) · 686 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#Exercise 1: Calculate the multiplication and sum of two numbers
# Given two integer numbers,
# write a Python code to return their product only if the product is equal to or lower than 1000.
# Otherwise, return their sum.
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)