<jupyter_start><jupyter_text>Question 1:<jupyter_code>In mathematics, the Fibonacci numbers, commonly denoted Fn, form a
sequence, called the Fibonacci sequence, such that each number is the sum of 
the two preceding ones, starting from 0 and 1:
The beginning of the sequence is this:
    
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ...

The function fastFib(num) returns the fibonacci number Fn, of the given num as an argument.
Examples

fib_fast(5) 5
fib_fast(10) 55
fib_fast(20) 6765
fib_fast(50) 12586269025<jupyter_output><empty_output><jupyter_text>Answer :<jupyter_code>from functools import lru_cache

@lru_cache()
def fib_fast(n):
    if n == 0:
        return 0
    if n==1:
        return 1
    else:
        return fib_fast(n-1)+fib_fast(n-2)
    
print(fib_fast(5))
print(fib_fast(10))
print(fib_fast(20))
print(fib_fast(50))<jupyter_output>5
55
6765
12586269025<jupyter_text>Question 2:<jupyter_code>Create a function that takes a strings characters as ASCII and returns 
each characters hexadecimal value as a string.

Examples

convert_to_hex("hello world") "68 65 6c 6c 6f 20 77 6f 72 6c 64"
convert_to_hex("Big Boi") "42 69 67 20 42 6f 69"
convert_to_hex("<NAME>") "4d 61 72 74 79 20 50 6f 70 70 69 6e 73 6f 6e"<jupyter_output><empty_output><jupyter_text>Answer :<jupyter_code>def convert_to_hex(str_):
    h = [i[2::] for i in map(hex,map(ord,str_))]
    return " ".join(h)

print(convert_to_hex("hello world"))
print(convert_to_hex("Big Boi"))
print(convert_to_hex("<NAME>"))<jupyter_output>68 65 6c 6c 6f 20 77 6f 72 6c 64
42 69 67 20 42 6f 69
4d 61 72 74 79 20 50 6f 70 70 69 6e 73 6f 6e<jupyter_text>Question 3:<jupyter_code>Someone has attempted to censor my strings by replacing every vowel
with a *, l*k* th*s. Luckily, I've been able to find the vowels that were
removed.
Given a censored string and a string of the censored vowels, return the
original uncensored string.

Example

uncensor("Wh*r* d*d my v*w*ls g*?", "eeioeo") "Where did my vowels go?"
uncensor("abcd", "") "abcd"
uncensor("*PP*RC*S*", "UEAE") "UPPERCASE"<jupyter_output><empty_output><jupyter_text>Answer :<jupyter_code>def uncensor(str1,str2):
    str_ = ""
    if str2 == "":
        return str1
    lst = list(str2)
    for i in list(str1):
        if i == "*":
            str_ += lst[0]
            lst.pop(0)
            continue
        str_ += i
    return str_


print(uncensor("Wh*r* d*d my v*w*ls g*?", "eeioeo"))
print(uncensor("abcd", ""))
print(uncensor("*PP*RC*S*", "UEAE"))<jupyter_output>Where did my vowels go?
abcd
UPPERCASE<jupyter_text>Question 4:<jupyter_code>Write a function that takes an IP address and returns the domain name
using PTR DNS records.
Example
get_domain("8.8.8.8") "dns.google"
get_domain("8.8.4.4") "dns.google"<jupyter_output><empty_output><jupyter_text>Answer :<jupyter_code>from dns.resolver import resolve_address

def get_domain(IP_address):
    domain = dns.resolver.resolve_address(IP_address)
    return domain[0].to_text()


print(get_domain("8.8.8.8"))
print(get_domain("8.8.4.4"))
import socket

def get_domain(IP_address):
  
    domain = socket.gethostbyaddr(IP_address)
    return result[0].to_text()


print(get_domain("8.8.8.8"))
print(get_domain("8.8.4.4"))<jupyter_output>dns.google
dns.google<jupyter_text>Question 5:<jupyter_code>Create a function that takes an integer n and returns the factorial of
factorials. See below examples for a better understanding:
    
Examples

fact_of_fact(4) 288
# 4! * 3! * 2! * 1! = 288
fact_of_fact(5) 34560
fact_of_fact(6) 24883200<jupyter_output><empty_output><jupyter_text>Answer :<jupyter_code>from functools import lru_cache

@lru_cache()
def fact(n):
    if n==0 or n == 1:
        return 1
    else:
        return n*fact(n-1)

def fact_of_fact(num):
    
    
    factfact = 1
    for i in range(1,num+1):
        factfact *= fact(i)
    return factfact


print(fact_of_fact(4))
print(fact_of_fact(5))
print(fact_of_fact(6))<jupyter_output>288
34560
24883200
{'fraction_non_alphanumeric': 0.12140333165068147, 'fraction_numerical': 0.0706713780918728, 'mean_word_length': 4.496532593619972, 'pattern_counts': {'":': 2, '<': 38, '<?xml version=': 0, '>': 38, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 6, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '10', 'dir': 'jupyter-structured-clean-dedup', 'id': '557371', 'license': 'MIT', 'n_tokens_mistral': 1774, 'n_tokens_neox': 1545, 'n_words': 417, 'path': 'Python Advance Programming Assignment/Assignment_04.ipynb', 'repo_name': 'kpsanjeet/Python-Programming-Basic-Assignment', 'size': '3980'}