<jupyter_start><jupyter_text>Question 1Write a function that takes a list of lists and returns the value of all of the symbols in it, where each symbol adds or takes something from the total score. Symbol values:* \ = 5* O = 3* X = 1* ! = -1* !! = -3* !!! = -5A list of lists containing 2 s, a O, and a !!! would equal (0 + 5 + 5 + 3 - 5) 8. If the final score is negative, return 0 (e.g. 3 s, 3 !!s, 2 !!!s and a X would be (0 + 5 + 5 + 5 - 3 - 3 - 3 - 5 - 5 + 1) -3, so return 0.Examples:check_score([['', '!'],['!!', 'X']]) ➞ 2check_score([['!!!', 'O', '!'],['X', '', '!!!'],['!!', 'X', 'O']]) ➞ 0<jupyter_code>def check_score(lst:list):
    res = 0
    dct = {'#':5, 'O':3, 'X':1, '!':-1, '!!':-3, '!!!':-5}
    for l in lst:
        for i in l:
            res += int(dct[i])
    if res < 0:
        return 0
    else:
        return res

print(check_score([ ['#', '!'], ['!!', 'X']]))
print(check_score([ ['!!!', 'O', '!'], ['X', '#', '!!!'], ['!!', 'X', 'O'] ]))<jupyter_output>2
0<jupyter_text>Question 2Create a function that takes a variable number of arguments, each argument representing the number of items in a group, and returns the number of permutations (combinations) of items that you could get by taking one item from each group.Examples:    * combinations(2, 3) ➞ 6* combinations(3, 7, 4) ➞ 84* combinations(2, 3, 4, 5) ➞ 120<jupyter_code>def combinations(*args):
    comb = 1
    for a in args:
        comb *= int(a)
    return comb

print(combinations(2, 3))
print(combinations(3, 7, 4))
print(combinations(2, 3, 4, 5))<jupyter_output>6
84
120<jupyter_text>Question 3Create a function that takes a string as an argument and returns the Morse code equivalent.Examples:encode_morse('EDABBIT CHALLENGE') ➞ '. -.. .- -... -... .. - -.-. .... .- .-.. .-... -. --. .'encode_morse('HELP ME !') ➞ '.... . .-.. .--. -- . -.-.--'This dictionary can be used for coding:char_to_dots = {'A': '.-', 'B': '-...', 'C': '-.-.', 'D': '-..', 'E': '.', 'F': '..-.','G': '--.', 'H': '....', 'I': '..', 'J': '.---', 'K': '-.-', 'L': '.-..','M': '--', 'N': '-.', 'O': '---', 'P': '.--.', 'Q': '--.-', 'R': '.-.','S': '...', 'T': '-', 'U': '..-', 'V': '...-', 'W': '.--', 'X': '-..-','Y': '-.--', 'Z': '--..', ' ': ' ', '0': '-----','1': '.----', '2': '..---', '3': '...--', '4': '....-', '5': '.....','6': '-....', '7': '--...', '8': '---..', '9': '----.','&': '.-...', "'": '.----.', '@': '.--.-.', ')': '-.--.-', '(': '-.--.',':': '---...', ',': '--..--', '=': '-...-', '!': '-.-.--', '.': '.-.-.-','-': '-....-', '+': '.-.-.', "": '.-..-.', '?': '..--..', '/': '-..-.'}<jupyter_code>def encode_morse(string):
    char_to_dots = {
    'A': '.-', 'B': '-...', 'C': '-.-.', 'D': '-..', 'E': '.', 'F': '..-.',
    'G': '--.', 'H': '....', 'I': '..', 'J': '.---', 'K': '-.-', 'L': '.-..',
    'M': '--', 'N': '-.', 'O': '---', 'P': '.--.', 'Q': '--.-', 'R': '.-.',
    'S': '...', 'T': '-', 'U': '..-', 'V': '...-', 'W': '.--', 'X': '-..-',
    'Y': '-.--', 'Z': '--..', ' ': ' ', '0': '-----',
    '1': '.----', '2': '..---', '3': '...--', '4': '....-', '5': '.....',
    '6': '-....', '7': '--...', '8': '---..', '9': '----.',
    '&': '.-...', "'": '.----.', '@': '.--.-.', ')': '-.--.-', '(': '-.--.',
    ':': '---...', ',': '--..--', '=': '-...-', '!': '-.-.--', '.': '.-.-.-',
    '-': '-....-', '+': '.-.-.', "": '.-..-.', '?': '..--..', '/': '-..-.'
    }
    return "".join([char_to_dots[x.upper()] for x in string])

print(encode_morse('EDABBIT CHALLENGE'))
print(encode_morse('HELP ME !'))<jupyter_output>.-...--...-.....- -.-......-.-...-...-.--..
......-...--. --. -.-.--<jupyter_text>Question 4Write a function that takes a number and returns True if it's a prime; False otherwise. The number can be 2^64-1 (2 to the power of 63, not XOR). With the standard technique it would be O(2^64-1), which is much too large for the 10 second time limit.Examples:* prime(7) ➞ True* prime(56963) ➞ True* prime(5151512515524) ➞ False<jupyter_code>def prime(n):
    for x in range(2,int(n/2 + 1)):
        if(n % x==0):
            return False
    return True  

print(prime(7))
print(prime(56963))
print(prime(5151512515524))<jupyter_output>True
True
False<jupyter_text>Question 5Create a function that converts a word to a bitstring and then to a boolean list based on the following criteria:1. Locate the position of the letter in the English alphabet (from 1 to 26).2. Odd positions will be represented as 1 and 0 otherwise.3. Convert the represented positions to boolean values, 1 for True and 0 for False.4. Store the conversions into an array.Examples:    * to_boolean_list('deep') ➞ [False, True, True, False]    * deep converts to 0110    * d is the 4th alphabet - 0    * e is the 5th alphabet - 1    * e is the 5th alphabet - 1    * p is the 16th alphabet - 0* to_boolean_list('loves') ➞ [False, True, False, True, True]* to_boolean_list('tesh') ➞ [False, True, True, False]<jupyter_code>def to_boolean_list(s):
    lst = []
    for i in range(len(s)):
        if (ord(s[i]) - 96) % 2 == 0:
            lst.append(False)
        else:
            lst.append(True)
    return lst

print(to_boolean_list('deep'))
print(to_boolean_list('loves'))
print(to_boolean_list('tesh'))<jupyter_output>[False, True, True, False]
[False, True, False, True, True]
[False, True, True, False]
{'fraction_non_alphanumeric': 0.3368640060525818, 'fraction_numerical': 0.03423491583128428, 'mean_word_length': 2.2763320941759604, 'pattern_counts': {'":': 4, '<': 17, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '589392', 'license': 'MIT', 'n_tokens_mistral': 2205, 'n_tokens_neox': 2047, 'n_words': 549, 'path': 'assignments/PythonAdvanceProgramming/Python_Advance_Programming_1.ipynb', 'repo_name': 'sanneabhilash/ineuron_datasciencemasters', 'size': '5287'}