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

Task 1 by Dev #8

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
12 changes: 12 additions & 0 deletions DevTask1/partA.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import numpy as np
import math
num = 100
ycap = np.random.rand(num)
ycap1 = 1 - ycap
y = np.random.randint(0,2,(num))
y1 = 1 - y
sum = 0
for i in range(0,num):
sum = sum + y[i]*(math.log(ycap[i],2)) + y1[i]*(math.log(ycap1[i],2))
O = (-1)*sum/num
print(O)
16 changes: 16 additions & 0 deletions DevTask1/partB.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class partB():
def __init__(self, list, target):
self.nlist = list
self.dict = {}
self.count = 0
self.target = target
def find(self):
for i in range(0, len(self.nlist)):
for j in range(0, len(self.nlist)):
if self.nlist[i] + self.nlist[j] == self.target:
self.dict[self.count] = [i, j]
self.count += 1
print(self.dict)

x = partB([10,20,10,40,50,60,70], 50)
x.find()