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.
requests kütüphanesi kullanarak bir API üzerinden anlık döviz kurlarını çeken ve JSON verisini işleyerek ekrana yazdıran örnek.
import requests
url = "https://api.exchangerate-api.com/v4/latest/USD"
response = requests.get(url)
data = response.json()
usd_try = data['rates']['TRY']
print(f"1 Dolar şu an: {usd_try} TL")
url = "https://api.exchangerate-api.com/v4/latest/USD"
response = requests.get(url)
data = response.json()
usd_try = data['rates']['TRY']
print(f"1 Dolar şu an: {usd_try} TL")
requests kütüphanesi kullanarak bir API üzerinden anlık döviz kurlarını çeken ve JSON verisini işleyerek ekrana yazdıran örnek.
import requests
url = "https://api.exchangerate-api.com/v4/latest/USD"
response = requests.get(url)
data = response.json()
usd_try = data['rates']['TRY']
print(f"1 Dolar şu an: {usd_try} TL")
url = "https://api.exchangerate-api.com/v4/latest/USD"
response = requests.get(url)
data = response.json()
usd_try = data['rates']['TRY']
print(f"1 Dolar şu an: {usd_try} TL")
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.
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");
}
Uygulamanın donmasını engelleyen ve uzun süren işlemleri arka planda yapmayı sağlayan asenkron metod yapısı örneği.
public async Task<string> VeriAlAsync()
{
await Task.Delay(2000); // 2 saniye bekleme simülasyonu
return "Veri yüklendi";
}
// Kullanımı:
string sonuc = await VeriAlAsync();
{
await Task.Delay(2000); // 2 saniye bekleme simülasyonu
return "Veri yüklendi";
}
// Kullanımı:
string sonuc = await VeriAlAsync();
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 dosyaya yazı yazdırmak için fwrite() komutu kullanılmaktadır. fputs() komutu ile dosyanın sonuna ekleme yapılmaktadır.
<?
$dosya_adi = "/wwwroot/deneme.txt";
$dosya = fopen ($dosya_adi , 'w') or die ("Dosya açılamadı!");
$metin = "Bu satır dosyaya yazılacak: Merhaba Dünya!\n";
fwrite ( $dosya , $metin ) ;
fputs ( $dosya , "Bu satır ise sonradan eklenecek\n" ) ;
fclose ($dosya);
?>
$dosya_adi = "/wwwroot/deneme.txt";
$dosya = fopen ($dosya_adi , 'w') or die ("Dosya açılamadı!");
$metin = "Bu satır dosyaya yazılacak: Merhaba Dünya!\n";
fwrite ( $dosya , $metin ) ;
fputs ( $dosya , "Bu satır ise sonradan eklenecek\n" ) ;
fclose ($dosya);
?>
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");
?>
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.
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>
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>