Skip to content

Commit 567ebc2

Browse files
Add files via upload
1 parent 94e01de commit 567ebc2

24 files changed

+392
-0
lines changed

add.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
def add (a,b) :
2+
return a+b
3+
print(add(4,5))

cal.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import add
2+
print(__name__)

factorialfunction.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# program to find factorial of a number
2+
3+
import math
4+
5+
def factorial(n):
6+
return(math.factorial(n))
7+
8+
9+
n = int(input("enter number : "))
10+
print("Factorial :",factorial(n))

file.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
with open("sample.txt",'w') as file :
2+
file.write(" 123 ")
3+
4+
s = input("enter file name : ")
5+
name = open(s)
6+
print(name.read())

greater.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# # finding the greatest among the three numbers
2+
3+
4+
# a = [ 3,4,7]
5+
# b = max(a)
6+
# print(b)
7+
8+
9+
10+
def greatest(a,b,c):
11+
if a>b and a>c :
12+
return a
13+
elif b>a and b>c :
14+
return b
15+
else :
16+
return c
17+
18+
a = int(input("enter a : "))
19+
b = int(input("enter b : "))
20+
c = int (input ("enter c : "))
21+
22+
print("greatest number is : ",greatest(a,b,c))

inheritance.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
class Person(object):
2+
def __init__(self, name):
3+
self.name = name
4+
def get_details(self):
5+
return self.name
6+
class Student(Person):
7+
def __init__(self, name, branch, year):
8+
super().__init__(name)
9+
self.branch = branch
10+
self.year = year
11+
def get_details(self):
12+
return "%s studies %s and is in %s year." % (self.name, self.branch, self.year)
13+
class Teacher(Person):
14+
def __init__(self, name, papers):
15+
super().__init__(name)
16+
self.papers = papers
17+
def get_details(self):
18+
return "%s teaches %s" % (self.name, ','.join(self.papers))
19+
person1 = Person('rahul')
20+
student1 = Student('RAHUL', 'IT', 2027)
21+
teacher1 = Teacher('dimple', ['python'])
22+
print(person1.get_details())
23+
print(student1.get_details())
24+
print(teacher1.get_details())

init.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Student(object):
2+
def __init__(self, name, branch, year):
3+
self.name = name
4+
self.branch = branch
5+
self.year = year
6+
print("A student object is created.")
7+
def print_details(self):
8+
print("Name:", self.name)
9+
print("Branch:", self.branch)
10+
print("Year:", self.year)
11+
a = Student('rahul' , ' it' , ' 2027')
12+
a.print_details()
13+

logo.py

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import tensorflow as tf
2+
from tensorflow.keras import datasets, layers, models
3+
from tensorflow.keras.preprocessing.image import ImageDataGenerator
4+
import matplotlib.pyplot as plt
5+
6+
# Load dataset - here we're assuming the dataset is already prepared and split into folders (train, test)
7+
train_dir = "path_to_train_data"
8+
test_dir = "path_to_test_data"
9+
10+
# Image augmentation for data preprocessing
11+
train_datagen = ImageDataGenerator(
12+
rescale=1./255,
13+
rotation_range=20,
14+
width_shift_range=0.2,
15+
height_shift_range=0.2,
16+
shear_range=0.2,
17+
zoom_range=0.2,
18+
horizontal_flip=True,
19+
fill_mode='nearest'
20+
)
21+
22+
test_datagen = ImageDataGenerator(rescale=1./255)
23+
24+
train_generator = train_datagen.flow_from_directory(
25+
train_dir,
26+
target_size=(224, 224),
27+
batch_size=32,
28+
class_mode='binary' # Since it's fake vs genuine logo classification
29+
)
30+
31+
test_generator = test_datagen.flow_from_directory(
32+
test_dir,
33+
target_size=(224, 224),
34+
batch_size=32,
35+
class_mode='binary'
36+
)
37+
38+
# Build a CNN model (simple version)
39+
model = models.Sequential([
40+
layers.Conv2D(32, (3, 3), activation='relu', input_shape=(224, 224, 3)),
41+
layers.MaxPooling2D((2, 2)),
42+
layers.Conv2D(64, (3, 3), activation='relu'),
43+
layers.MaxPooling2D((2, 2)),
44+
layers.Conv2D(128, (3, 3), activation='relu'),
45+
layers.MaxPooling2D((2, 2)),
46+
layers.Flatten(),
47+
layers.Dense(512, activation='relu'),
48+
layers.Dense(1, activation='sigmoid') # Binary classification (fake vs genuine)
49+
])
50+
51+
# Compile the model
52+
model.compile(optimizer='adam',
53+
loss='binary_crossentropy',
54+
metrics=['accuracy'])
55+
56+
# Train the model
57+
history = model.fit(train_generator,
58+
steps_per_epoch=100,
59+
epochs=10,
60+
validation_data=test_generator,
61+
validation_steps=50)
62+
63+
# Plot training & validation accuracy and loss
64+
plt.plot(history.history['accuracy'], label='train accuracy')
65+
plt.plot(history.history['val_accuracy'], label='val accuracy')
66+
plt.legend()
67+
plt.show()
68+
69+
plt.plot(history.history['loss'], label='train loss')
70+
plt.plot(history.history['val_loss'], label='val loss')
71+
plt.legend()
72+
plt.show()
73+
74+
# Evaluate the model
75+
test_loss, test_acc = model.evaluate(test_generator, steps=50)
76+
print(f'Test accuracy: {test_acc}')

mergec.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
file1 = file2 = file3 = ""
2+
with open("files/file1") as file1 :
3+
data = file1.readlines()
4+
with open("files/file1") as file1 :
5+
data = file1.readlines()

multiinherit.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class calculation1 () :
2+
def sum(self,a,b):
3+
return a+b;
4+
class calculation2 () :
5+
def multiply(self , a, b ) :
6+
return a*b ;
7+
class derived(calculation1 , calculation2 ):
8+
def divide(self, a, b ):
9+
return a/b;
10+
d= derived()
11+
print(d.sum(10,20))
12+
print(d.multiply(2,3))
13+
print(d.divide(4,2))

0 commit comments

Comments
 (0)