<jupyter_start><jupyter_text>Question 1:<jupyter_code>Create a function based on the input and output. Look at the examples,
there is a pattern.

Examples

secret("p.one.two.three") "<p class='one two three'></p>"
secret("p.one") "<p class='one'></p>"
secret("p.four.five") "<p class='four five'></p>"<jupyter_output><empty_output><jupyter_text>Answer :<jupyter_code>import re

def secret(str_):
    
    str1 = re.findall("\w+",str_)
    x = str1[0]
    y = " ".join(str1[1::])
    
    return f"<{x} class='{y}'></p>"

print(secret("p.one.two.three"))
print(secret("p.one"))
print(secret("p.four.five"))<jupyter_output><p class='one two three'></p>
<p class='one'></p>
<p class='four five'></p><jupyter_text>question 2:<jupyter_code>Create a function which counts how many lone 1s appear in a given
number. Lone means the number doesn't appear twice or more in a row.

Examples

count_lone_ones(101) 2
count_lone_ones(1191) 1
count_lone_ones(1111) 0
count_lone_ones(462) 0<jupyter_output><empty_output><jupyter_text>Answer :<jupyter_code>def count_lone_ones(num):
    return sum([1 for i in re.findall("1+",str(num)) if len(i)==1])

print(count_lone_ones(101))
print(count_lone_ones(1191))
print(count_lone_ones(1111))
print(count_lone_ones(462))<jupyter_output>2
1
0
0<jupyter_text>Question 3:<jupyter_code>Write a method that accepts two integer parameters rows and cols. 
The output is a 2d array of numbers displayed in column-major order, 
meaning the numbers shown increase sequentially down each column and wrap to 
the top of the next column to the right once the bottom of the current column is reached.

Examples

printGrid(3, 6) [
 [1, 4, 7, 10, 13, 16],
 [2, 5, 8, 11, 14, 17],
 [3, 6, 9, 12, 15, 18]
]

printGrid(5, 3) [
 [1, 6, 11],
 [2, 7, 12],
 [3, 8, 13],
 [4, 9, 14],
 [5, 10, 15]
]

printGrid(4, 1) [
 [1],
 [2],
 [3],
 [4]
]<jupyter_output><empty_output><jupyter_text>Answer :<jupyter_code>def printGrid(r,c):
    
    grid = []
    for i in range(1,r+1):
        temp = [i]
        for j in range(c-1):
            temp.append(temp[~0] + r)
        grid.append(temp)
        
    return grid  
        
for i in printGrid(3, 6):print(i)
print()

for i in printGrid(5, 3):print(i)
print()

for i in printGrid(4, 1):print(i)<jupyter_output>[1, 4, 7, 10, 13, 16]
[2, 5, 8, 11, 14, 17]
[3, 6, 9, 12, 15, 18]

[1, 6, 11]
[2, 7, 12]
[3, 8, 13]
[4, 9, 14]
[5, 10, 15]

[1]
[2]
[3]
[4]<jupyter_text>Question 4:<jupyter_code>Given a list of integers, return the smallest positive integer not present in the list.

Here is a representative example. Consider the list:
[-2, 6, 4, 5, 7, -1, 7, 1, 3, 6, 6, -2, 9, 10, 2, 2]

After reordering, the list becomes:
[-2, -2, -1, 1, 2, 2, 3, 4, 5, 6, 6, 6, 7, 7, 9, 10]
from which we see that the smallest missing positive integer is 8.

Examples

min_miss_pos([-2, 6, 4, 5, 7, -1, 1, 3, 6, -2, 9, 10, 2, 2]) 8
# After sorting, list becomes [-2, -2, -1, 1, 2, 2, 3, 4, 5, 6, 6, 7, 9, 10]
# So the smallest missing positive integer is 8
min_miss_pos([5, 9, -2, 0, 1, 3, 9, 3, 8, 9]) 2
# After sorting, list becomes [-2, 0, 1, 3, 3, 5, 8, 9, 9, 9]
# So the smallest missing positive integer is 2
min_miss_pos([0, 4, 4, -1, 9, 4, 5, 2, 10, 7, 6, 3, 10, 9]) 1
# After sorting, list becomes [-1, 0, 2, 3, 4, 4, 4, 5, 6, 7, 9, 9, 10, 10]
# So the smallest missing positive integer is 1<jupyter_output><empty_output><jupyter_text>Answer :<jupyter_code>def min_miss_pos(lst):
    lst = [i for i in lst if i>0]
    max_num = max(lst)
    set1 = set(lst)
    set2 = set(range(1,max_num+1))
    return min(set2-set1)

print(min_miss_pos([-2, 6, 4, 5, 7, -1, 1, 3, 6, -2, 9, 10, 2, 2]))
print(min_miss_pos([5, 9, -2, 0, 1, 3, 9, 3, 8, 9]))
print(min_miss_pos([0, 4, 4, -1, 9, 4, 5, 2, 10, 7, 6, 3, 10, 9]))<jupyter_output>8
2
1<jupyter_text>Question 5:<jupyter_code>Google is launching a network of autonomous pizza delivery drones and wants you to create a
flexible rewards system (Pizza Points™) that can be
tweaked in the future. The rules are simple: 
if a customer has made at least N orders of at least Y price, they get a FREE pizza!
Create a function that takes a dictionary of customers, a minimum number of orders and a 
minimum order price. Return a list of customers that are eligible for a free pizza.

Examples

customers = {
 "Batman": [22, 30, 11, 17, 15, 52, 27, 12],
 "Spider-Man": [5, 17, 30, 33, 40, 22, 26, 10, 11, 45]
}

 pizza_points(customers, 5, 20) ["Spider-Man"]
 pizza_points(customers, 3, 10) ["Batman", "Spider-Man"]
 pizza_points(customers, 5, 100) []<jupyter_output><empty_output><jupyter_text>Answer :<jupyter_code>def pizza_points(customers,num,price):
    elig_cust = []
    for i in customers.keys():
        temp = [i for i in customers[i] if i>=price]
        if len(temp)>=num:
            elig_cust.append(i)
    return elig_cust


customers = {
 "Batman": [22, 30, 11, 17, 15, 52, 27, 12],
 "Spider-Man": [5, 17, 30, 33, 40, 22, 26, 10, 11, 45]
}

print(pizza_points(customers, 5, 20))
print(pizza_points(customers, 3, 10))
print(pizza_points(customers, 5, 100))<jupyter_output>['Spider-Man']
['Batman', 'Spider-Man']
[]
{'fraction_non_alphanumeric': 0.16421712718009016, 'fraction_numerical': 0.08524397413286303, 'mean_word_length': 4.073558648111332, 'pattern_counts': {'":': 4, '<': 50, '<?xml version=': 0, '>': 53, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '10', 'dir': 'jupyter-structured-clean-dedup', 'id': '651813', 'license': 'MIT', 'n_tokens_mistral': 2451, 'n_tokens_neox': 2074, 'n_words': 691, 'path': 'Python Advance Programming Assignment/Assignment_20.ipynb', 'repo_name': 'kpsanjeet/Python-Programming-Basic-Assignment', 'size': '5103'}