Assignment - 1.ipynb - Colaboratory
Assignment - 1.ipynb - Colaboratory
splitted_string=s.split()
print(splitted_string)
planet = "Earth"
diameter = 12742
d = {'k1':[1,2,3,{'tricky':['oh','man','inception',{'target':[1,2,3,'hello']}]}]}
hello_word= d['k1'][3]['tricky'][3]['target'][3]
print(hello_word)
hello
Numpy
import numpy as np
zeros_array = np.zeros(10)
print(zeros_array)
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
array_of_fives = np.full(10, 5)
print(array_of_fives)
[5 5 5 5 5 5 5 5 5 5]
print(even_numbers)
[20 22 24 26 28 30 32 34]
matrix = np.arange(9).reshape(3, 3)
print(matrix)
[[0 1 2]
[3 4 5]
[6 7 8]]
7. Concatenate a and b
a = np.array([1, 2, 3])
b = np.array([4, 5, 6])
result = np.concatenate((a, b))
print(result)
[1 2 3 4 5 6]
Pandas
import pandas as pd
column1 column
0 0 4
1 1 5
2 2 6
9. Generate the series of dates from 1st Jan, 2023 to 10th Feb, 2023
start_date = "2023-01-01"
end_date = "2023-02-10"
lists = [[1, 'aaa', 22], [2, 'bbb', 25], [3, 'ccc', 24]]
df = pd.DataFrame(lists, columns=columns)
print(df)
ID Name Age
0 1 aaa 22
1 2 bbb 25
2 3 ccc 24