No products in the cart.

Write a program to find mode …

CBSE, JEE, NEET, CUET

CBSE, JEE, NEET, CUET

Question Bank, Mock Tests, Exam Papers

NCERT Solutions, Sample Papers, Notes, Videos

Write a program to find mode of the list in Python?
  • 2 answers

Aries 24 3 years, 9 months ago

print("calculating mode of N number") || n=int(input("how many no. are there")) || nums=[ ] for i in range(n) : || a=int(input(" Enter no. ")) || nums.append(a) || difnums={ } || for x in nums: || if x not in difnums: || difnums[x]=1 || else: || difnums[x] +=1 | print(" No. With their frequency are") || maxfreq=0 || mode=0 for d in difnums. || keys( ) : || print(d, "comes", difnums[d], " times") || if difnums[d] > maxfreq: || maxfreq=difnums[d] || mode =d print("mode is", mode) || (|| means next line)

Aries 24 3 years, 9 months ago

print("calculating mode of N number") n=int(input("how many no. are there")) nums=[ ] for i in range(n) : a=int(input(" Enter no. ")) nums.append(a) difnums={ } for x in nums: if x not in difnums: difnums[x]=1 else: difnums[x] +=1 print(" No. With their frequency are") maxfreq=0 mode=0 for d in difnums. keys( ) : print(d, "comes", difnums[d], " times") if difnums[d] > maxfreq: maxfreq=difnums[d] mode =d print("mode is", mode)
http://mycbseguide.com/examin8/

Related Questions

Define packages
  • 0 answers
Write a program for swapping two numbers?
  • 0 answers
What is alu
  • 1 answers
Write a program for swapping two numbers
  • 1 answers

myCBSEguide App

myCBSEguide

Trusted by 1 Crore+ Students

Test Generator

Test Generator

Create papers online. It's FREE.

CUET Mock Tests

CUET Mock Tests

75,000+ questions to practice only on myCBSEguide app

Download myCBSEguide App