<jupyter_start><jupyter_text>Question1Create a function that takes a string and returns a string in which each character is repeatedonce.Examplesdouble_char('String') ➞ 'SSttrriinngg'double_char('Hello World!') ➞ 'HHeelllloo WWoorrlldd!!'double_char('1234!_ ') ➞ '11223344!!__ '<jupyter_code>def double_char(string:str) -> str:
    return ''.join([c+c for c in string])

print(double_char('String'))
print(double_char('Hello World!'))
print(double_char('1234!_ '))<jupyter_output>SSttrriinngg
HHeelllloo  WWoorrlldd!!
11223344!!__<jupyter_text>Question2Create a function that reverses a boolean value and returns the string 'boolean expected'if another variable type is given.Examplesreverse(True) ➞ Falsereverse(False) ➞ Truereverse(0) ➞ 'boolean expected'reverse(None) ➞ 'boolean expected'<jupyter_code>def reverse(arg:bool) -> bool:
    return not arg if type(arg) == bool else "boolean expected"

print(reverse(True)) # False
print(reverse(False)) # True
print(reverse(0)) # "boolean expected"
print(reverse(None)) # "boolean expected<jupyter_output>False
True
boolean expected
boolean expected<jupyter_text>Question3Create a function that returns the thickness (in meters) of a piece of paper after folding it nnumber of times. The paper starts off with a thickness of 0.5mm.Examplesnum_layers(1) ➞ '0.001m' Paper folded once is 1mm (equal to 0.001m)num_layers(4) ➞ '0.008m' Paper folded 4 times is 8mm (equal to 0.008m)num_layers(21) ➞ '1048.576m' Paper folded 21 times is 1048576mm (equal to 1048.576m)<jupyter_code>def num_layers(n):
    thickness = 0.5
    for _ in range(n):
        thickness *= 2
    return str(thickness / 1000)+'m' # for meters

print(num_layers(1))
print(num_layers(4))
print(num_layers(21))<jupyter_output>0.001m
0.008m
1048.576m<jupyter_text>Question4Create a function that takes a single string as argument and returns an ordered list containingthe indices of all capital letters in the string.Examplesindex_of_caps('eDaBiT') ➞ [1, 3, 5]index_of_caps('eQuINoX') ➞ [1, 3, 4, 6]index_of_caps('determine') ➞ []index_of_caps('STRIKE') ➞ [0, 1, 2, 3, 4, 5]index_of_caps('sUn') ➞ [1]<jupyter_code>def index_of_caps(word):
    indices = []
    for i in range(len(word)):
        if word[i].isupper():
             indices.append(i)
    return indices

print(index_of_caps('BhaNu'))
print(index_of_caps('eDaBiT'))
print(index_of_caps('eQuINoX')) 
print(index_of_caps('determine'))
print(index_of_caps('STRIKE'))
print(index_of_caps('sUn'))<jupyter_output>[0, 3]
[1, 3, 5]
[1, 3, 4, 6]
[]
[0, 1, 2, 3, 4, 5]
[1]<jupyter_text>Question5Using list comprehensions, create a function that finds all even numbers from 1 to the givennumber.Examplesfind_even_nums(8) ➞ [2, 4, 6, 8]find_even_nums(4) ➞ [2, 4]find_even_nums(2) ➞ [2]<jupyter_code>def find_even_nums(n):
    even =[x for x in range(2,n+1) if x % 2 == 0]
    return even

print(find_even_nums(8))
print(find_even_nums(4))
print(find_even_nums(2))<jupyter_output>[2, 4, 6, 8]
[2, 4]
[2]
{'fraction_non_alphanumeric': 0.13394062078272603, 'fraction_numerical': 0.05398110661268556, 'mean_word_length': 6.1791767554479415, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '329812', 'license': 'MIT', 'n_tokens_mistral': 1247, 'n_tokens_neox': 1120, 'n_words': 296, 'path': 'assignments/PythonBasicsProgramming/Programming_Assignment_19.ipynb', 'repo_name': 'sanneabhilash/ineuron_datasciencemasters', 'size': '2964'}