Sum of numbers divisible by 3 and 5 in python

Sum of numbers divisible by 3 and 5 in python using for loop. This python program with source code is discussed in this post. This python project is useful for beginners and CBSE KV School Class 11 and Class 12 students computer science practical file and NIELIT O Level Programming and Problem Solving through Python ( Module M3-R5).


Write a function Div3and5() that takes a 10 elements numeric tuple and return the sum of elements which are divisible by 3 and 5

Python Program Source Code

Explanation of Code – Sum of numbers divisible by 3 and 5 in python program

def Div3and5(t): #a function named Div3and5(t) is initialized
s=0 #sum variable =0
for i in t: #for loop ends at the length of tupple
if i%3==0 and i%5==0: # checks its divisiblity from 3 and 5
s=s+i # Sum is increased
return s #value is retured from this function
l=[] # I is an array
for i in range(10):# for loop from i=1 to i=10
print(“Enter the “,i+1,”th number of the tuple”,end=””,sep=””) # asks for input
e=int(input()) # e takes integer input
l.append(e) # adds
t=tuple(l) # creating t tupple to show itself in output with all input numbers
print(“Entered tuple :”,t) #shows the tupple
print(“Sum of numbers in tuple divisible by 3 and 5 =”,Div3and5(t)) # print and calls function Is called Div3and5(t) t is the tupple

Output of Python Program

The below shell window show the input entered (numbers for the tuple). The program execute the command and sum the numbers divisible by 3 and 5.

Testing of program
The input of 10 numbers of tupple, 3 number are divisible by 3,5 . the 3 numbers are 15, 60,45 whose sum is 120.

Source code for the “Sum of numbers divisible by 3 and 5” in python program -> click here

for more python programs -> click here

Hello World Program in Python

Input a welcome message and display it in Python

Display the larger / smaller number in Python.

Greatest of Three Numbers in Python using Nested if

Patterns using nested loop in Python

Program to Print Pattern in Python

Program to input the value of x and n and sum of series in Python

Python Program for Armstrong, Prefect Number, Palindrome

Program of Prime number by recursion in python

Prime Number Program in Python

Write a Program to Print Fibonacci Series in Python

LCM and GCD program in Python

Python program to count number of vowels in a string

Whether a String is Palindrome or not in Python

Bubble Sort Program in Python

Linear search in python using list

Program to read a text file in python

Python program to read a file line by line

Program to Count Vowels and Consonants in Python

Stack Program in Python

Queue Program in Python

Python Leap Year Program for Beginners

Python Program to Print Series and Addition

Binary Search Program in Python

Program to find sum of digits in python

Sum of numbers divisible by 3 and 5 in python