Skip to content
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
43 changes: 43 additions & 0 deletions Question 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# QUESTION-1 Create the class Society with following information:
# society_name, house_no, no_of_members, flat, income
# Methods : An __init__ method to assign initial values of society_name, flat, house_no, no_of_members, income
# input_data() To read information from members
# allocate_flat() To allocate flat according to income using the below table.
# show_data() to display the details of the entire class.

class Society():
def __init__(self,society_name, flat, house_no, no_of_members, income):
self.society_name = society_name
self.flat = flat
self.house_no = house_no
self.no_of_members = no_of_members
self.income = income

def input_data(self):
self.society_name = input("Enter the society name: ")
self.flat = input("Enter the flat: ")
self.house_no = int(input("Enter the house number: "))
self.no_of_members = int(input("Enter the number of members: "))
self.income = int(input("Enter the income: "))
self.allocate_flat()

def allocate_flat(self):
if self.income>=25000:
print("A Type")
elif self.income>=20000 and self.income<25000:
print("B Type")
elif self.income>=15000 and self.income<20000:
print("C Type")
elif self.income<15000:
print("D Type")

def show_data(self):
print("\nsociety name: ", self.society_name, "\nflat name: ", self.flat, "\nhouse number: ", self.house_no, "\nnumber of members: ", self.no_of_members, "\nincome : ", self.income, "\nflat allocation:")
return self.allocate_flat()

a=Society("","", 0, 0, 0)
a.input_data()
a.allocate_flat()
a.show_data()
a.allocate_flat()
a.show_data()
37 changes: 37 additions & 0 deletions Question 2
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Question 2:

class Iteminfo:

def __init__(self,item): #item_code=0, item, price=None, qty=None,net_price=None
self.item_code = 0
self.item=item
self.price = None
self.qty = None
self.net_price = None
self.discount = None

def buy(self):
self.item_code = int(input("Enter the item code: "))
# self.item = input("Enter the item name " )
self.price = int(input("Enter the price: " ))
self.qty = int(input("Enter the quantity: " ))

def calculate_discount(self):
if self.qty <= 10:
self.discount = 0
elif self.qty<=20 and self.qty>=11:
self.discount = 15
elif self.qty>20:
self.discount = 20
self.net_price=(self.price*self.qty - self.discount)
return self.net_price

def show_all(self):
print("\n\nitem code {} \nitem name {} \nprice {} \nquantity {} \ndiscount amount {} \nnet price {}".format(self.item_code, self.item, self.price, self.qty, self.discount, self.net_price))

a=Iteminfo("defter")
a.buy()
# a.show_all()
a.calculate_discount()
a.show_all()

33 changes: 33 additions & 0 deletions Question 3
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Question 3:


class Product():
def __init__(self,product_id,product_name,product_purchase_price,product_sale_price):
self.product_id = product_id
self.product_name = product_name
self.product_purchase_price = product_purchase_price
self.product_sale_price =product_sale_price

def set_remarks(self):
self.margin = self.product_sale_price - self.product_purchase_price
if self.margin<0:
print("Company is on Loss")
elif self.margin>0:
print("Company is on Profit")
print("Net profit per amount is:", self.margin)

def set_details(self):
self.product_id = input("product_id: ")
self.product_name = input("product_name: ")
self.product_purchase_price = int(input("product_purchase_price: "))
self.product_sale_price = int(input("product_sale_price: "))
self.set_remarks()

def get_details(self):
print("product_id: ",self.product_id, "\nproduct_name: ", self.product_name,"\nproduct_purchase_price: ",self.product_purchase_price, "\nproduct_sale_price: ", self.product_sale_price)

a=Product(220,"defter",40,50)
# a.product_name
# a.set_details()
a.set_remarks()
a.get_details()
59 changes: 59 additions & 0 deletions Question 4
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# 4.odev

class Items():
def __init__(self,musteri_kodu):
self.musteri_kodu=musteri_kodu
self.product =["elma", "muz", "patates", "deterjan"]
self.price = {"elma":100, "muz":30,"patates": 50,"deterjan": 120}
self.total_price=0
self.price_tobe_paid=0
self.alinan_urunler=[]
self.alinan_miktarlar=[]
self.eleman=int(input("kac urun alacaksiniz? "))
self.total_discount=0
# self.discount=0

def __str__(self):
print(f"musteri kodu:{self.musteri_kodu} ve urun fiyatlari : {self.price}")

def calculate_discount(self):
for i in range(self.eleman):
self.total_price+=self.price[self.alinan_urunler[i]]*self.alinan_miktarlar[i] #self.katalog[i]
if self.total_price >= 4000:
self.discount=0.25
elif self.total_price >= 2000:
self.discount=0.15
elif self.total_price < 2000:
self.discount=0.1
return self.discount

def shopping_cart(self):
for i in range(self.eleman):
self.urunler=input("alacaginiz urunu giriniz: ")
self.qty=int(input("alacaginiz urunu miktarini giriniz: "))
self.alinan_urunler.append(self.urunler)
self.alinan_miktarlar.append(self.qty)
return self.alinan_urunler, self.alinan_miktarlar

def get_total_amount(self):
self.price_tobe_paid = self.total_price*(1-self.discount)
self.total_discount=self.total_price*self.discount
print(f"toplam odenen:{self.price_tobe_paid} toplam indirim:{self.total_discount}")

class Customer(Items):
def __init__(self,musteri_kodu):
super().__init__(musteri_kodu)

def __str__(self):
return f"musteri kodu:{self.musteri_kodu} aldigi urunler {self.alinan_urunler} ve odedigi miktar {self.price_tobe_paid} ve toplam indirim {self.total_discount}"

a=Items("123")
a.shopping_cart()
a.calculate_discount()
a.get_total_amount()
b=Customer("123")
b.shopping_cart()
b.calculate_discount()
b.get_total_amount()
print(b.price_tobe_paid)
print(b.__str__())
54 changes: 54 additions & 0 deletions TicTacToe
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#tictactoe oyunu
import random
class TicTacToe():

def __init__(self):
self.ilk = random.choice(["x","y"])
self.liste=[0,0,0,0,0,0,0,0,0]

def who_starts(self):
print("oyuna baslayacak kisi ", self.ilk)
print("",self.liste[0],self.liste[1],self.liste[2],"\n",self.liste[3],self.liste[4],self.liste[5],"\n",self.liste[6],self.liste[7],self.liste[8])
self.let_play()

def let_play(self):
if self.ilk=="x":
for i in range(1,10):
if i%2==1:
x=int(input("X numarali oyuncu oynasin: 1-9 arasi"))
self.liste[x-1]="x"
print("",self.liste[0],self.liste[1],self.liste[2],"\n",self.liste[3],self.liste[4],self.liste[5],"\n",self.liste[6],self.liste[7],self.liste[8])

else:
y=int(input("Y numarali oyuncu oynasin: 1-9 arasi"))
self.liste[y-1]="y"
print("",self.liste[0],self.liste[1],self.liste[2],"\n",self.liste[3],self.liste[4],self.liste[5],"\n",self.liste[6],self.liste[7],self.liste[8])

if i>4:
if self.liste[:3]==["x","x","x"] or self.liste[3:6]==["x","x","x"] or self.liste[6:9]==["x","x","x"] or self.liste[::3]==["x","x","x"] or self.liste[1::3]==["x","x","x"] or self.liste[2::3]==["x","x","x"] or self.liste[::4]==["x","x","x"] or self.liste[2:7:2]==["x","x","x"] :
print ("kazanan X oldu")
break
elif self.liste[:3]==["y","y","y"] or self.liste[3:6]==["y","y","y"] or self.liste[6:9]==["y","y","y"] or self.liste[::3]==["y","y","y"] or self.liste[1::3]==["y","y","y"] or self.liste[2::3]==["y","y","y"] or self.liste[::4]==["y","y","y"] or self.liste[2:7:2]==["y","y","y"] :
print ("kazanan y oldu")
break
elif self.ilk=="y":
for i in range(1,10):
if i%2==0:
x=int(input("X numarali oyuncu oynasin: 1-9 arasi"))
self.liste[x-1]="x"
print("",self.liste[0],self.liste[1],self.liste[2],"\n",self.liste[3],self.liste[4],self.liste[5],"\n",self.liste[6],self.liste[7],self.liste[8])

else:
y=int(input("Y numarali oyuncu oynasin: 1-9 arasi"))
self.liste[y-1]="y"
print("",self.liste[0],self.liste[1],self.liste[2],"\n",self.liste[3],self.liste[4],self.liste[5],"\n",self.liste[6],self.liste[7],self.liste[8])

if i>4:
if self.liste[:3]==["x","x","x"] or self.liste[3:6]==["x","x","x"] or self.liste[6:9]==["x","x","x"] or self.liste[::3]==["x","x","x"] or self.liste[1::3]==["x","x","x"] or self.liste[2::3]==["x","x","x"] or self.liste[::4]==["x","x","x"] or self.liste[2:7:2]==["x","x","x"] :
print ("kazanan X oldu")
break
elif self.liste[:3]==["y","y","y"] or self.liste[3:6]==["y","y","y"] or self.liste[6:9]==["y","y","y"] or self.liste[::3]==["y","y","y"] or self.liste[1::3]==["y","y","y"] or self.liste[2::3]==["y","y","y"] or self.liste[::4]==["y","y","y"] or self.liste[2:7:2]==["y","y","y"] :
print ("kazanan y oldu")
break
a=TicTacToe()
print(a.who_starts())