3) i. Common Usage Methods across all Data Structures Examples




The zombies take over the world. There are a few cities that still are holding, but the chances of survival are very less especially for you because you are staying in a treehouse in the middle of nowhere. You found a computer in the basement with a file. The file contains two rows. The first row is the name of a still safe city and the second row is the number of the survivors from that city.
To have the highest chance to survive you need to find the biggest city. Write a program that selects ‘the city with the most survivors’ from a list of cities and another that selects ‘the city with the most number of healthy people’.

1
2
Output:
New Orleans




You are at maths class and your teacher just arrived drunk. He said if you don’t order the class in alphabetical order in 5 minutes, you will fail the whole year.
You got a list of your classmates. Write a program that orders the list into alphabetical order to be able to pass the class.

1
2
Output:
['Annamaria', 'Constantine', 'Emilian', 'Erik', 'Zimbabwe']




You are an agent of the International Spy Agency and your identity was exposed. You need to delete every evidence that points to you. You find a set of documents. You need to know every evidence that points to you, where your name appears.
Write a program that filters out the strings that contain your name from an array of strings.

1
2
3
Output:
My name is Emiliano
['Emiliano is an agent, he must die', 'Emiliano is agent 99']




You are trying to send your ammunition list to the troops deployed on Mars but the Martians hacked your communication. You must code your message to hide the actual number of ammunition from the enemy. For every number, you decided to divide by two that increment by 5, so the Martians will track false information.
Write a program that applies your method to a list of numbers with the ammunition stack.

1
2
3
Output:
Original: [8, 4, 5, 7, 6, 1, 5, 7, 2, 3]
Coded: [9.0, 7.0, 7.5, 8.5, 8.0, 5.5, 7.5, 8.5, 6.0, 6.5]




An asteroid will hit the world and will wipe out every living thing. You have to save the most important people from the planet, otherwise, the future of the human race will be wiped out.
Write a program that stores some of the most important people of Earth than print them to the screen.

1
2
3
4
Output:
('Angelica', '0656484894', 1987)
('Carol Danvers', '14189463', 1999)
('Mark', '165464513', 1897)




You are working to develop a system that decodes the communication of the most dangerous alien species, the ants. They are reversing their messages to code them.
You need to develop a system that decodes the messages sent through a pipeline. Write a program that reverses an input string using slicing.

1
2
Output:
The Earth must be atacked tomorrow




Dragan has a humongous tuple that does not know what to do with it. Help him find: the tuple’s length, the max and min values. What if Dragan needs to know whether or not his tuple contains particular value n?

1
2
3
4
Output:
Total number of subjects =  5
My highest score =  95
My lowest score =  67