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

Python tasks by ShreyR #12

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
Binary file added .DS_Store
Binary file not shown.
Binary file added ShreyRamanujam/.DS_Store
Binary file not shown.
13 changes: 13 additions & 0 deletions ShreyRamanujam/A.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import random
import math
y1 = []
y2 = [] # Same as y cap
for i in range(100):
y1.append(random.randint(0,1))
y2.append(random.uniform(0,1))
o = 0
for i in range(100):
o += y1[i] * math.log2(y2[i]) + (1 - y1[i]) * math.log2(1-y2[i])

o = -o/100
print("Cross-Entropy loss value is: ", o)
18 changes: 18 additions & 0 deletions ShreyRamanujam/B.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
class numbers():
def __init__(self, numbers):
self.numbers = numbers

def findtargetpairs(self, target):
sno = 1
targetdictionary = {}
for i in range(0, len(self.numbers)):
for j in range(0, len(self.numbers)):
if self.numbers[i] + self.numbers[j] == target:
targetdictionary[sno] = [i, j]
sno += 1
return targetdictionary


mynumbers = numbers([10, 20, 10, 40, 50, 60, 70])
target50 = mynumbers.findtargetpairs(50)
print(target50)