Program to Calculate Percentage in Python

Learn via video course
FREE
View all courses
Python Course for Beginners With Certification: Mastering the Essentials
Python Course for Beginners With Certification: Mastering the Essentials
by Rahul Janghu
1000
4.90
Start Learning
Python Course for Beginners With Certification: Mastering the Essentials
Python Course for Beginners With Certification: Mastering the Essentials
by Rahul Janghu
1000
4.90
Start Learning
Topics Covered

Overview

A percentage is the proportion of the totality. In other words, a percentage is a figure or ratio that is written as a fraction of 100. In this article, we calculate the percentage using the Python programming language in three ways.

  1. Calculating Percentage in Python using List Comprehension and len()
  2. Calculating Percentage in Python using filter(), lambda, and len()
  3. Calculating Percentage in Python using list(), map() and find()

Transform Your Career

Choose from our industry-leading programs designed for career success

NSDC Certified

Modern Software and AI Engineering Program

Master full-stack development with AI integration

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Modern Data Science and ML with specialisation in AI

Advanced data science techniques with AI specialization

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Advanced AIML with Specialisation in Agentic AI

Deep dive into AIML with focus on Agentic systems

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

DevOps, Cloud & AI Platform Engineering

Build and manage AI-powered cloud infrastructure

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

AI Engineering Advanced Certification by IIT-Roorkee

Premier AI engineering certification from IIT-Roorkee

3 MonthsDuration
AI-LedCurriculum
Career SupportSupport
Program highlights
Go to Program

Calculating Percentage in Python

We are going to use the input_list and calculate the percentage of the number of even elements in the list.

  • input_list = [2, 7, 6, 3, 19, 8, 14, 26]
  • Number of even elements: 5
  • Percentage of number of even elements in the list: 62.5
  • Explanation: (5/8)100=62.5(5/8)*100 = 62.5

Method 1: Using List Comprehension and len()

Output:

Here, we create a list of even elements using list comprehension and calculate the length of the list using len(). Then divide by the length of the original list and multiply the result by 100 to obtain the percentage count.

Method 2: Calculating Percentage in Python Using filter(), lambda and len()

Output

Using filter() and lambda, we carry out tasks to obtain even elements in the list and then calculate the length of the list using len(). Then divide by the length of the original list and multiply the result by 100 to obtain the percentage count.

Method 3: Calculating Percentage in Python with the use of list(), map(), and find()

Output

Convert all the list elements to string and then check if the numbers in the list start with the digit 6 and add them to the output list. Then divide the lengths of both lists to find the percentage of the count of even values in the input list.

Scaler Placement Report and Statistics

₹23L
AVG CTC
SCALER PLACEMENT PROOF

Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.

11,000+placements
650+companies
Verified data

Similar Python Programs

Conclusion

We used three methods to calculate percentages in the Python programming language.

  1. Using List Comprehension and len()
  2. Using filter(), lambda and len()
  3. Using list(), map() and find()
Hiring Partners:
GoogleGoogleAmazonAmazonMicrosoftMicrosoftFlipkartFlipkartAdobeAdobe1200+ more