From 5cb2134c25ddc4f6d10c891c27b7b93befc39ae8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sinem=20I=C5=9F=C4=B1k?= <154877909+Sinemsss@users.noreply.github.com> Date: Sun, 9 Mar 2025 16:46:05 +0300 Subject: [PATCH] =?UTF-8?q?Create=20weighted=5Fsinem=5F=C4=B1=C5=9F=C4=B1k?= =?UTF-8?q?.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "weighted_sinem_\304\261\305\237\304\261k.py" | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 "weighted_sinem_\304\261\305\237\304\261k.py" diff --git "a/weighted_sinem_\304\261\305\237\304\261k.py" "b/weighted_sinem_\304\261\305\237\304\261k.py" new file mode 100644 index 0000000..f4cfd63 --- /dev/null +++ "b/weighted_sinem_\304\261\305\237\304\261k.py" @@ -0,0 +1,8 @@ +import random +def weighted_srs(data, n, weights, with_replacement): + return random.choices(data, weights=weights, k=n) if + data = ['sinem', 'muhammet', 'selim', 'seher'] +weights = [11, 23, 9, 7] +n = 2 +print(weighted_srs(data, n, weights, True)) +print(weighted_srs(data, n, weights, False))