Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onboarding tasks #61

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions task2_coding_exercises/q1_arrays.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ def find_min_index(arr: list[int]) -> int:
@param array of integers
@returns integer index of minimum integer
"""

# insert code here
pass
m = min(arr)
return arr.index(m)


def reverse_str_arr(s: str) -> list[str]:
Expand All @@ -30,9 +31,10 @@ def reverse_str_arr(s: str) -> list[str]:
@param string
@returns array of characters
"""

# insert code here
pass
l = []
for x in reversed(s):
l.append(x)
return l


def most_freq_element(arr: list[int]) -> int:
Expand All @@ -48,5 +50,12 @@ def most_freq_element(arr: list[int]) -> int:
@returns integer value that appears the most frequently in the array
"""

# insert code here
pass
s = set(arr)
m = 0
for i in s:
temp = arr.count(i)
if temp > m:
m = temp
el = i

return el
17 changes: 12 additions & 5 deletions task2_coding_exercises/q2_debugging.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,17 @@ def adjacent_subtraction(arr: list[int]):
@returns array of integers or None
"""
results = []
for i in range(len(arr)):
for i in range(len(arr) - 1):
first = arr[i]
second = arr[i + 1]
results.append(second - first)

return results
if len(arr) == 1:
return arr
elif len(arr) == 0:
return None
else:
return results


def str_math(arr: list[str]):
Expand All @@ -42,8 +47,10 @@ def str_math(arr: list[str]):
total = 0
for s in arr:
try:
total += int(s)
total += float(s)
except:
pass

return total
if arr:
return total
else:
return None
20 changes: 20 additions & 0 deletions task2_coding_exercises/q3_data_science.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,23 @@
"""

# Your code here
import pandas as pd
from matplotlib import pyplot as plt
import matplotlib.transforms as mtransforms


df = pd.read_csv('q3_test_data.csv')
df.ffill()
plt.plot(df['0.1'])
plt.savefig("plot_1.jpg")
plt.clf()
plt.plot(df['0.2'])
plt.savefig("plot_2.jpg")
plt.clf()
plt.plot(df['0.3'])
plt.savefig("plot_3.jpg")
plt.clf()
plt.plot(df['1'])
plt.yscale('log')
plt.savefig("plot_4.jpg")
plt.clf()
Binary file added task2_coding_exercises/q3_plots/plot_1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added task2_coding_exercises/q3_plots/plot_2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added task2_coding_exercises/q3_plots/plot_3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added task2_coding_exercises/q3_plots/plot_4.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading