Python program without input argument and with return value


This type of function does not have input arguments but has a value to return to the main program.

Write a program to calculate and print sum of first 50 even numbers.

Program:

def sum_even():

sum=0

for i in range(1,51):

sum=sum+2*i

return sum

S=sum_even()

print("Sum of Even Number in Range 1 to 50: ", S)

Output:

Sum of Even Number in Range 1 to 50: 2550



Write a program to input radius of a circle and calculate its area.

def circle():

r=int(input("Enter radius of circle :"))

area=3.14*r*r

return(area)

A=circle()

print("The Area of circle is ", A)

Output:

Enter radius of circle :5

The Area of circle is 78.5



15 views0 comments

Recent Posts

See All

Python program to add one or more element in List

Program: #Append() is used for adding one element in List at the end of list. X=[9,18,27] X.append(36) print(X) output: [9, 18, 27, 36] #Insert () is used for add element at any given position in the

Python program to remove elements of a given list

Program: n=[9,18,27,36,45,54,63] print("List=",n) i=int(input("Enter the position of elements to delete : ")) del n[i] print("List after deletion=",n) del n[:2] print("List after deleting first two el

Python program to create a list of 5 numbers

Python program to create a list of 5 numbers. Numbers entered by User. n=[] for i in range(5): j=int(input("Enter number: ")) n.append(j) print("The List is", n) Output: Enter number: 3 Enter number: