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.
Geçmiş verilere dayanarak gelecekteki değerleri tahmin etmeye yarayan, en temel makine öğrenmesi algoritması olan Lineer Regresyon örneği.
from sklearn.linear_model import LinearRegression
import numpy as np
# Örnek veriler (X: Tecrübe Yılı, y: Maaş)
X = np.array([[1], [2], [3], [4], [5]])
y = np.array([5000, 7000, 9500, 12000, 15500])
model = LinearRegression()
model.fit(X, y)
# 6 yıllık tecrübe için tahmin
tahmin = model.predict([[6]])
print(f"6 Yıllık tecrübe tahmini maaşı: {tahmin[0]} TL")
import numpy as np
# Örnek veriler (X: Tecrübe Yılı, y: Maaş)
X = np.array([[1], [2], [3], [4], [5]])
y = np.array([5000, 7000, 9500, 12000, 15500])
model = LinearRegression()
model.fit(X, y)
# 6 yıllık tecrübe için tahmin
tahmin = model.predict([[6]])
print(f"6 Yıllık tecrübe tahmini maaşı: {tahmin[0]} TL")
Belirlenen bir haber sitesinden anlık başlıkları çekip listeleyen temel scraping örneği.
import requests
from bs4 import BeautifulSoup
url = "https://news.ycombinator.com/"
page = requests.get(url)
soup = BeautifulSoup(page.content, "html.parser")
for story in soup.find_all("span", class_="titleline")[:10]:
print(story.text)
from bs4 import BeautifulSoup
url = "https://news.ycombinator.com/"
page = requests.get(url)
soup = BeautifulSoup(page.content, "html.parser")
for story in soup.find_all("span", class_="titleline")[:10]:
print(story.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.
Text dosyasına yazdırma
CSHARPAçılan text dosyasına satır eklemeye yarayan kod örneyi
string lines = "First line.\r\nSecond line.\r\nThird line.";
// Write the string to a file.
System.IO.StreamWriter file = new System.IO.StreamWriter("c:\\test.txt");
file.WriteLine(lines);
file.Close();
// Write the string to a file.
System.IO.StreamWriter file = new System.IO.StreamWriter("c:\\test.txt");
file.WriteLine(lines);
file.Close();
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;
}
}
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");
?>
Bir dosyanın içeriğini açmak veya bir değiştirmek için önce dosyanın açılması gerekmektedir. PHP'de dosya açmak için kullanılacak komut fopen()' dır.
<?
$dosya_adi = fopen( "deneme.txt" , 'w' ) or die ("Dosya açılamıyor!") ;
$dosya_adi = fopen( "deneme.txt" , 'a' ) or die ("Dosya açılamıyor!") ;
$dosya_adi = fopen( "deneme.txt" , 'r' ) or die ("Dosya açılamıyor!") ;
?>
$dosya_adi = fopen( "deneme.txt" , 'w' ) or die ("Dosya açılamıyor!") ;
$dosya_adi = fopen( "deneme.txt" , 'a' ) or die ("Dosya açılamıyor!") ;
$dosya_adi = fopen( "deneme.txt" , 'r' ) or die ("Dosya açılamıyor!") ;
?>
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.
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>
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>