-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchallenge2.py
More file actions
189 lines (117 loc) · 2.72 KB
/
Copy pathchallenge2.py
File metadata and controls
189 lines (117 loc) · 2.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# Program to implement Series data structure in Pandas
# import pandas as pd
# # Creating a Series
# data = [10, 20, 30, 40, 50]
# series = pd.Series(data)
# # Display Series
# print("Pandas Series:")
# print(series)
# # Accessing elements
# print("\nFirst Element:")
# print(series[0])
# # Performing operations
# print("\nSeries after adding 5:")
# print(series + 5)
# # Display statistical information
# print("\nMean of Series:")
# print(series.mean())
# Program to implement DataFrame data structure in Pandas
# import pandas as pd
# # Creating a dictionary
# data = {
# "Name": ["Rahul", "Aman", "Priya", "Neha"],
# "Age": [20, 21, 19, 22],
# "Marks": [85, 90, 88, 92]
# }
# # Creating DataFrame
# df = pd.DataFrame(data)
# # Display DataFrame
# print("Pandas DataFrame:")
# print(df)
# # Display column names
# print("\nColumn Names:")
# print(df.columns)
# # Accessing a column
# print("\nName Column:")
# print(df["Name"])
# # Display statistical information
# print("\nAverage Marks:")
# print(df["Marks"].mean())
#pass keyword -- placeholder statement that does nothing , used for empty block ,
# avoid syntax error
# def func():
# pass
#remove duplicates from a list
# using set()
# num = [1,2,3,4,5,6,4]
# unique = list(set(num))
# print("unique list ",unique)
# x = [3,2,1]
# it = iter(x.pop,2)
# print(next(it))
# x = ["A","B"]
# print(x[True],x[False])
# import numpy as np
# a = np.array([[1,2,3],[4,5,6]])
# b = np.array([[7,8,9],[10,11,12]])
# s0 = np.stack((a,b),axis=0)
# d = s0.shape
# print(s0)
# print(d)
# import pandas as pd
# df = pd.DataFrame({"name":['rahul','rohit'],"marks":[34,23]})
# print(df)
# si = pd.Series([10,20,30,40])
# print(si)
#liner search using for loop
# num = [10,20,30,40,50]
# tar = 30
# found = False
# for i in num:
# if i == tar:
# found = True
# break
# print("found" if found else "not found")
# x = (i for i in [1,2,0,5])
# all(x)
# print(next(x))
# x = [1,2,3,4]
# for i in x :
# if i%2 :
# x.remove(i)
# print(x)
# x = map(lambda x: x*2, [1,2,3])
# print(list(zip(x,x)))
# x = iter([1])
# next(x)
# next(x)
# def f():
# return f
# print(f()()() is f)
# x = [1,2,3]
# print((n := len(x)),n)
# l1 = [1,2,3,4,5,6]
# l2 = [1,3,4,5,7,8]
# c = []
# for i in l1:
# if i in l2:
# c.append(i)
# print(i)
# n = [1,2,2,3,4,5,6,7,7]
# un = [i for i in n if n.count(i) == 1]
# print("unique element :",un)
# n = [1,2,3,4,5]
# k = 2
# rotate = n[-k:] + n[:-k]
# print("right rotated",rotate)
# x = 0
# print(x or (x := 5 ))
# print(x)
# num = [1,2,3,4,5]
# k = 2
# rotate = num[k:] + num[:k]
# print("left rotated",rotate)
# print("2026".isdigit())
# print({"python":3.14}.get("java",0))
x = [1,2,3,4]
print(x[:2])