|
| 1 | +""" |
| 2 | +Soru 1 |
| 3 | +Kendisine gönderilen sayılardan sadece palindrom olanları toplayan, diğerlerini de bu toplamdan çıkaran ve geri döndüren fonkisyonu yaz. |
| 4 | +palindrom = 909 , 888, 121 ... |
| 5 | +""" |
| 6 | + |
| 7 | +def palindrom(*dram): |
| 8 | + total = fark = 0 |
| 9 | + for sayı in dram: |
| 10 | + if str(sayı) == str(sayı)[::-1]: |
| 11 | + total += sayı |
| 12 | + else: |
| 13 | + total -= sayı |
| 14 | + return total - fark |
| 15 | + |
| 16 | +print(palindrom(10, 101, 55, 40, 9001)) |
| 17 | + |
| 18 | +"""""""""""""""""""""""""""""""""""""""""""" |
| 19 | + |
| 20 | +class sınıf: |
| 21 | + e = 5 |
| 22 | + d = "qwew" |
| 23 | + f = [2, 4, 6] |
| 24 | + |
| 25 | + def write(self): |
| 26 | + k = 120 |
| 27 | + print(k, self.k) |
| 28 | + |
| 29 | + def write2(self,y): |
| 30 | + self.write() |
| 31 | + print(y) |
| 32 | + |
| 33 | +nesne = sınıf() |
| 34 | +nesne.write() |
| 35 | +nesne.write2("fwefreq") # self i görmezden geliyoruz. |
| 36 | + |
| 37 | + |
| 38 | +obje = sınıf() |
| 39 | +print(obje.e) |
| 40 | +obje.e = 989 |
| 41 | +print(obje.e) |
| 42 | + |
| 43 | +def Palamut():{print("asdsefd")} |
| 44 | + |
| 45 | +Palamut() |
| 46 | + |
| 47 | +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" |
| 48 | + |
| 49 | +class qwerty: |
| 50 | + yazı = "" |
| 51 | + def __init__(self, b): |
| 52 | + self.yazı = b |
| 53 | + |
| 54 | + def __del__(self): |
| 55 | + print("sil") |
| 56 | + |
| 57 | + def __str__(self): |
| 58 | + return "yazdırılan : " + self.yazı |
| 59 | + |
| 60 | +nesneee = qwerty("Ali") |
| 61 | +print(nesneee.metin) |
| 62 | + |
| 63 | +qw = qwerty("CIVA") |
| 64 | +print(qw) |
| 65 | + |
| 66 | +"""""""""""""""""""""""""""""""" |
| 67 | + |
| 68 | +def num(c, d): |
| 69 | + return c + d |
| 70 | + |
| 71 | +def multiply(c , d): |
| 72 | + return c * d |
| 73 | + |
| 74 | + |
| 75 | +w = 4 |
| 76 | +s = "wefı" |
| 77 | +r = [0, 5 ,6] |
| 78 | +"""""""""""""""""""""""""""""""""""""""""""""""""""""" |
| 79 | +import ast |
| 80 | +from cmath import e |
| 81 | +import ornekler_2 as orn |
| 82 | + |
| 83 | +from ornekler_2 import num |
| 84 | + |
| 85 | +print(orn.num(5, 7)) |
| 86 | +print(orn.e) |
| 87 | + |
| 88 | +print(num(1, 5)) |
| 89 | + |
| 90 | +print(orn.e) |
| 91 | + |
| 92 | +##################################################### |
| 93 | + |
| 94 | +a = "wer" |
| 95 | +try: |
| 96 | + h = 9 + a |
| 97 | +except: |
| 98 | + print("int and string") |
| 99 | + |
| 100 | +############################# |
| 101 | + |
| 102 | +from termcolor2 import termcolor |
| 103 | + |
| 104 | +print(qw("hi").red.on_white.blink.underline.dark) |
| 105 | + |
| 106 | +"""""""""""""""""""""""""""""""""""""""""""""""" |
| 107 | + |
| 108 | +dosya = open("metin.txt", "v") |
| 109 | + |
| 110 | +for satır in dosya: |
| 111 | + print(satır[:-1]) |
| 112 | + |
| 113 | +gerg = open("metin.txt", "r") |
| 114 | +print("villages", file=gerg) |
| 115 | + |
| 116 | +gerg.close() |
| 117 | + |
0 commit comments