<jupyter_start><jupyter_text>Assignment No.2, By <NAME> - Data Science Batch-1.  Ques1: Create an empty list. Accept 10 numbers from the user and append to it the list if it is an even number.<jupyter_code>def list1(A):
    evenlist = []
    for i in A: 
        if (i % 2 == 0): 
            evenlist.append(i) 
        else:
            print("All/One of the element is not an even number")
    print("Even list:", evenlist) 
A=list()
n=int(input("Enter the size:"))
print("Enter the Element:")
for i in range(int(n)):
    k=int(input(""))
    A.append(k)
list1(A)<jupyter_output>Enter the size:10
Enter the Element:
2
4
6
8
10
22
44
92
18
7
All/One of the element is not an even number
Even lists: [2, 4, 6, 8, 10, 22, 44, 92, 18]<jupyter_text>Ques 2: Create a notebook on LIST COMPREHENSION. This exercise is to put you in a Self learning mode List comprehensions provide us with a simple way to create a list based on some iterable. During the creation, elements from the iterable can be conditionally included in the new list and transformed as needed.An iterable is something you can loop over. If you want a more detailed explanation you can read my previous blog post.The components of a list comprehension are:1. Output Expression (Optional)2. Iterable3. Iterator variable which represents the members of the iterableExample -<jupyter_code>numbers = [1, 2, 3, 4, 5]
squares = [number**2 for number in numbers]
print(squares)<jupyter_output>[1, 4, 9, 16, 25]<jupyter_text>Ques3: In this assignment, given a number n, you have to write a program that generates a dictionary d which contains (i, i*i), where i is from 1 to n (both included). Then you have to just print this dictionary d.Example:Input: 4will give output as{1: 1, 2: 4, 3: 9, 4: 16}Input Format:Take the number n in a single line.Output Format:Print the dictionary d in a single line.<jupyter_code>d=dict()
for i in range(1,9):
    d[i]=i*i
print(d)<jupyter_output>{1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64}<jupyter_text>Ques 4: There is a robot which wants to go the charging point to charge itself. The robot moves in a 2-D plane from the original point (0,0). The robot can move toward UP, DOWN, LEFT and RIGHT with given steps. The trace of robot movement is shown as the following: UP 5 DOWN 3 LEFT 3 RIGHT 2 Then, the output of the program should be: 2 The numbers after the direction are steps. Write a program to compute the distance between the current position after a sequence of movement and original point. If the distance is a float, then just print the nearest integer (use round() function for that and then convert it into an integer).<jupyter_code>import  math
x,y = 0,0
while True:
    s = input().split()
    if not s:
        break
    if s[0]=='UP':                  # s[0] indicates command
        x-=int(s[1])                # s[1] indicates unit of move
    if s[0]=='DOWN':
        x+=int(s[1])
    if s[0]=='LEFT':
        y-=int(s[1])
    if s[0]=='RIGHT':
        y+=int(s[1])
                                    # N**P means N^P
dist = round(math.sqrt(x**2 + y**2))  # euclidean distance = square root of (x^2+y^2) and rounding it to nearest integer
print(dist)<jupyter_output>1
2
3
4
5
UP
{'fraction_non_alphanumeric': 0.0986267166042447, 'fraction_numerical': 0.038077403245942575, 'mean_word_length': 3.4146005509641872, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, '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': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '628509', 'license': 'MIT', 'n_tokens_mistral': 1107, 'n_tokens_neox': 1005, 'n_words': 473, 'path': 'LetsUpgrade_Assignment-2_by_Payal_Mahajan_data-science-batch-1 (1).ipynb', 'repo_name': 'payalmhjn/Data-science_LetsUpgrade', 'size': '3211'}