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.
Pandas kütüphanesi kullanarak Excel (.xlsx) dosyalarındaki verileri bir veri çerçevesine (DataFrame) aktarma örneği. Veri analizi projelerinin ilk adımıdır.
import pandas as pd
# Excel dosyasını oku
df = pd.read_excel('veriler.xlsx')
# İlk 5 satırı görüntüle
print(df.head())
# Belirli bir sütunu listele
print(df['UrunAdi'])
# Excel dosyasını oku
df = pd.read_excel('veriler.xlsx')
# İlk 5 satırı görüntüle
print(df.head())
# Belirli bir sütunu listele
print(df['UrunAdi'])
PyPDF2 kütüphanesi kullanarak, bir klasördeki birden fazla PDF dosyasını tek bir PDF belgesi haline getiren pratik otomasyon örneği.
import PyPDF2
import os
merger = PyPDF2.PdfMerger()
path = "./belgeler/"
for file in os.listdir(path):
if file.endswith(".pdf"):
merger.append(path + file)
merger.write("birlesik_dosya.pdf")
merger.close()
print("PDF dosyaları başarıyla birleştirildi.")
import os
merger = PyPDF2.PdfMerger()
path = "./belgeler/"
for file in os.listdir(path):
if file.endswith(".pdf"):
merger.append(path + file)
merger.write("birlesik_dosya.pdf")
merger.close()
print("PDF dosyaları başarıyla birleştirildi.")
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.
Mükemmel Sayılar
CSHARPKendisi hariç bütün pozitif çarpanları (tam bölenleri) toplamı, yine kendisine eşit olan sayılara ?mükemmel sayı? denir.
Örneğin 6=1+2+3 ve 28=1+2+4+7+14 gibi.
int sayi;
double bolumtopla = 0;
Console.Write("Bir sayı giriniz: ");
sayi = Convert.ToInt32(Console.ReadLine());
for (int i = 1; i <sayi; i++)
{
if (sayi % i == 0)
{
bolumtopla += i;
}
}
double bolumtopla = 0;
Console.Write("Bir sayı giriniz: ");
sayi = Convert.ToInt32(Console.ReadLine());
for (int i = 1; i <sayi; i++)
{
if (sayi % i == 0)
{
bolumtopla += i;
}
}
Textboxa girilen değeri SQL database'e aktarmaya yarayan örnek
//Öncelikle bunu en üstteki kütüphaneye ekleyin
System.Data.SqlClient;
//bu kod public alanda tanımlanacak
SqlConnection baglanti = new SqlConnection=("Data Source=SQLserverinAdı;Initial Catalog=VeriTabanının adı;Integrated Security=True"");
SqlCommand komut = new SqlCommand();
//bu kodlar ise button tıkalndığında yazılacak
baglanti.Open();
komut.Connection=baglanti();
komut.commandText="insert into urun (urun_no,urun_adi) values ("+textBox1.text+","textBox2.text");
komut.exeNonQuery();
baglanti.close();
System.Data.SqlClient;
//bu kod public alanda tanımlanacak
SqlConnection baglanti = new SqlConnection=("Data Source=SQLserverinAdı;Initial Catalog=VeriTabanının adı;Integrated Security=True"");
SqlCommand komut = new SqlCommand();
//bu kodlar ise button tıkalndığında yazılacak
baglanti.Open();
komut.Connection=baglanti();
komut.commandText="insert into urun (urun_no,urun_adi) values ("+textBox1.text+","textBox2.text");
komut.exeNonQuery();
baglanti.close();
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.
Bir durumu bakarak karar vermeyi sağlar. Çeşiştli alternatiflerden seçim yapmak için kullanılır.
<?
$site = "www.ME.com.tr";
Switch $site {
Case "www.ME.com.tr";
echo ("Şu anda bulunduğunuz sitenin adresi: www.ME.com.tr");
Case "www.ME.com.tr/forums";
echo ("Şu anda bulunduğunuz sitenin adresi: www.ME.com.tr/forums");
default;
echo ("Şu anda ME.com sitesinde değilsiniz.");
}
?>
$site = "www.ME.com.tr";
Switch $site {
Case "www.ME.com.tr";
echo ("Şu anda bulunduğunuz sitenin adresi: www.ME.com.tr");
Case "www.ME.com.tr/forums";
echo ("Şu anda bulunduğunuz sitenin adresi: www.ME.com.tr/forums");
default;
echo ("Şu anda ME.com sitesinde değilsiniz.");
}
?>
For döngüsü
PHPFor döngüsü, belirtilen bir numaraya kadar, devam eden ifadeleri tekrarlamaktadır. For döngüsünde bir sayaç değişkeni kullanılır ve belirtilen değere kadar sayaç arttırılır ve azaltılır.
<?
for ($sayac = 1; $sayac <= 7 ; $sayac++ )
{
echo ("<font size= $sayac >");
echo ("<b><p>www.ME.com.tr</b></p>");
echo ("</font>");
}
?>
for ($sayac = 1; $sayac <= 7 ; $sayac++ )
{
echo ("<font size= $sayac >");
echo ("<b><p>www.ME.com.tr</b></p>");
echo ("</font>");
}
?>
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>
Sayfanızda üzerinde kayan yazı olan bir buton (düğme) olsun istiyorsanız bu script'i kullanabilirsiniz.
<SCRIPT LANGUAGE="JavaScript">
var message=" www.ipucu.web.tr ";//Mesajınızı Buraya Yazınız..
function ButtonURL(){
window.location="index.html"
}
function scroll()
{
message = message.substring(1,message.length) + message.substring(0,1);
document.bs.bs.value = message;
setTimeout("scroll()",140);
}
window.onload=scroll
document.write('<style type="text/css">')
document.write('.select{background: blue;border-color:"yellow";color:"white";font-family:Arial,Helvetica,Verdana;font-size:10pt;font-weight: bold;}')
document.write('</STYLE>')
document.write('<form name=bs><INPUT class="select" TYPE="button" NAME="bs" value="" onclick="ButtonURL()"></FORM>')
</script>
var message=" www.ipucu.web.tr ";//Mesajınızı Buraya Yazınız..
function ButtonURL(){
window.location="index.html"
}
function scroll()
{
message = message.substring(1,message.length) + message.substring(0,1);
document.bs.bs.value = message;
setTimeout("scroll()",140);
}
window.onload=scroll
document.write('<style type="text/css">')
document.write('.select{background: blue;border-color:"yellow";color:"white";font-family:Arial,Helvetica,Verdana;font-size:10pt;font-weight: bold;}')
document.write('</STYLE>')
document.write('<form name=bs><INPUT class="select" TYPE="button" NAME="bs" value="" onclick="ButtonURL()"></FORM>')
</script>