Skip to content

Sinem Gençer DataScience #42

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

Open
wants to merge 1 commit into
base: master
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
Binary file not shown.
Binary file not shown.
Binary file added Week04/__pycache__/arrays_oguz_aydin.cpython-313.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
29 changes: 29 additions & 0 deletions Week04/arrays_sinem_gencer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import numpy as np

def replace_center_with_minus_one(d, n, m):
"""
Check if inputs are valid
"""
if d <= 0 or n <= 0 or m <= 0:
raise ValueError("Parameters d, n, and m must be positive integers.")
if m > n:
raise ValueError("Center size m cannot be greater than array size n.")
"""
Create array of nxn size filled with random values using d
"""
outer_min = 10 ** (d - 1)
outer_max = 10 ** d
arr = np.random.randint(outer_min, outer_max, size=(n, n))

"""
Get indices for center according to m value given
"""
start = (n - m) // 2
end = start + m

"""
Fill mxm array in the center with -1
"""
arr[start:end, start:end] = -1

return arr
Loading