Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Python 3 Coding Functions: Here is any code required to help code what is below:

ID: 3823256 • Letter: P

Question

Python 3 Coding Functions:

Here is any code required to help code what is below:

def pokemon_by_types(db, types):
new_db = {}
for pokemon_type in types:
for key in db: # iterate through all the type in types list
if db[key][1] == pokemon_type or db[key][2] == pokemon_type:
if key not in new_db:
new_db[key] = db[key]
return new_db

I need help coding the functions listed below in the image:

get types(db): Given a database db, this function determines all the pokemon types in the database. It returns the types as a list of strings, asciibatically sorted (in order based on the ASCII character values). The sorted() function or .sort() method can be helpful here. count by type(db,type): Given a database db and a single pokemon type (as a string) this function collects and reports three statistics l.how many pokemon in db have type as their only type 2. how many dual-type pokemon in db have type as one of their two types 3.a sum of the two values (1 and 2) a A tuple of (single type count, dual type count, total count) should be returned. fastest type(db): Given a database db, determine the type with the highest average speed. Ties are possible, so return a list of types (strings) sorted asciibatically. Hints: The sorted function or .sort() method can be helpful here, as can get types and pokemon by types( legendary count of types(db): Given a database db, for every type in that database, count how many pokemon of that type are legendary. Create a new dictionary to report the counts. It should have one entry for every type in the original database and be structured in the format: type count of legendary. For example, "Fire" 2, Ground 1 Hint get types and pokemon by types() could be helpful here. t team hp(db, team): Given a database db and a list of pokemon names (as strings) team, find out the total hps of all pokemon on that team and return it as an integer. Assume all pokemon on the team are included in the database

Explanation / Answer

public class DoublyLinkedListImpl {

    private Node head;

    private Node tail;

    private int size;

     

    public DoublyLinkedListImpl() {

        size = 0;

    }

  

    private class Node {

        E element;

        Node next;

        Node prev;

        public Node(E element, Node next, Node prev) {

            this.element = element;

            this.next = next;

            this.prev = prev;

        }

    }

  

    public int size() { return size; }

     

    /**

     * return whether the list is empty or not

     * @return

     */

    public boolean isEmpty() { return size == 0; }

     

    /**

     * adds element at the starting of the linked list

     * @param element

     */

    public void addFirst(E element) {

        Node tmp = new Node(element, head, null);

        if(head != null ) {head.prev = tmp;}

        head = tmp;

        if(tail == null) { tail = tmp;}

        size++;

        System.out.println("adding: "+element);

    }

     

    /**

     * adds element at the end of the linked list

     * @param element

     */

    public void addLast(E element) {

         

        Node tmp = new Node(element, null, tail);

        if(tail != null) {tail.next = tmp;}

        tail = tmp;

        if(head == null) { head = tmp;}

        size++;

        System.out.println("adding: "+element);

    }

     

    /**

     * this method walks forward through the linked list

     */

    public void iterateForward(){

         

        System.out.println("iterating forward..");

        Node tmp = head;

        while(tmp != null){

            System.out.println(tmp.element);

            tmp = tmp.next;

        }

    }

     

    /**

     * this method walks backward through the linked list

     */

    public void iterateBackward(){

         

        System.out.println("iterating backword..");

        Node tmp = tail;

        while(tmp != null){

            System.out.println(tmp.element);

            tmp = tmp.prev;

        }

    }

     

    /**

     * this method removes element from the start of the linked list

     * @return

     */

    public E removeFirst() {

        if (size == 0) throw new NoSuchElementException();

        Node tmp = head;

        head = head.next;

        head.prev = null;

        size--;

        System.out.println("deleted: "+tmp.element);

        return tmp.element;

    }

     

    /**

     * this method removes element from the end of the linked list

     * @return

     */

    public E removeLast() {

        if (size == 0) throw new NoSuchElementException();

        Node tmp = tail;

        tail = tail.prev;

        tail.next = null;

        size--;

        System.out.println("deleted: "+tmp.element);

        return tmp.element;

    }

     

    public static void main(String a[]){

         

        DoublyLinkedListImpl<Integer> dll = new DoublyLinkedListImpl<Integer>();

        dll.addFirst(10);

        dll.addFirst(34);

        dll.addLast(56);

        dll.addLast(364);

        dll.iterateForward();

        dll.removeFirst();

        dll.removeLast();

        dll.iterateBackward();

    }

}