College_Sample2

  1. Python Program to Find the Largest Number in a List

  2. Python Program to Find the Second Largest Number in a List

  3. Python Program to Put Even and Odd elements in a List into Two Different Lists.

  4. Python Program to check whether two lists are same.

  5. Python Program to Find the Union of Lists.

  6. Python Program to Find the Intersection of Lists.

  7. Python Program to find union and intersection of lists without repetition.

  8. Python Program to Create a List of Tuples with the First Element as the Number and Second Element as the Square of the Number.

  9. Python Program to Remove the Duplicate Items from a List.

  10. Python Program to Read a List of Words and Return the Length of the Longest One.

  11. Python Program to Add a Key-Value Pair to the Dictionary

  12. Python Program to Concatenate Two Dictionaries Into One

  13. Python Program to Check if a Given Key Exists in a Dictionary or Not

  14. Python Program to Generate a Dictionary that Contains Numbers (between 1 and n) in the Form (x,x*x).

  15. Python Program to Sum All the Items in a Dictionary

  16. Python Program to Multiply All the Items in a Dictionary

  17. Python Program to Remove the Given Key from a Dictionary

  18. Write a function is_empty(my_dict) that takes a dictionary my_dict and returns True if my_dict is empty and False otherwise.

  19. Write a function make_dict(key_value_list) that takes a list of tuples key_value_list where each tuple is of the form (key, value) and returns a dictionary with these keys and corresponding values.

  20. A simple substitution cipher is an encryption scheme where each letter in an alphabet to replaced by a different letter in the same alphabet with the restriction that each letter's replacement is unique. The template for this question contains an example of a substitution cipher represented a dictionary CIPHER_DICTIONARY. Your task is to write a function encrypt(phrase,cipher_dict) that takes a string phrase and a dictionary cipher_dict and returns the results of replacing each character in phrase by its corresponding value in cipher_dict.

    CIPHER_DICT = {'e': 'u', 'b': 's', 'k': 'x', 'u': 'q', 'y': 'c', 'm': 'w', 'o': 'y', 'g': 'f', 'a': 'm', 'x': 'j', 'l': 'n', 's': 'o', 'r': 'g', 'i': 'i', 'j': 'z', 'c': 'k', 'f': 'p', ' ': 'b', 'q': 'r', 'z': 'e', 'p': 'v', 'v': 'l', 'h': 'h', 'd': 'd', 'n': 'a', 't': ' ', 'w': 't'}
    

    encrypt("cat", CIPHER_DICT) should return ”km “

  21. Write a function make_cipher_dict(alphabet) that takes a string of unique characters and returns a randomly-generated cipher dictionary for the characters in alphabet . You should use the shuffle() method in the random module to ensure that your returned cipher dictionary is random.

  22. Write a python code to generate grade using dictionary. Dictionary should have student names as keys (assuming names are unique) and subject_name and mark as value. There are 5 subjects for each student. Marks should be converted to grades (90 – 100 A+, 80-89 A etc).