Knowee
Questions
Features
Study Tools

Write a Python program to accept a list of 10 integers and find the frequency ofany given data item (Without using predefined function

Question

Write a Python program to accept a list of 10 integers and find the frequency of any given data item (Without using predefined function)

🧐 Not the exact question you are looking for?Go ask a question

Solution

Sure! Here's a step-by-step solution in Python:

  1. Start by creating an empty list to store the 10 integers:

    numbers = []
    
  2. Use a loop to accept input from the user and add the integers to the list:

    for i in range(10):
        num = int(input("Enter an integer: "))
        numbers.append(num)
    
  3. Next, ask the user for the data item they want to find the frequency of:

    data_item = int(input("Enter the data item to find its frequency: "))
    
  4. Initialize a variable frequency to keep track of the frequency of the data item:

    frequency = 0
    
  5. Use another loop to iterate through the list and count the frequency of the data item:

    for num in numbers:
        if num == data_item:
            frequency += 1
    
  6. Finally, print the frequency of the data item:

    print("The frequency of", data_item, "is", frequency)
    

And that's it! This program will accept a list of 10 integers from the user and find the frequency of a given data item without using any predefined functions.

This problem has been solved

Similar Questions

Given a string, , consisting of alphabets and digits, find the frequency of each digit in the given string.

I have a list sample_data = [1,2,3,4,5,6,7,8,9,10], and I want [1,4,9,16,25,36,49,64,81,100] from it. What should be the possible solution?

Given a list of integers, count and return the number of times each value appears as an array of integers.

Even numbersWrite a Python program to print the even numbers from a list.Sample Test Cases

Given a string as input . Print the frequncy of each character in the string in alphabetical order of characters

1/1

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.