w3resource

Python: Count the number of equal numbers from three given integers

Python Basic - 1: Exercise-86 with Solution

Write a Python program to count the number of equal numbers from three given integers.

Sample Solution:

Python Code:

def test_three_equal(x, y, z):
  result= set([x, y, z])
  if len(result)==3:
    return 0
  else:
    return (4 - len(result))

print(test_three_equal(1, 1, 1))
print(test_three_equal(1, 2, 2))
print(test_three_equal(-1, -2, -3))
print(test_three_equal(-1, -1, -1))

Sample Output:

3
2
0
3

Pictorial Presentation:

Python: Count the number of equal numbers from three given integers.
Python: Count the number of equal numbers from three given integers.

Flowchart:

Flowchart: Python - Count the number of equal numbers from three given integers.

Python Code Editor:

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: Write a Python program to check whether a given string is an "isogram" or not.
Next: Write a Python program to check whether a given employee code is exactly 8 digits or 12 digits.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Follow us on Facebook and Twitter for latest update.