

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Python program to multiply all numbers in the list?
First we create 3 list for user input .here we use traversing technique. Initializing the value of product to 1, traverse all the element and multiply every number with the product one by one till the end of list.
Example
Input: A=[5,6,3] Output:90 Explanation:5*6*3
Algorithm
Step 1: input all numbers in the list (lst). Step 2: to multiply all values in the list we use traversing technique. Step 3: variable X=1. Step 4: for i in LST /*traverse from first to last in the list X=X*i /* multiply elements one by one Step 5: display X
Example Code
#To multiply all numbers in a list def mulallnum(lst): x=1 for i in lst: x=x*i return x #driver code A=list() B=list() C=list() n1=int(input("Enter the size of the First List ::")) n2=int(input("Enter the size of the Second List ::")) n3=int(input("Enter the size of the Third List ::")) print("Enter the Element of First List ::") for i in range(int(n1)): k=int(input("")) A.append(k) print("Enter the Element of Second List ::") for j in range(int(n2)): k1=int(input("")) B.append(k1) print("Enter the Element of Third List ::") for j in range(int(n3)): k1=int(input("")) C.append(k1) print("MULTIPLY OF ALL NUMBERS IN FIRST LIST ::>",mulallnum(A)) print("MULTIPLY OF ALL NUMBERS IN SECOND LIST ::>",mulallnum(B)) print("MULTIPLY OF ALL NUMBERS IN THIRD LIST ::>",mulallnum(C))
Output
Enter the size of the First List ::3 Enter the size of the Second List ::4 Enter the size of the Third List ::5 Enter the Element of First List :: 1 2 5 Enter the Element of Second List :: 3 2 4 5 Enter the Element of Third List :: 12 2 1 3 2 MULTIPLY OF ALL NUMBERS IN FIRST LIST ::> 10 MULTIPLY OF ALL NUMBERS IN SECOND LIST ::> 120 MULTIPLY OF ALL NUMBERS IN THIRD LIST ::> 144
- Related Questions & Answers
- C# program to multiply all numbers in the list
- Python Program to Multiply All the Items in a Dictionary
- C++ Program to Multiply two Numbers
- How to multiply large numbers using Python?
- How to multiply large numbers with all digits in the output in R?
- Java program to multiply given floating point numbers
- 8051 Program to Multiply two 8 Bit numbers
- 8085 Program to Multiply two 8 bits numbers
- 8085 program to multiply two 8 bit numbers
- 8086 program to multiply two 8-bit numbers
- 8086 program to multiply two 16-bit numbers
- C Program to Multiply two Floating Point Numbers?
- Java Program to Multiply Two Floating-Point Numbers
- Golang Program to Print the Sum of all the Positive Numbers and Negative Numbers in a List
- Python program to multiply two matrices
Advertisements