-1

hi,
I am currently taking a pyton programming class and having some extreme difficulties. I am in quite the pickle with these 3 prompts. I do not know where to start for any of these prompts; if anyone has any code or solutions to any of these three promps I will be very grateful.

Prompt 1:
Write a program that creates a dictionary of son-father pairs, you can use celebrities, fictional characters, or even historical figures for fun. Your program should present the user a menu with three options. The following is an example.

0 - Quit
1 - Find a Father
2 - Find a Grandfather

Option 0 should end the program.

Option 1 should prompt the user for the name of a son. If the dictionary contains the son-father pair, the program should display the father. Otherwise, the program should tell the user it doesn't know who the father is.

Option 2 should prompt the user for the name of a grandson. If the dictionary contains enough information, the program should display the grandson's grandfather. Otherwise, the program should tell the user it doesn't know who the grandfather is.

The dictionary you create should include several geneartions so that a grandfather can be found given the name of a grandson.

Prompt 2:

Write a program to sort a list of numbers using the insertion sort algorithm (one of the many sorting algorithms). Given a list, insertion sort works by taking elements from the list one by one and inserting them in their correct position into a new sorted list. Here is the list of numbers you are going to use in your program, nlist = [345, 100, 50, 400, 900, 1000, 45, 295]. Your program needs to sort the numbers from the smallest to the largest. Then display the numbers, in order.

Promt 3:

Write a program to solve the following two tasks. (1) Turn a list into a dictionary. Here is the list of words, wlist = [“beetle”, “beef”, “apple”, “air”, “cat”, “dog”, “bicycle”, “dig”, “feet”, “five”, “kite”, “goat”, “high”, “warm”, “wolf”, “hot”, “xylophone”, “yuk”, “yum”, “zoo”]. The dictionary your program creates should have all the words as the values and their first letters as the keys (such that “a”-[“air”, “apple”] will be one of the key-value pairs of the dictionary). (2) Then, your program should look up a particular word “cat” in the dictionary, and report if the word is in the dictionary.

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by pyTony
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.