Kod Örnekleri & Teknik Rehberler
Python, C#, PHP ve modern web teknolojileri üzerine profesyonel örnekler.
Python & Veri Bilimi
PopülerÖğrenmesi kolay ve son derece güçlü. Yapay Zeka, Veri Analizi ve Otomasyon dünyasının lider dili Python ile ilgili en güncel snippetları keşfedin.
Büyük veri setleri içerisinde belirli kriterlere göre filtreleme yapmayı ve istatistiksel özet almayı sağlayan profesyonel veri analizi örneği.
import pandas as pd
# Veri setini yükle
df = pd.read_csv('satislar.csv')
# Filtreleme: Satışı 5000'den büyük olan ve Ankara şubesi verileri
filtre = df[(df['Satis'] > 5000) & (df['Sehir'] == 'Ankara')]
# Genel istatistiksel özet
print(filtre.describe())
# Gruplandırarak toplam alma
print(df.groupby('Kategori')['Satis'].sum())
# Veri setini yükle
df = pd.read_csv('satislar.csv')
# Filtreleme: Satışı 5000'den büyük olan ve Ankara şubesi verileri
filtre = df[(df['Satis'] > 5000) & (df['Sehir'] == 'Ankara')]
# Genel istatistiksel özet
print(filtre.describe())
# Gruplandırarak toplam alma
print(df.groupby('Kategori')['Satis'].sum())
Belirtilen bir web sitesindeki HTML başlıklarını (h1 etiketlerini) otomatik olarak çeken temel bir bot örneği.
import requests
from bs4 import BeautifulSoup
url = "https://www.kodornekleri.com"
response = requests.get(url)
soup = BeautifulSoup(response.text, 'html.parser')
# Tüm h1 başlıklarını çek
for baslik in soup.find_all('h1'):
print(baslik.text)
from bs4 import BeautifulSoup
url = "https://www.kodornekleri.com"
response = requests.get(url)
soup = BeautifulSoup(response.text, 'html.parser')
# Tüm h1 başlıklarını çek
for baslik in soup.find_all('h1'):
print(baslik.text)
C# (CSharp) & .NET Core
KurumsalModern, nesne yönelimli ve yüksek performanslı. ASP.NET Core ve Entity Framework ile profesyonel web ve masaüstü projeleri geliştirin.
Dizileri sıralamak
CSHARPDizileri sıralamak için Array.Sort(Array) komutu kullanılabilir.
// sorting int array
int[] intArray = new int[5] { 8, 12, 55, 28, 6 };
Array.Sort(intArray);
// writing array
foreach (int i in intArray) Console.Write(i + " ");
// output: 6 8 12 28 55
int[] intArray = new int[5] { 8, 12, 55, 28, 6 };
Array.Sort(intArray);
// writing array
foreach (int i in intArray) Console.Write(i + " ");
// output: 6 8 12 28 55
Kullanıcının MessageBox kusutunda seçmiş olduğu karara göre işlem yapmak için DialogResult kullanılmaktadır.
if (DialogResult.Yes == MessageBox.Show("Kararınız nedir?", "Important Question", MessageBoxButtons.YesNo))
{
MessageBox.Show("EVET seçildi");
}
else
{
MessageBox.Show("İptal edildi");
}
{
MessageBox.Show("EVET seçildi");
}
else
{
MessageBox.Show("İptal edildi");
}
PHP & Web Programlama
DinamikWeb dünyasının emektar ve güçlü dili. PDO veritabanı yönetimi, API işlemleri ve modern PHP 8.x tekniklerini inceleyin.
Kullanıcının başka bir URL adresine yönlendirilmesini sağlar.
<?
header("Location: http://www.google.com");
?>
header("Location: http://www.google.com");
?>
While döngüsü döngüye girilmeden önce şartın sağlanıp sağlanmadığını kontrol ettikten sonra işlemleri yapmaktadır. İşlemler ilk kez yapıldıktan sonra şartın sağlanıp sağlanmaması isteniyorsa bu durumda do..while döngüsü kullanılır.
<?
$sayac=1;
Do
{
echo ("<font size= $sayac >");
echo ("<b><p>www.ME.com.tr</b></p>");
echo ("</font>");
sayac++;
}
while ($sayac <= 7) ;
?>
$sayac=1;
Do
{
echo ("<font size= $sayac >");
echo ("<b><p>www.ME.com.tr</b></p>");
echo ("</font>");
sayac++;
}
while ($sayac <= 7) ;
?>
JavaScript (ES6+)
Frontendİnteraktif web sayfalarının kalbi. Modern JS, Async/Await ve DOM manipülasyonu üzerine en pratik kod parçacıkları burada.
Sayfalarınızda kullanıcıların mouse (fare)'un sağ tuş fonksiyonlarına ulaşmasını istemiyorsanız bu scripti rahatlıkla kullanabilirsiniz.
<style>
#ie5menu { position: absolute; width: 210px; background-color: menu; font-family: Tahoma; font-size: 12px; line-height: 20px; cursor: default; visibility: hidden; border: 2px outset default }
.menuitems { padding-left: 15px; padding-right: 15px }
//-->
</style>
<script>
var display_url=0
function showmenuie5(){
ie5menu.style.left=document.body.scrollLeft+event.clientX
ie5menu.style.top=document.body.scrollTop+event.clientY
ie5menu.style.visibility="visible"
return false
}
function hidemenuie5(){
ie5menu.style.visibility="hidden"
}
function highlightie5(){
if (event.srcElement.className=="menuitems"){
event.srcElement.style.backgroundColor="highlight"
event.srcElement.style.color="white"
if (display_url==1)
window.status=event.srcElement.url
}
}
function lowlightie5(){
if (event.srcElement.className=="menuitems"){
event.srcElement.style.backgroundColor=""
event.srcElement.style.color="black"
window.status=''
}
}
function jumptoie5(){
if (event.srcElement.className=="menuitems")
window.location=event.srcElement.url
}
</script>
<script>
function correct(){
if (finished){
setTimeout("begin()",1000)
}
return true
}
window.onerror=correct
function begin(){
if (!document.all)
return
if (maxheight==null)
maxheight=temp.offsetHeight
whatsnew.style.height=maxheight
temp.style.display="none"
c=1
finished=true
change()
}
</script>
<!-- İSTEDİĞİNİZ LİNKLERİ AŞAĞIDAKİ BÖLÜMLERE YERLEŞTİRİNİZ.. -->
<!--[if IE]><div id="ie5menu" onMouseover="highlightie5()" onMouseout="lowlightie5()" onClick="jumptoie5()">
<div class="menuitems" url="http://www.ipucu.web.tr">ipucu siteniz</div>
<div class="menuitems" url="http://www.adres2.com">LİNK2</div>
<div class="menuitems" url="http://www.google.com">Google</div>
<div class="menuitems" url="http://www.altavista.com">Altavista</div>
<div class="menuitems" url="http://www.hotmail.com">Hotmail</div></div>
<![endif]-->
<script>
document.oncontextmenu=showmenuie5
if (document.all&&window.print)
document.body.onclick=hidemenuie5
</script>
#ie5menu { position: absolute; width: 210px; background-color: menu; font-family: Tahoma; font-size: 12px; line-height: 20px; cursor: default; visibility: hidden; border: 2px outset default }
.menuitems { padding-left: 15px; padding-right: 15px }
//-->
</style>
<script>
var display_url=0
function showmenuie5(){
ie5menu.style.left=document.body.scrollLeft+event.clientX
ie5menu.style.top=document.body.scrollTop+event.clientY
ie5menu.style.visibility="visible"
return false
}
function hidemenuie5(){
ie5menu.style.visibility="hidden"
}
function highlightie5(){
if (event.srcElement.className=="menuitems"){
event.srcElement.style.backgroundColor="highlight"
event.srcElement.style.color="white"
if (display_url==1)
window.status=event.srcElement.url
}
}
function lowlightie5(){
if (event.srcElement.className=="menuitems"){
event.srcElement.style.backgroundColor=""
event.srcElement.style.color="black"
window.status=''
}
}
function jumptoie5(){
if (event.srcElement.className=="menuitems")
window.location=event.srcElement.url
}
</script>
<script>
function correct(){
if (finished){
setTimeout("begin()",1000)
}
return true
}
window.onerror=correct
function begin(){
if (!document.all)
return
if (maxheight==null)
maxheight=temp.offsetHeight
whatsnew.style.height=maxheight
temp.style.display="none"
c=1
finished=true
change()
}
</script>
<!-- İSTEDİĞİNİZ LİNKLERİ AŞAĞIDAKİ BÖLÜMLERE YERLEŞTİRİNİZ.. -->
<!--[if IE]><div id="ie5menu" onMouseover="highlightie5()" onMouseout="lowlightie5()" onClick="jumptoie5()">
<div class="menuitems" url="http://www.ipucu.web.tr">ipucu siteniz</div>
<div class="menuitems" url="http://www.adres2.com">LİNK2</div>
<div class="menuitems" url="http://www.google.com">Google</div>
<div class="menuitems" url="http://www.altavista.com">Altavista</div>
<div class="menuitems" url="http://www.hotmail.com">Hotmail</div></div>
<![endif]-->
<script>
document.oncontextmenu=showmenuie5
if (document.all&&window.print)
document.body.onclick=hidemenuie5
</script>
Formda kullanıcı tarafından girilen e-posta adresini kontrol eder.
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function checkeposta(myForm) {
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(myForm.emailAddr.value)){
return (true)
}
alert("Hatalı E-posta Adresi! Tekrar giriniz.")
return (false)
}
// End -->
</script>
</HEAD>
<BODY>
<form onSubmit="return checkeposta(this)">
E-mail Address:<br>
<input type="text" name="emailAddr">
<p>
<input type="submit" value="Submit">
<input type="reset" value="Reset">
</form>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function checkeposta(myForm) {
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(myForm.emailAddr.value)){
return (true)
}
alert("Hatalı E-posta Adresi! Tekrar giriniz.")
return (false)
}
// End -->
</script>
</HEAD>
<BODY>
<form onSubmit="return checkeposta(this)">
E-mail Address:<br>
<input type="text" name="emailAddr">
<p>
<input type="submit" value="Submit">
<input type="reset" value="Reset">
</form>