Learn practical skills, build real-world projects, and advance your career
Created 4 years ago
Question 1:
Given a two integer numbers return their product and if the product is greater than 1000, then return their sum
def fun(num1,num2):
mul = num1 * num2
if mul <1000:
return mul
else:
return num1+num2
fun(34,122), fun(22,3)
(156, 66)
Question 2:
Given a range of first 10 numbers, Iterate from start number to the end number and print the sum of the current number and previous number
nums = [1,2,3,4,5,6,7,8,9,10]
for i in nums:
print(i+ i-1)
1
3
5
7
9
11
13
15
17
19
Question 3:
Given a string, display only those characters which are present at an even index number.