#----------------------------- 1 - Adding list of elements ---------------------------
# initalizing an empty list to add n elements
list = []
elements = int(input("Enter the number of elements : "))
# getting the elements from user
for i in range (elements):
print(i+1,end=".")
number = int(input("Enter the number : "))
list.append(number)
values =list
sum= 0
# adding list of numbers
for i in range(elements):
sum = sum + list[i]
print("The total of the given nyumbers is ",sum)
#----------------------------- 2 - Adding list of elements using function ------------
list = []
elements = int(input("Enter the number of elements : "))
def addition(values):
if values ==0:
return 1
sum = 0
# adding list of numbers
for i in range(elements):
sum = sum + list[i]
print("The total of the given nyumbers is ",sum)
for i in range (elements):
print(i+1,end=".")
number = int(input("Enter the number : "))
list.append(number)
addition(list)
#----------------------------- 3 - Finding maximum using if else ------------------
# Getting the input from user
a = int(input("Enter the 1st number: "))
b = int(input("ENter the 2nd number :"))
# Finding maximum using if else
if (a> b):
print(a," is greater than ",b)
elif(a == b):
print(a," is equal to ",b)
else:
print(b," is greater than ",a)
#----------------------------- 4 - Finding maximum using function ------------------
# finding maximum using function
def maximum(x, y):
if x >= y:
return x
else:
return y
# Gettingh the input from user
a = int(input("Enter the 1st number: "))
b = int(input("ENter the 2nd number :"))
print("The maximimum value is : ",maximum(a, b))
#----------------------------- 5 - Finding maximum using max() -----------------------
# finding maximum using max()
a = int(input("Enter the 1st number: "))
b = int(input("ENter the 2nd number :"))
maximum = max(a,b)
print("The maximum value is :", maximum)