Skip to content

Commit cd3e9e4

Browse files
committed
Python Kodları
1 parent 8f058ab commit cd3e9e4

39 files changed

+22748
-0
lines changed

Asal Sayı.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
sayac=0
2+
sayi=input('Sayı: ')
3+
for i in range(2,int(sayi)):
4+
if(int(sayi)%i==0):
5+
sayac+=1
6+
break
7+
if(sayac!=0):
8+
print("Sayı Asal Değil")
9+
else:
10+
print("Sayı Asal")

Asal Sayılar.py

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# coding=utf-8
2+
3+
"""
4+
Girdiğimiz bir sayıya kadar ki asal olan bütün sayıları listeleme
5+
"""
6+
7+
deger = int(input("Kaça kadar ki asal sayıları arıyorsunuz? : "))
8+
asal = []
9+
10+
for i in range(2, deger):
11+
flag = False
12+
for j in range(2, i):
13+
if i % j == 0:
14+
flag = True
15+
break
16+
if not flag:
17+
asal.append(i)
18+
19+
for i in asal:
20+
print(i)
21+
22+
print("\n0 - {} arasında toplam {} tane asal sayı vardır.".format(deger, len(asal)))

Binary.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
decimal = int(input("Number in decimal format: "))
2+
3+
def binary(n):
4+
output = ""
5+
while n > 0:
6+
output = "{}{}".format(n % 2, output)
7+
n = n // 2
8+
return output
9+
10+
# our method
11+
print(binary(decimal))
12+

Celcius-Fahrenheit.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
print("-" * 30)
2+
print("1- Celsius to fahrenheit")
3+
print("2- Fahrenheit to celsius")
4+
print("-" * 30)
5+
6+
choice = input("Your choice (1/2): ")
7+
8+
if choice == "1":
9+
print("\n# Celsius to Fahrenheit")
10+
celsius = float(input("Degree to convert: "))
11+
fahrenheit = (celsius * 1.8) + 32
12+
print("{} degree celsius is equal to {} degree fahrenheit.".format(celsius, fahrenheit))
13+
elif choice == "2":
14+
print("\n# Fahrenheit to Celsius")
15+
fahrenheit = float(raw_input("Degree to convert: "))
16+
celsius = (fahrenheit - 32) / 1.8
17+
print("{} degree fahrenheit is equal to {} degree celsius.".format(fahrenheit, celsius))
18+
else:
19+
print("Congratulations! You hacked the super-program.")

DB Browser (SQLite).lnk

1.38 KB
Binary file not shown.

Database Yazdırma.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import sqlite3
2+
3+
vt=sqlite3.connect("database")
4+
im=vt.cursor()
5+
6+
7+
satırlar=im.execute("select ID,ADI,SOYADI,OKULNO FROM OGRENCI")
8+
for i in (satırlar):
9+
print(i)
10+
11+
12+
13+
14+
15+
vt.commit()
16+
vt.close()

Facebook.py

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import webbrowser as sp
2+
sp.open("www.facebook.com")

Fibonacci.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
def fibonacci(n, output=[]):
2+
a=1
3+
b=1
4+
for i in range(n):
5+
a, b = b, a + b
6+
output.append(str(a))
7+
return output
8+
9+
number = int(input("Length of fibonacci sequence: "))
10+
11+
print("Result: 1,{}".format(",".join(fibonacci(number))))

Haber.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/python3
2+
# -*- coding: utf-8 -*-
3+
4+
import feedparser
5+
6+
"""
7+
cnn'den son dakika haberlerini çekme
8+
"""
9+
url = "http://www.cnnturk.com/feed/rss/news"
10+
haberler = feedparser.parse(url)
11+
12+
i = 0
13+
for haber in haberler.entries:
14+
i += 1
15+
print(i)
16+
print(haber.title)
17+
print(haber.link)
18+
print(haber.summary)
19+
print("\n")

Hava Durumu.py

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# coding=utf-8
2+
import re
3+
import urllib.request
4+
5+
url = "https://www.havadurumu15gunluk.net/havadurumu/istanbul-hava-durumu-15-gunluk.html"
6+
site = urllib.request.urlopen(url).read().decode('utf-8')
7+
8+
r_gunduz = '<td width="45">&nbsp;&nbsp;(-?\d+)°C</td>'
9+
r_gece = '<td width="45">&nbsp;(-?\d+)°C</td>'
10+
r_gun = '<td width="70" nowrap="nowrap">(.*)</td>'
11+
r_tarih = '<td width="75" nowrap="nowrap">(.*)</td>'
12+
r_aciklama = '<img src="/havadurumu/images/trans.gif" alt="İstanbul Hava durumu 15 günlük" width="1" height="1" />(.*)</div>'
13+
14+
comp_gunduz = re.compile(r_gunduz)
15+
comp_gece = re.compile(r_gece)
16+
comp_gun = re.compile(r_gun)
17+
comp_tarih = re.compile(r_tarih)
18+
comp_aciklama = re.compile(r_aciklama)
19+
20+
gunduz = []
21+
gece = []
22+
gun = []
23+
tarih = []
24+
aciklama = []
25+
26+
for i in re.findall(r_gunduz, site):
27+
gunduz.append(i)
28+
29+
for i in re.findall(r_gece, site):
30+
gece.append(i)
31+
32+
for i in re.findall(r_gun, site):
33+
gun.append(i)
34+
35+
for i in re.findall(r_tarih, site):
36+
tarih.append(i)
37+
38+
for i in re.findall(r_aciklama, site):
39+
aciklama.append(i)
40+
41+
print("-" * 75)
42+
print(" ISTANBUL HAVA DURUMU")
43+
print("-" * 75)
44+
for i in range(0, len(gun)):
45+
print("{} {},\n\t\t\t\t\tgündüz: {} °C\tgece: {} °C\t{}".format(tarih[i], gun[i], gunduz[i], gece[i], aciklama[i]))
46+
print("-" * 75)

Hızlı Yazma.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from datetime import *
2+
3+
before = datetime.now()
4+
5+
text = "Say hello to my little friend"
6+
print("Please type: {}".format(text))
7+
8+
if text == input(": "):
9+
after = datetime.now()
10+
11+
speed = after - before
12+
seconds = speed.total_seconds()
13+
letter_per_second = round(len(text) / seconds, 1)
14+
15+
print("You won!")
16+
print("Your score is: {} seconds.".format(seconds))
17+
print("{} letters per second.".format(letter_per_second))
18+
else:
19+
print("You failed.")

Kriptografi.py

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
def encrypt(text, value, output=""):
2+
for char in text:
3+
output = "{}{}".format(output, chr(ord(char) + value))
4+
return output
5+
6+
def decrypt(text, value, output=""):
7+
for char in text:
8+
output = "{}{}".format(output, chr(ord(char) - value))
9+
return output
10+
11+
i = int(input("Increment value: "))
12+
13+
text = input("Type your text: ")
14+
print("Encrypted text: {}".format(encrypt(text, i)))
15+
16+
text = input("\nType for decrypt: ")
17+
print("Decrypted text: {}".format(decrypt(text, i)))

Max Min Ort.py

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# coding=utf-8
2+
3+
"""
4+
Girilen sayılardan en büyük ve en küçük sayıları bulma
5+
"""
6+
7+
sayilar = []
8+
9+
flag = True
10+
while flag:
11+
try:
12+
a = int(input("Sayıları girin(çıkış için -1): "))
13+
if a == -1:
14+
flag = False
15+
else:
16+
sayilar.append(float(a))
17+
except SyntaxError:
18+
print("HATA: Yalnızca sayı girin !")
19+
except NameError:
20+
print("HATA: Yalnızca sayı girin !")
21+
22+
try:
23+
en_buyuk = sayilar[0]
24+
en_kucuk = sayilar[0]
25+
ortalama = sayilar[0]
26+
except IndexError:
27+
print("\nEn az bir sayı girmelisiniz")
28+
en_buyuk = "yok"
29+
en_kucuk = "yok"
30+
ortalama = "yok"
31+
finally:
32+
toplam = 0
33+
34+
for sayi in sayilar:
35+
if sayi > en_buyuk:
36+
en_buyuk = sayi
37+
if sayi < en_kucuk:
38+
en_kucuk = sayi
39+
toplam += sayi
40+
41+
ortalama = toplam / len(sayilar)
42+
43+
print("\nen büyük sayı = {}\n" \
44+
"en küçük sayı = {}\n" \
45+
"ortalama = {}".format(en_buyuk, en_kucuk, ortalama))

Pascal.py

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
def generate_pascal(height, rows=[]):
2+
rows.append([1])
3+
row=[1]
4+
for i in range(height):
5+
last = 0
6+
next_row = []
7+
for n in row:
8+
next_row.append(last + n)
9+
last = n
10+
next_row.append(1)
11+
12+
row = next_row
13+
rows.append(row)
14+
15+
return rows
16+
17+
for i in generate_pascal(5):
18+
print (i)

Ping.py

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import subprocess as sp
2+
3+
ip=input("Ip giriniz:")
4+
p=sp.Popen("ping "+ip,stdout=sp.PIPE)
5+
6+
if p.poll():
7+
print(ip+"pasif")
8+
else:
9+
print(ip+"aktif")

SQL.py

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import sqlite3
2+
3+
vt=sqlite3.connect("database")
4+
im=vt.cursor()
5+
6+
7+
eski=input("Değiştirilecek ismi giriniz:")
8+
yeni=input("Yeni adı giriniz")
9+
10+
im.execute("UPDATE OGRENCI SET ADI=? WHERE ADI=?",(yeni,eski))
11+
12+
13+
vt.commit()
14+
vt.close()

Sezar Şifresi Kırma.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
print("Sezar Şifresi Kırma Programına Hoşgeldiniz.")
2+
sifresiz=input("Şifresi kırılacak metni giriniz:")
3+
def sifrele(metin):
4+
sifrelimetin=""
5+
for harf in metin:
6+
asciikod=ord(harf)
7+
asciikod=asciikod-3
8+
karakterkod=chr(asciikod)
9+
sifrelimetin=sifrelimetin+karakterkod
10+
print("Şifresiz:",metin,"Şifreli:",sifrelimetin)
11+
12+
sifrele(sifresiz)

Sezar Şifresi Oluşturma.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
def sifrele(metin):
2+
sifrelimetin=""
3+
for harf in metin:
4+
asciikod=ord(harf)
5+
asciikod=asciikod+3
6+
karakterkod=chr(asciikod)
7+
sifrelimetin=sifrelimetin+karakterkod
8+
9+
print("Şifresiz:",metin,"Şifreli:",sifrelimetin)
10+
sifresiz=input("Şifrelenecek metni giriniz:")
11+
sifrele(sifresiz)
12+

TaşKağıtMakas.py

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import random
2+
3+
print(("-" * 30) + "\nRock, Paper, Scissors\n" + ("-" * 30))
4+
5+
user_score, computer_score = 0, 0
6+
7+
while True:
8+
print("\n1 - Rock\n2 - Paper\n3 - Scissors")
9+
user_choice = input("Your choice: ")
10+
computer_choice = random.choice(["1", "2", "3"])
11+
12+
if user_choice == "1" or "Rock":
13+
if computer_choice == "1":
14+
print("Computer's choice: Rock\nRock equal to rock. Scoreless!")
15+
16+
elif computer_choice == "2":
17+
print("Computer's choice: Paper\nPaper wraps stone. You lose!")
18+
computer_score += 100
19+
20+
elif computer_choice == "3":
21+
print("Computer's choice: Scissors\nRock breaks scissors. You win!")
22+
user_score += 100
23+
24+
elif user_choice == "2" or "Paper":
25+
if computer_choice == "1":
26+
print("Computer's choice: Rock\nPaper wraps stone. You win!")
27+
user_score += 100
28+
29+
elif computer_choice == "2":
30+
print("Computer's choice: Paper\nPaper equal to paper. Scoreless!")
31+
32+
elif computer_choice == "3":
33+
print("Computer's choice: Scissors\nScissors cuts paper. You lose!")
34+
computer_score += 100
35+
36+
elif user_choice == "3" or "Scissors":
37+
if computer_choice == "1":
38+
print("Computer's choice: Rock\nRock breaks scissors. You lose!")
39+
computer_score += 100
40+
41+
elif computer_choice == "2":
42+
print("Computer's choice: Paper\nScissors cuts paper. You win!")
43+
user_score += 100
44+
45+
elif computer_choice == "3":
46+
print("Computer's choice: Scissors\nScissors equal to scissors. Scoreless!")
47+
48+
else:
49+
break
50+
51+
print("\nUser's score: {}\nComputer's score: {}".format(user_score, computer_score))

Text to Speech.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from gtts import gTTS
2+
tts = gTTS(text="Hi", lang='tr')
3+
tts.save("audio1.mp3")

Veritabanına Ekleme.py

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import sqlite3
2+
3+
vt=sqlite3.connect("database")
4+
im=vt.cursor()
5+
im.execute('''CREATE TABLE IF NOT EXISTS OGRENCI
6+
(ID INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
7+
ADI TEXT NOT NULL,
8+
SOYADI TEXT NOT NULL,
9+
OKULNO TEXT NOT NULL);''')
10+
ad=input("İsim:")
11+
soyad=input("Soyad:")
12+
okulno=input("Okul No:")
13+
veri=[]
14+
veri.append(ad)
15+
veri.append(soyad)
16+
veri.append(okulno)
17+
18+
im.execute("INSERT INTO OGRENCI(ADI,SOYADI,OKULNO) VALUES (?,?,?)",veri)
19+
vt.commit()
20+
vt.close()

0 commit comments

Comments
 (0)