diff --git a/Question 1 b/Question 1 new file mode 100644 index 0000000..7fcfa22 --- /dev/null +++ b/Question 1 @@ -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() diff --git a/Question 2 b/Question 2 new file mode 100644 index 0000000..e1086a8 --- /dev/null +++ b/Question 2 @@ -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() + diff --git a/Question 3 b/Question 3 new file mode 100644 index 0000000..b99f623 --- /dev/null +++ b/Question 3 @@ -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() diff --git a/Question 4 b/Question 4 new file mode 100644 index 0000000..5756677 --- /dev/null +++ b/Question 4 @@ -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__()) diff --git a/TicTacToe b/TicTacToe new file mode 100644 index 0000000..e2dcbbb --- /dev/null +++ b/TicTacToe @@ -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())