Question

In Python Develop a program that uses a list or dictionary that can be searched.   The...

In Python

Develop a program that uses a list or dictionary that can be searched.   The program should do some kind of processing of list or dictionary members.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
def search(lst,key):
    for x in range(len(lst)):
        if(lst[x] == key):
            return "element "+str(key)+" is at index "+str(x)
    return "element "+str(key)+" not found"

#Testing
print(search([2, 5, 7, 9, 12, 15] ,12))

Note:

It is the program using list

Add a comment
Know the answer?
Add Answer to:
In Python Develop a program that uses a list or dictionary that can be searched.   The...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • python Programming. In this program you can use if, else and elif or list and dictionary....

    python Programming. In this program you can use if, else and elif or list and dictionary. If your loaf of bread has passed its expiration date and has become stale or is smooshed/damaged, or your bread smells sour or has colored spots on it, then throw it out.

  • PYTHON PROGRAM by using functions & dictionary or set. - must create a variable to hold...

    PYTHON PROGRAM by using functions & dictionary or set. - must create a variable to hold a dictionary or sets - must define a function that accepts dictionaries or sets as an argument A dictionary maps a set of objects (keys) to another set of objects (values). A Python dictionary is a mapping of unique keys to values. For e.g.: a dictionary defined as: released = { "iphone" : 2007, "iphone 3G": 2008, "iphone 3GS": 2009, "iphone 4" : 2010,...

  • THIS IS A PROGRAM FOR PYTHON THIS IS A PROGRAM FOR PYTHON THIS IS A PROGRAM...

    THIS IS A PROGRAM FOR PYTHON THIS IS A PROGRAM FOR PYTHON THIS IS A PROGRAM FOR PYTHON This time, we will write a program that uses functions to parse through all those names in a List object (see below for the "us_counties" list) to count the number of occurrences each vowel (a, e, i, o, u) has in all the names. We want 5 separate answers, one for each vowel. Not looking for output here. All my solution will...

  • Python Modify your program from Learning Journal Unit 7 to read dictionary items from a file...

    Python Modify your program from Learning Journal Unit 7 to read dictionary items from a file and write the inverted dictionary to a file. You will need to decide on the following: How to format each dictionary item as a text string in the input file. How to covert each input string into a dictionary item. How to format each item of your inverted dictionary as a text string in the output file. Create an input file with your original...

  • in python: Write a program that uses a two-dimensional list that has 4 rows, with 5...

    in python: Write a program that uses a two-dimensional list that has 4 rows, with 5 columns in each row. The program should do the following things 1. Create or fill in the list so that it has random numbers between 0 and 50. 2. Print the entire list using a loop.

  • Write a Python equivalent program for the Unix spell utility. You can use the dictionary at /usr/...

    Write a Python equivalent program for the Unix spell utility. You can use the dictionary at /usr/share/dict/words (if you machine does not have it, you can copy it from a Linux machine such as npu29). The minimum requirement is to check if each word in the file exists in the dictionary as is (case insensitive). Your spell checker should inlcude at least two features: 1. Check the simple plural forms (add s or es). 2. Check the simple verb past...

  • (IN PYTHON) You are to develop a Python program that will read the file Grades-1.txt that...

    (IN PYTHON) You are to develop a Python program that will read the file Grades-1.txt that you have been provided on Canvas. That file has a name and 3 grades on each line. You are to ask the user for the name of the file and how many grades there are per line. In this case, it is 3 but your program should work if the files was changed to have more or fewer grades per line. The name and...

  • IN python, Write a program that creates a dictionary containing course numbers and the room numbers...

    IN python, Write a program that creates a dictionary containing course numbers and the room numbers where the courses meet. The dictionary should contain the following key:value pairs. Course Number (key) Room Number (value) CS101 3004 CS102 4501 CS103 6755 NT110 1244 CM241 1411 The program should also create a dictionary containing course numbers and the names of the instructors that teach each course. The dictionary should have the following key:value pairs. Course Number (key) Instructor (value) CS101 Haynes CS102...

  • in python Write a program that keeps a dictionary in which both keys and values are...

    in python Write a program that keeps a dictionary in which both keys and values are strings—names of students and their course grades. Prompt the user of the program to add or remove students, to modify grades, or to print all grades. The printout should be sorted by name and formatted like this: Carl: B- Joe: C Sarah: A Francine: A

  • 3 Dn Ent Write a python program to create a Dictionary named grade with the given...

    3 Dn Ent Write a python program to create a Dictionary named grade with the given items and do the below operations: i. 15 i. Create Dictionary with keys-{'Monday', 'Tuesday', 'Wednesday Thursday', 'Friday') ii. values-{1, 2, 3, 4, 5) ii. Now append another item with key-'Saturday') and value-(63 to the already created Dictionary and print it.

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT