Basic Python Programs – 1

#----------------------------- 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)

Join our team, where career growth knows no limits.

For More Details

Our internship program guarantees personalized attention for optimal career development in the tech industry.

+91 97879 68375

-> You should bring your own laptop during the internship

Who can apply?

Internships are open for students who: B.E / B.Tech / M.E / M.Tech / B.Sc / M.Sc / M.C.A / B.C.A / Diploma.

  • Ongoing Students Only
  • days, 5days/ 10days or Based on Student Preference
  • Limited 1 to 10 students per slot
  • Registration fees : 1000 INR
  • Slots are filling quickly only fewer slots are available