From 427875663c221ae11ff3b8a8a6e6d66e89b36ac2 Mon Sep 17 00:00:00 2001 From: Melih Mucuk Date: Wed, 31 Dec 2014 11:56:23 +0200 Subject: basic --- tr-tr/csharp-tr.html.markdown | 824 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 824 insertions(+) create mode 100644 tr-tr/csharp-tr.html.markdown (limited to 'tr-tr') diff --git a/tr-tr/csharp-tr.html.markdown b/tr-tr/csharp-tr.html.markdown new file mode 100644 index 00000000..ecbc2b18 --- /dev/null +++ b/tr-tr/csharp-tr.html.markdown @@ -0,0 +1,824 @@ +--- +language: c# +contributors: + - ["Irfan Charania", "https://github.com/irfancharania"] + - ["Max Yankov", "https://github.com/golergka"] + - ["Melvyn Laïly", "http://x2a.yt"] + - ["Shaun McCarthy", "http://www.shaunmccarthy.com"] + - ["Melih Mucuk", "http://melihmucuk.com"] +filename: LearnCSharp.cs +--- + +C# zarif ve tip güvenli nesne yönelimli bir dil olup geliştiricilerin .NET framework üzerinde çalışan güçlü ve güvenli uygulamalar geliştirmesini sağlar. + +[Daha fazlasını okuyun.](http://msdn.microsoft.com/en-us/library/vstudio/z1zx9t92.aspx) + +```c# +// Tek satırlık yorumlar // ile başlar +/* +Birden fazla satırlı yorumlar buna benzer +*/ +/// +/// Bu bir XML dokümantasyon yorumu +/// + +// Uygulamanın kullanacağı ad alanlarını belirtin +using System; +using System.Collections.Generic; +using System.Data.Entity; +using System.Dynamic; +using System.Linq; +using System.Linq.Expressions; +using System.Net; +using System.Threading.Tasks; +using System.IO; + +// Kodu düzenlemek için paketler içinde alan tanımlayın +namespace Learning +{ + // Her .cs dosyası, dosya ile aynı isimde en az bir sınıf içermeli + // bu kurala uymak zorunda değilsiniz ancak mantıklı olan yol budur. + public class LearnCSharp + { + // TEMEL SÖZ DİZİMİ - daha önce Java ya da C++ kullandıysanız İLGİNÇ ÖZELLİKLER'e geçin + public static void Syntax() + { + // Satırları yazdırmak için Console.WriteLine kullanın + Console.WriteLine("Merhaba Dünya"); + Console.WriteLine( + "Integer: " + 10 + + " Double: " + 3.14 + + " Boolean: " + true); + + // Yeni satıra geçmeden yazdırmak için Console.Write kullanın + Console.Write("Merhaba "); + Console.Write("Dünya"); + + /////////////////////////////////////////////////// + // Tipler & Değişkenler + // + // Bir değişken tanımlamak için kullanın + /////////////////////////////////////////////////// + + // Sbyte - Signed 8-bit integer + // (-128 <= sbyte <= 127) + sbyte fooSbyte = 100; + + // Byte - Unsigned 8-bit integer + // (0 <= byte <= 255) + byte fooByte = 100; + + // Short - 16-bit integer + // Signed - (-32,768 <= short <= 32,767) + // Unsigned - (0 <= ushort <= 65,535) + short fooShort = 10000; + ushort fooUshort = 10000; + + // Integer - 32-bit integer + int fooInt = 1; // (-2,147,483,648 <= int <= 2,147,483,647) + uint fooUint = 1; // (0 <= uint <= 4,294,967,295) + + // Long - 64-bit integer + long fooLong = 100000L; // (-9,223,372,036,854,775,808 <= long <= 9,223,372,036,854,775,807) + ulong fooUlong = 100000L; // (0 <= ulong <= 18,446,744,073,709,551,615) + // Numbers default to being int or uint depending on size. + // L is used to denote that this variable value is of type long or ulong + + // Double - Double-precision 64-bit IEEE 754 Floating Point + double fooDouble = 123.4; // Precision: 15-16 digits + + // Float - Single-precision 32-bit IEEE 754 Floating Point + float fooFloat = 234.5f; // Precision: 7 digits + // f is used to denote that this variable value is of type float + + // Decimal - a 128-bits data type, with more precision than other floating-point types, + // suited for financial and monetary calculations + decimal fooDecimal = 150.3m; + + // Boolean - true & false + bool fooBoolean = true; // or false + + // Char - A single 16-bit Unicode character + char fooChar = 'A'; + + // Strings -- unlike the previous base types which are all value types, + // a string is a reference type. That is, you can set it to null + string fooString = "\"escape\" quotes and add \n (new lines) and \t (tabs)"; + Console.WriteLine(fooString); + + // You can access each character of the string with an indexer: + char charFromString = fooString[1]; // => 'e' + // Strings are immutable: you can't do fooString[1] = 'X'; + + // Compare strings with current culture, ignoring case + string.Compare(fooString, "x", StringComparison.CurrentCultureIgnoreCase); + + // Formatting, based on sprintf + string fooFs = string.Format("Check Check, {0} {1}, {0} {1:0.0}", 1, 2); + + // Dates & Formatting + DateTime fooDate = DateTime.Now; + Console.WriteLine(fooDate.ToString("hh:mm, dd MMM yyyy")); + + // You can split a string over two lines with the @ symbol. To escape " use "" + string bazString = @"Here's some stuff +on a new line! ""Wow!"", the masses cried"; + + // Use const or read-only to make a variable immutable + // const values are calculated at compile time + const int HOURS_I_WORK_PER_WEEK = 9001; + + /////////////////////////////////////////////////// + // Data Structures + /////////////////////////////////////////////////// + + // Arrays - zero indexed + // The array size must be decided upon declaration + // The format for declaring an array is follows: + // [] = new []; + int[] intArray = new int[10]; + + // Another way to declare & initialize an array + int[] y = { 9000, 1000, 1337 }; + + // Indexing an array - Accessing an element + Console.WriteLine("intArray @ 0: " + intArray[0]); + // Arrays are mutable. + intArray[1] = 1; + + // Lists + // Lists are used more frequently than arrays as they are more flexible + // The format for declaring a list is follows: + // List = new List(); + List intList = new List(); + List stringList = new List(); + List z = new List { 9000, 1000, 1337 }; // intialize + // The <> are for generics - Check out the cool stuff section + + // Lists don't default to a value; + // A value must be added before accessing the index + intList.Add(1); + Console.WriteLine("intList @ 0: " + intList[0]); + + // Others data structures to check out: + // Stack/Queue + // Dictionary (an implementation of a hash map) + // HashSet + // Read-only Collections + // Tuple (.Net 4+) + + /////////////////////////////////////// + // Operators + /////////////////////////////////////// + Console.WriteLine("\n->Operators"); + + int i1 = 1, i2 = 2; // Shorthand for multiple declarations + + // Arithmetic is straightforward + Console.WriteLine(i1 + i2 - i1 * 3 / 7); // => 3 + + // Modulo + Console.WriteLine("11%3 = " + (11 % 3)); // => 2 + + // Comparison operators + Console.WriteLine("3 == 2? " + (3 == 2)); // => false + Console.WriteLine("3 != 2? " + (3 != 2)); // => true + Console.WriteLine("3 > 2? " + (3 > 2)); // => true + Console.WriteLine("3 < 2? " + (3 < 2)); // => false + Console.WriteLine("2 <= 2? " + (2 <= 2)); // => true + Console.WriteLine("2 >= 2? " + (2 >= 2)); // => true + + // Bitwise operators! + /* + ~ Unary bitwise complement + << Signed left shift + >> Signed right shift + & Bitwise AND + ^ Bitwise exclusive OR + | Bitwise inclusive OR + */ + + // Incrementations + int i = 0; + Console.WriteLine("\n->Inc/Dec-rementation"); + Console.WriteLine(i++); //i = 1. Post-Incrementation + Console.WriteLine(++i); //i = 2. Pre-Incrementation + Console.WriteLine(i--); //i = 1. Post-Decrementation + Console.WriteLine(--i); //i = 0. Pre-Decrementation + + /////////////////////////////////////// + // Control Structures + /////////////////////////////////////// + Console.WriteLine("\n->Control Structures"); + + // If statements are c-like + int j = 10; + if (j == 10) + { + Console.WriteLine("I get printed"); + } + else if (j > 10) + { + Console.WriteLine("I don't"); + } + else + { + Console.WriteLine("I also don't"); + } + + // Ternary operators + // A simple if/else can be written as follows + // ? : + string isTrue = (true) ? "True" : "False"; + + // While loop + int fooWhile = 0; + while (fooWhile < 100) + { + //Iterated 100 times, fooWhile 0->99 + fooWhile++; + } + + // Do While Loop + int fooDoWhile = 0; + do + { + //Iterated 100 times, fooDoWhile 0->99 + fooDoWhile++; + } while (fooDoWhile < 100); + + //for loop structure => for(; ; ) + for (int fooFor = 0; fooFor < 10; fooFor++) + { + //Iterated 10 times, fooFor 0->9 + } + + // For Each Loop + // foreach loop structure => foreach( in ) + // The foreach loop loops over any object implementing IEnumerable or IEnumerable + // All the collection types (Array, List, Dictionary...) in the .Net framework + // implement one or both of these interfaces. + // (The ToCharArray() could be removed, because a string also implements IEnumerable) + foreach (char character in "Hello World".ToCharArray()) + { + //Iterated over all the characters in the string + } + + // Switch Case + // A switch works with the byte, short, char, and int data types. + // It also works with enumerated types (discussed in Enum Types), + // the String class, and a few special classes that wrap + // primitive types: Character, Byte, Short, and Integer. + int month = 3; + string monthString; + switch (month) + { + case 1: + monthString = "January"; + break; + case 2: + monthString = "February"; + break; + case 3: + monthString = "March"; + break; + // You can assign more than one case to an action + // But you can't add an action without a break before another case + // (if you want to do this, you would have to explicitly add a goto case x + case 6: + case 7: + case 8: + monthString = "Summer time!!"; + break; + default: + monthString = "Some other month"; + break; + } + + /////////////////////////////////////// + // Converting Data Types And Typecasting + /////////////////////////////////////// + + // Converting data + + // Convert String To Integer + // this will throw an Exception on failure + int.Parse("123");//returns an integer version of "123" + + // try parse will default to type default on failure + // in this case: 0 + int tryInt; + if (int.TryParse("123", out tryInt)) // Function is boolean + Console.WriteLine(tryInt); // 123 + + // Convert Integer To String + // Convert class has a number of methods to facilitate conversions + Convert.ToString(123); + // or + tryInt.ToString(); + } + + /////////////////////////////////////// + // CLASSES - see definitions at end of file + /////////////////////////////////////// + public static void Classes() + { + // See Declaration of objects at end of file + + // Use new to instantiate a class + Bicycle trek = new Bicycle(); + + // Call object methods + trek.SpeedUp(3); // You should always use setter and getter methods + trek.Cadence = 100; + + // ToString is a convention to display the value of this Object. + Console.WriteLine("trek info: " + trek.Info()); + + // Instantiate a new Penny Farthing + PennyFarthing funbike = new PennyFarthing(1, 10); + Console.WriteLine("funbike info: " + funbike.Info()); + + Console.Read(); + } // End main method + + // CONSOLE ENTRY A console application must have a main method as an entry point + public static void Main(string[] args) + { + OtherInterestingFeatures(); + } + + // + // INTERESTING FEATURES + // + + // DEFAULT METHOD SIGNATURES + + public // Visibility + static // Allows for direct call on class without object + int // Return Type, + MethodSignatures( + int maxCount, // First variable, expects an int + int count = 0, // will default the value to 0 if not passed in + int another = 3, + params string[] otherParams // captures all other parameters passed to method + ) + { + return -1; + } + + // Methods can have the same name, as long as the signature is unique + public static void MethodSignatures(string maxCount) + { + } + + // GENERICS + // The classes for TKey and TValue is specified by the user calling this function. + // This method emulates the SetDefault of Python + public static TValue SetDefault( + IDictionary dictionary, + TKey key, + TValue defaultItem) + { + TValue result; + if (!dictionary.TryGetValue(key, out result)) + return dictionary[key] = defaultItem; + return result; + } + + // You can narrow down the objects that are passed in + public static void IterateAndPrint(T toPrint) where T: IEnumerable + { + // We can iterate, since T is a IEnumerable + foreach (var item in toPrint) + // Item is an int + Console.WriteLine(item.ToString()); + } + + public static void OtherInterestingFeatures() + { + // OPTIONAL PARAMETERS + MethodSignatures(3, 1, 3, "Some", "Extra", "Strings"); + MethodSignatures(3, another: 3); // explicity set a parameter, skipping optional ones + + // EXTENSION METHODS + int i = 3; + i.Print(); // Defined below + + // NULLABLE TYPES - great for database interaction / return values + // any value type (i.e. not a class) can be made nullable by suffixing a ? + // ? = + int? nullable = null; // short hand for Nullable + Console.WriteLine("Nullable variable: " + nullable); + bool hasValue = nullable.HasValue; // true if not null + + // ?? is syntactic sugar for specifying default value (coalesce) + // in case variable is null + int notNullable = nullable ?? 0; // 0 + + // IMPLICITLY TYPED VARIABLES - you can let the compiler work out what the type is: + var magic = "magic is a string, at compile time, so you still get type safety"; + // magic = 9; will not work as magic is a string, not an int + + // GENERICS + // + var phonebook = new Dictionary() { + {"Sarah", "212 555 5555"} // Add some entries to the phone book + }; + + // Calling SETDEFAULT defined as a generic above + Console.WriteLine(SetDefault(phonebook, "Shaun", "No Phone")); // No Phone + // nb, you don't need to specify the TKey and TValue since they can be + // derived implicitly + Console.WriteLine(SetDefault(phonebook, "Sarah", "No Phone")); // 212 555 5555 + + // LAMBDA EXPRESSIONS - allow you to write code in line + Func square = (x) => x * x; // Last T item is the return value + Console.WriteLine(square(3)); // 9 + + // DISPOSABLE RESOURCES MANAGEMENT - let you handle unmanaged resources easily. + // Most of objects that access unmanaged resources (file handle, device contexts, etc.) + // implement the IDisposable interface. The using statement takes care of + // cleaning those IDisposable objects for you. + using (StreamWriter writer = new StreamWriter("log.txt")) + { + writer.WriteLine("Nothing suspicious here"); + // At the end of scope, resources will be released. + // Even if an exception is thrown. + } + + // PARALLEL FRAMEWORK + // http://blogs.msdn.com/b/csharpfaq/archive/2010/06/01/parallel-programming-in-net-framework-4-getting-started.aspx + var websites = new string[] { + "http://www.google.com", "http://www.reddit.com", + "http://www.shaunmccarthy.com" + }; + var responses = new Dictionary(); + + // Will spin up separate threads for each request, and join on them + // before going to the next step! + Parallel.ForEach(websites, + new ParallelOptions() {MaxDegreeOfParallelism = 3}, // max of 3 threads + website => + { + // Do something that takes a long time on the file + using (var r = WebRequest.Create(new Uri(website)).GetResponse()) + { + responses[website] = r.ContentType; + } + }); + + // This won't happen till after all requests have been completed + foreach (var key in responses.Keys) + Console.WriteLine("{0}:{1}", key, responses[key]); + + // DYNAMIC OBJECTS (great for working with other languages) + dynamic student = new ExpandoObject(); + student.FirstName = "First Name"; // No need to define class first! + + // You can even add methods (returns a string, and takes in a string) + student.Introduce = new Func( + (introduceTo) => string.Format("Hey {0}, this is {1}", student.FirstName, introduceTo)); + Console.WriteLine(student.Introduce("Beth")); + + // IQUERYABLE - almost all collections implement this, which gives you a lot of + // very useful Map / Filter / Reduce style methods + var bikes = new List(); + bikes.Sort(); // Sorts the array + bikes.Sort((b1, b2) => b1.Wheels.CompareTo(b2.Wheels)); // Sorts based on wheels + var result = bikes + .Where(b => b.Wheels > 3) // Filters - chainable (returns IQueryable of previous type) + .Where(b => b.IsBroken && b.HasTassles) + .Select(b => b.ToString()); // Map - we only this selects, so result is a IQueryable + + var sum = bikes.Sum(b => b.Wheels); // Reduce - sums all the wheels in the collection + + // Create a list of IMPLICIT objects based on some parameters of the bike + var bikeSummaries = bikes.Select(b=>new { Name = b.Name, IsAwesome = !b.IsBroken && b.HasTassles }); + // Hard to show here, but you get type ahead completion since the compiler can implicitly work + // out the types above! + foreach (var bikeSummary in bikeSummaries.Where(b => b.IsAwesome)) + Console.WriteLine(bikeSummary.Name); + + // ASPARALLEL + // And this is where things get wicked - combines linq and parallel operations + var threeWheelers = bikes.AsParallel().Where(b => b.Wheels == 3).Select(b => b.Name); + // this will happen in parallel! Threads will automagically be spun up and the + // results divvied amongst them! Amazing for large datasets when you have lots of + // cores + + // LINQ - maps a store to IQueryable objects, with delayed execution + // e.g. LinqToSql - maps to a database, LinqToXml maps to an xml document + var db = new BikeRepository(); + + // execution is delayed, which is great when querying a database + var filter = db.Bikes.Where(b => b.HasTassles); // no query run + if (42 > 6) // You can keep adding filters, even conditionally - great for "advanced search" functionality + filter = filter.Where(b => b.IsBroken); // no query run + + var query = filter + .OrderBy(b => b.Wheels) + .ThenBy(b => b.Name) + .Select(b => b.Name); // still no query run + + // Now the query runs, but opens a reader, so only populates are you iterate through + foreach (string bike in query) + Console.WriteLine(result); + + + + } + + } // End LearnCSharp class + + // You can include other classes in a .cs file + + public static class Extensions + { + // EXTENSION FUNCTIONS + public static void Print(this object obj) + { + Console.WriteLine(obj.ToString()); + } + } + + // Class Declaration Syntax: + // class { + // //data fields, constructors, functions all inside. + // //functions are called as methods in Java. + // } + + public class Bicycle + { + // Bicycle's Fields/Variables + public int Cadence // Public: Can be accessed from anywhere + { + get // get - define a method to retrieve the property + { + return _cadence; + } + set // set - define a method to set a proprety + { + _cadence = value; // Value is the value passed in to the setter + } + } + private int _cadence; + + protected virtual int Gear // Protected: Accessible from the class and subclasses + { + get; // creates an auto property so you don't need a member field + set; + } + + internal int Wheels // Internal: Accessible from within the assembly + { + get; + private set; // You can set modifiers on the get/set methods + } + + int _speed; // Everything is private by default: Only accessible from within this class. + // can also use keyword private + public string Name { get; set; } + + // Enum is a value type that consists of a set of named constants + // It is really just mapping a name to a value (an int, unless specified otherwise). + // The approved types for an enum are byte, sbyte, short, ushort, int, uint, long, or ulong. + // An enum can't contain the same value twice. + public enum BikeBrand + { + AIST, + BMC, + Electra = 42, //you can explicitly set a value to a name + Gitane // 43 + } + // We defined this type inside a Bicycle class, so it is a nested type + // Code outside of this class should reference this type as Bicycle.Brand + + public BikeBrand Brand; // After declaring an enum type, we can declare the field of this type + + // Static members belong to the type itself rather then specific object. + // You can access them without a reference to any object: + // Console.WriteLine("Bicycles created: " + Bicycle.bicyclesCreated); + static public int BicyclesCreated = 0; + + // readonly values are set at run time + // they can only be assigned upon declaration or in a constructor + readonly bool _hasCardsInSpokes = false; // read-only private + + // Constructors are a way of creating classes + // This is a default constructor + public Bicycle() + { + this.Gear = 1; // you can access members of the object with the keyword this + Cadence = 50; // but you don't always need it + _speed = 5; + Name = "Bontrager"; + Brand = BikeBrand.AIST; + BicyclesCreated++; + } + + // This is a specified constructor (it contains arguments) + public Bicycle(int startCadence, int startSpeed, int startGear, + string name, bool hasCardsInSpokes, BikeBrand brand) + : base() // calls base first + { + Gear = startGear; + Cadence = startCadence; + _speed = startSpeed; + Name = name; + _hasCardsInSpokes = hasCardsInSpokes; + Brand = brand; + } + + // Constructors can be chained + public Bicycle(int startCadence, int startSpeed, BikeBrand brand) : + this(startCadence, startSpeed, 0, "big wheels", true, brand) + { + } + + // Function Syntax: + // () + + // classes can implement getters and setters for their fields + // or they can implement properties (this is the preferred way in C#) + + // Method parameters can have default values. + // In this case, methods can be called with these parameters omitted + public void SpeedUp(int increment = 1) + { + _speed += increment; + } + + public void SlowDown(int decrement = 1) + { + _speed -= decrement; + } + + // properties get/set values + // when only data needs to be accessed, consider using properties. + // properties may have either get or set, or both + private bool _hasTassles; // private variable + public bool HasTassles // public accessor + { + get { return _hasTassles; } + set { _hasTassles = value; } + } + + // You can also define an automatic property in one line + // this syntax will create a backing field automatically. + // You can set an access modifier on either the getter or the setter (or both) + // to restrict its access: + public bool IsBroken { get; private set; } + + // Properties can be auto-implemented + public int FrameSize + { + get; + // you are able to specify access modifiers for either get or set + // this means only Bicycle class can call set on Framesize + private set; + } + + // It's also possible to define custom Indexers on objects. + // All though this is not entirely useful in this example, you + // could do bicycle[0] which yields "chris" to get the first passenger or + // bicycle[1] = "lisa" to set the passenger. (of this apparent quattrocycle) + private string[] passengers = { "chris", "phil", "darren", "regina" } + + public string this[int i] + { + get { + return passengers[i]; + } + + set { + return passengers[i] = value; + } + } + + //Method to display the attribute values of this Object. + public virtual string Info() + { + return "Gear: " + Gear + + " Cadence: " + Cadence + + " Speed: " + _speed + + " Name: " + Name + + " Cards in Spokes: " + (_hasCardsInSpokes ? "yes" : "no") + + "\n------------------------------\n" + ; + } + + // Methods can also be static. It can be useful for helper methods + public static bool DidWeCreateEnoughBycles() + { + // Within a static method, we only can reference static class members + return BicyclesCreated > 9000; + } // If your class only needs static members, consider marking the class itself as static. + + + } // end class Bicycle + + // PennyFarthing is a subclass of Bicycle + class PennyFarthing : Bicycle + { + // (Penny Farthings are those bicycles with the big front wheel. + // They have no gears.) + + // calling parent constructor + public PennyFarthing(int startCadence, int startSpeed) : + base(startCadence, startSpeed, 0, "PennyFarthing", true, BikeBrand.Electra) + { + } + + protected override int Gear + { + get + { + return 0; + } + set + { + throw new ArgumentException("You can't change gears on a PennyFarthing"); + } + } + + public override string Info() + { + string result = "PennyFarthing bicycle "; + result += base.ToString(); // Calling the base version of the method + return result; + } + } + + // Interfaces only contain signatures of the members, without the implementation. + interface IJumpable + { + void Jump(int meters); // all interface members are implicitly public + } + + interface IBreakable + { + bool Broken { get; } // interfaces can contain properties as well as methods & events + } + + // Class can inherit only one other class, but can implement any amount of interfaces + class MountainBike : Bicycle, IJumpable, IBreakable + { + int damage = 0; + + public void Jump(int meters) + { + damage += meters; + } + + public bool Broken + { + get + { + return damage > 100; + } + } + } + + /// + /// Used to connect to DB for LinqToSql example. + /// EntityFramework Code First is awesome (similar to Ruby's ActiveRecord, but bidirectional) + /// http://msdn.microsoft.com/en-us/data/jj193542.aspx + /// + public class BikeRepository : DbSet + { + public BikeRepository() + : base() + { + } + + public DbSet Bikes { get; set; } + } +} // End Namespace +``` + +## Topics Not Covered + + * Flags + * Attributes + * Static properties + * Exceptions, Abstraction + * ASP.NET (Web Forms/MVC/WebMatrix) + * Winforms + * Windows Presentation Foundation (WPF) + +## Further Reading + + * [DotNetPerls](http://www.dotnetperls.com) + * [C# in Depth](http://manning.com/skeet2) + * [Programming C#](http://shop.oreilly.com/product/0636920024064.do) + * [LINQ](http://shop.oreilly.com/product/9780596519254.do) + * [MSDN Library](http://msdn.microsoft.com/en-us/library/618ayhy6.aspx) + * [ASP.NET MVC Tutorials](http://www.asp.net/mvc/tutorials) + * [ASP.NET Web Matrix Tutorials](http://www.asp.net/web-pages/tutorials) + * [ASP.NET Web Forms Tutorials](http://www.asp.net/web-forms/tutorials) + * [Windows Forms Programming in C#](http://www.amazon.com/Windows-Forms-Programming-Chris-Sells/dp/0321116208) + + + +[C# Coding Conventions](http://msdn.microsoft.com/en-us/library/vstudio/ff926074.aspx) -- cgit v1.2.3 From 32174fe9ce787f9135bda27dd3d3fddc9b0225bd Mon Sep 17 00:00:00 2001 From: Melih Mucuk Date: Wed, 31 Dec 2014 12:01:40 +0200 Subject: types --- tr-tr/csharp-tr.html.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tr-tr') diff --git a/tr-tr/csharp-tr.html.markdown b/tr-tr/csharp-tr.html.markdown index ecbc2b18..29c29145 100644 --- a/tr-tr/csharp-tr.html.markdown +++ b/tr-tr/csharp-tr.html.markdown @@ -81,8 +81,8 @@ namespace Learning // Long - 64-bit integer long fooLong = 100000L; // (-9,223,372,036,854,775,808 <= long <= 9,223,372,036,854,775,807) ulong fooUlong = 100000L; // (0 <= ulong <= 18,446,744,073,709,551,615) - // Numbers default to being int or uint depending on size. - // L is used to denote that this variable value is of type long or ulong + // Sayılar boyutlarına göre ön tanımlı olarak int ya da uint olabilir. + // L, bir değerin long ya da ulong tipinde olduğunu belirtmek için kullanılır. // Double - Double-precision 64-bit IEEE 754 Floating Point double fooDouble = 123.4; // Precision: 15-16 digits -- cgit v1.2.3 From 20a921fd03a8274e817944f5732b7b69f4267abd Mon Sep 17 00:00:00 2001 From: Melih Mucuk Date: Wed, 31 Dec 2014 16:07:18 +0200 Subject: arrays --- tr-tr/csharp-tr.html.markdown | 52 +++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 26 deletions(-) (limited to 'tr-tr') diff --git a/tr-tr/csharp-tr.html.markdown b/tr-tr/csharp-tr.html.markdown index 29c29145..8c6a7d43 100644 --- a/tr-tr/csharp-tr.html.markdown +++ b/tr-tr/csharp-tr.html.markdown @@ -82,63 +82,63 @@ namespace Learning long fooLong = 100000L; // (-9,223,372,036,854,775,808 <= long <= 9,223,372,036,854,775,807) ulong fooUlong = 100000L; // (0 <= ulong <= 18,446,744,073,709,551,615) // Sayılar boyutlarına göre ön tanımlı olarak int ya da uint olabilir. - // L, bir değerin long ya da ulong tipinde olduğunu belirtmek için kullanılır. + // L, değişken değerinin long ya da ulong tipinde olduğunu belirtmek için kullanılır. - // Double - Double-precision 64-bit IEEE 754 Floating Point - double fooDouble = 123.4; // Precision: 15-16 digits + // Double - Çift hassasiyetli 64-bit IEEE 754 kayan sayı + double fooDouble = 123.4; // Hassasiyet: 15-16 basamak - // Float - Single-precision 32-bit IEEE 754 Floating Point - float fooFloat = 234.5f; // Precision: 7 digits - // f is used to denote that this variable value is of type float + // Float - Tek hassasiyetli 32-bit IEEE 754 kayan sayı + float fooFloat = 234.5f; // Hassasiyet: 7 basamak + // f, değişken değerinin float tipinde olduğunu belirtmek için kullanılır. - // Decimal - a 128-bits data type, with more precision than other floating-point types, - // suited for financial and monetary calculations + // Decimal - 128-bit veri tiğinde ve diğer kayan sayı veri tiplerinden daha hassastır, + // finansal ve mali hesaplamalar için uygundur. decimal fooDecimal = 150.3m; // Boolean - true & false - bool fooBoolean = true; // or false + bool fooBoolean = true; // veya false - // Char - A single 16-bit Unicode character + // Char - 16-bitlik tek bir unicode karakter char fooChar = 'A'; - // Strings -- unlike the previous base types which are all value types, - // a string is a reference type. That is, you can set it to null + // Strings -- Önceki baz tiplerinin hepsi değer tipiyken, + // string bir referans tipidir. Null değer atayabilirsiniz string fooString = "\"escape\" quotes and add \n (new lines) and \t (tabs)"; Console.WriteLine(fooString); - // You can access each character of the string with an indexer: + // İndeks numarası kullanarak bir string'in bütün karakterlerine erişilebilirsiniz: char charFromString = fooString[1]; // => 'e' - // Strings are immutable: you can't do fooString[1] = 'X'; + // String'ler değiştirilemez: fooString[1] = 'X' işlemini yapamazsınız; - // Compare strings with current culture, ignoring case + // String'leri geçerli kültür değeri ve büyük küçük harf duyarlılığı olmadan karşılaştırma string.Compare(fooString, "x", StringComparison.CurrentCultureIgnoreCase); - // Formatting, based on sprintf + // sprintf baz alınarak formatlama string fooFs = string.Format("Check Check, {0} {1}, {0} {1:0.0}", 1, 2); - // Dates & Formatting + // Tarihler & Formatlama DateTime fooDate = DateTime.Now; Console.WriteLine(fooDate.ToString("hh:mm, dd MMM yyyy")); - // You can split a string over two lines with the @ symbol. To escape " use "" + // Bir string'i iki satıra bölmek için @ sembolü kullanabilirsiniz. " işaretinden kaçmak için "" kullanın string bazString = @"Here's some stuff on a new line! ""Wow!"", the masses cried"; - // Use const or read-only to make a variable immutable - // const values are calculated at compile time + // Bir değişkeni değiştirilemez yapmak için const ya da read-only kullanın. + // const değerleri derleme sırasında hesaplanır const int HOURS_I_WORK_PER_WEEK = 9001; /////////////////////////////////////////////////// - // Data Structures + // Veri Yapıları /////////////////////////////////////////////////// - // Arrays - zero indexed - // The array size must be decided upon declaration - // The format for declaring an array is follows: - // [] = new []; + // Diziler - Sıfır indeksli + // Dizi boyutuna tanımlama sırasında karar verilmelidir. + // Dizi tanımlama formatı şöyledir: + // [] = new []; int[] intArray = new int[10]; - // Another way to declare & initialize an array + // Bir diğer dizi tanımlama formatı şöyledir: int[] y = { 9000, 1000, 1337 }; // Indexing an array - Accessing an element -- cgit v1.2.3 From 4ba98e1b9782ac8dc1a476296fb9cf1095943787 Mon Sep 17 00:00:00 2001 From: Melih Mucuk Date: Wed, 31 Dec 2014 16:46:49 +0200 Subject: swithc case --- tr-tr/csharp-tr.html.markdown | 98 +++++++++++++++++++++---------------------- 1 file changed, 49 insertions(+), 49 deletions(-) (limited to 'tr-tr') diff --git a/tr-tr/csharp-tr.html.markdown b/tr-tr/csharp-tr.html.markdown index 8c6a7d43..1ecf18e8 100644 --- a/tr-tr/csharp-tr.html.markdown +++ b/tr-tr/csharp-tr.html.markdown @@ -141,46 +141,46 @@ on a new line! ""Wow!"", the masses cried"; // Bir diğer dizi tanımlama formatı şöyledir: int[] y = { 9000, 1000, 1337 }; - // Indexing an array - Accessing an element + // Bir diziyi indeksleme - Bir elemente erişme Console.WriteLine("intArray @ 0: " + intArray[0]); - // Arrays are mutable. + // Diziler değiştirilebilir. intArray[1] = 1; - // Lists - // Lists are used more frequently than arrays as they are more flexible - // The format for declaring a list is follows: - // List = new List(); + // Listeler + // Listeler daha esnek oldukları için dizilerden daha sık kullanılırlar. + // Bir liste tanımlama formatı şöyledir: + // List = new List(); List intList = new List(); List stringList = new List(); - List z = new List { 9000, 1000, 1337 }; // intialize - // The <> are for generics - Check out the cool stuff section + List z = new List { 9000, 1000, 1337 }; // tanımlama + // <> işareti genelleme içindir - Güzel özellikler sekmesini inceleyin - // Lists don't default to a value; - // A value must be added before accessing the index + // Listelerin varsayılan bir değeri yoktur; + // İndekse erişmeden önce değer eklenmiş olmalıdır intList.Add(1); Console.WriteLine("intList @ 0: " + intList[0]); - // Others data structures to check out: - // Stack/Queue - // Dictionary (an implementation of a hash map) - // HashSet - // Read-only Collections - // Tuple (.Net 4+) + // Diğer veri yapıları için şunlara bakın: + // Stack/Queue (Yığın/Kuyruk) + // Dictionary (hash map'in uygulanması) (Sözlük) + // HashSet (karma seti) + // Read-only Collections (Değiştirilemez koleksiyonlar) + // Tuple (.Net 4+) (tüp) /////////////////////////////////////// - // Operators + // Operatörler /////////////////////////////////////// Console.WriteLine("\n->Operators"); - int i1 = 1, i2 = 2; // Shorthand for multiple declarations + int i1 = 1, i2 = 2; // Birden çok tanımlamanın kısa yolu - // Arithmetic is straightforward + // Aritmetik basittir Console.WriteLine(i1 + i2 - i1 * 3 / 7); // => 3 - // Modulo + // Mod Console.WriteLine("11%3 = " + (11 % 3)); // => 2 - // Comparison operators + // Karşılaştırma operatörleri Console.WriteLine("3 == 2? " + (3 == 2)); // => false Console.WriteLine("3 != 2? " + (3 != 2)); // => true Console.WriteLine("3 > 2? " + (3 > 2)); // => true @@ -188,17 +188,17 @@ on a new line! ""Wow!"", the masses cried"; Console.WriteLine("2 <= 2? " + (2 <= 2)); // => true Console.WriteLine("2 >= 2? " + (2 >= 2)); // => true - // Bitwise operators! + // Bit düzeyi operatörleri! /* - ~ Unary bitwise complement - << Signed left shift - >> Signed right shift - & Bitwise AND - ^ Bitwise exclusive OR - | Bitwise inclusive OR + ~ Tekli bit tamamlayıcısı + << Sola kaydırma Signed left shift + >> Sağa kaydırma Signed right shift + & Bit düzeyi AND + ^ Bit düzeyi harici OR + | Bit düzeyi kapsayan OR */ - // Incrementations + // Arttırma int i = 0; Console.WriteLine("\n->Inc/Dec-rementation"); Console.WriteLine(i++); //i = 1. Post-Incrementation @@ -207,11 +207,11 @@ on a new line! ""Wow!"", the masses cried"; Console.WriteLine(--i); //i = 0. Pre-Decrementation /////////////////////////////////////// - // Control Structures + // Kontrol Yapıları /////////////////////////////////////// Console.WriteLine("\n->Control Structures"); - // If statements are c-like + // If ifadesi c benzeridir int j = 10; if (j == 10) { @@ -226,47 +226,47 @@ on a new line! ""Wow!"", the masses cried"; Console.WriteLine("I also don't"); } - // Ternary operators - // A simple if/else can be written as follows - // ? : + // Üçlü operatörler + // Basit bir if/else ifadesi şöyle yazılabilir + // ? : string isTrue = (true) ? "True" : "False"; - // While loop + // While döngüsü int fooWhile = 0; while (fooWhile < 100) { - //Iterated 100 times, fooWhile 0->99 + //100 kere tekrarlanır, fooWhile 0->99 fooWhile++; } - // Do While Loop + // Do While Döngüsü int fooDoWhile = 0; do { - //Iterated 100 times, fooDoWhile 0->99 + //100 kere tekrarlanır, fooDoWhile 0->99 fooDoWhile++; } while (fooDoWhile < 100); - //for loop structure => for(; ; ) + //for döngüsü yapısı => for(; ; ) for (int fooFor = 0; fooFor < 10; fooFor++) { - //Iterated 10 times, fooFor 0->9 + //10 kere tekrarlanır, fooFor 0->9 } - // For Each Loop - // foreach loop structure => foreach( in ) - // The foreach loop loops over any object implementing IEnumerable or IEnumerable - // All the collection types (Array, List, Dictionary...) in the .Net framework - // implement one or both of these interfaces. - // (The ToCharArray() could be removed, because a string also implements IEnumerable) + // For Each Döngüsü + // foreach döngüsü yapısı => foreach( in ) + // foreach döngüsü, IEnumerable ya da IEnumerable e dönüştürülmüş herhangi bir obje üzerinde döngü yapabilir + // .Net framework üzerindeki bütün koleksiyon tiplerinden (Dizi, Liste, Sözlük...) + // biri ya da hepsi uygulanarak gerçekleştirilebilir. + // (ToCharArray() silindi, çünkü string'ler aynı zamanda IEnumerable'dır.) foreach (char character in "Hello World".ToCharArray()) { - //Iterated over all the characters in the string + //String içindeki bütün karakterler üzerinde döner } // Switch Case - // A switch works with the byte, short, char, and int data types. - // It also works with enumerated types (discussed in Enum Types), + // Bir switch byte, short, char ve int veri tipleri ile çalışır. + // Aynı zamanda sıralı tipler ilede çalışabilir.(Enum Tipleri bölümünde tartışıldı), // the String class, and a few special classes that wrap // primitive types: Character, Byte, Short, and Integer. int month = 3; -- cgit v1.2.3 From 9b1b260c6c3510ccbcc213dd37175ae4383cf08f Mon Sep 17 00:00:00 2001 From: Melih Mucuk Date: Wed, 31 Dec 2014 17:13:30 +0200 Subject: classes --- tr-tr/csharp-tr.html.markdown | 50 +++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'tr-tr') diff --git a/tr-tr/csharp-tr.html.markdown b/tr-tr/csharp-tr.html.markdown index 1ecf18e8..37a1090a 100644 --- a/tr-tr/csharp-tr.html.markdown +++ b/tr-tr/csharp-tr.html.markdown @@ -266,9 +266,9 @@ on a new line! ""Wow!"", the masses cried"; // Switch Case // Bir switch byte, short, char ve int veri tipleri ile çalışır. - // Aynı zamanda sıralı tipler ilede çalışabilir.(Enum Tipleri bölümünde tartışıldı), - // the String class, and a few special classes that wrap - // primitive types: Character, Byte, Short, and Integer. + // Aynı zamanda sıralı tipler ile de çalışabilir.(Enum Tipleri bölümünde tartışıldı), + // String sınıfı, ve bir kaç özel sınıf kaydırılır + // basit tipler: Character, Byte, Short, and Integer. int month = 3; string monthString; switch (month) @@ -282,9 +282,9 @@ on a new line! ""Wow!"", the masses cried"; case 3: monthString = "March"; break; - // You can assign more than one case to an action - // But you can't add an action without a break before another case - // (if you want to do this, you would have to explicitly add a goto case x + // Bir aksiyon için birden fazla durum atayabilirsiniz + // Ancak, break olmadan yeni bir durum ekleyemezsiniz + // (Eğer bunu yapmak istiyorsanız, goto komutu eklemek zorundasınız) case 6: case 7: case 8: @@ -296,51 +296,51 @@ on a new line! ""Wow!"", the masses cried"; } /////////////////////////////////////// - // Converting Data Types And Typecasting + // Veri Tipleri Dönüştürme ve Typecasting /////////////////////////////////////// - // Converting data + // Veri Dönüştürme - // Convert String To Integer - // this will throw an Exception on failure - int.Parse("123");//returns an integer version of "123" + // String'i Integer'a Dönüştürme + // bu başarısız olursa hata fırlatacaktır + int.Parse("123");// "123" 'in Integer değerini döndürür - // try parse will default to type default on failure - // in this case: 0 + // try parse hata durumunda değişkene varsayılan bir değer atamak için kullanılır + // bu durumda: 0 int tryInt; - if (int.TryParse("123", out tryInt)) // Function is boolean + if (int.TryParse("123", out tryInt)) // Fonksiyon boolean'dır Console.WriteLine(tryInt); // 123 - // Convert Integer To String - // Convert class has a number of methods to facilitate conversions + // Integer'ı String'e Dönüştürme + // Convert sınıfı dönüştürme işlemini kolaylaştırmak için bir dizi metoda sahiptir Convert.ToString(123); - // or + // veya tryInt.ToString(); } /////////////////////////////////////// - // CLASSES - see definitions at end of file + // SINIFLAR - dosyanın sonunda tanımları görebilirsiniz /////////////////////////////////////// public static void Classes() { - // See Declaration of objects at end of file + // Obje tanımlamalarını dosyanın sonunda görebilirsiniz - // Use new to instantiate a class + // Bir sınıfı türetmek için new kullanın Bicycle trek = new Bicycle(); - // Call object methods - trek.SpeedUp(3); // You should always use setter and getter methods + // Obje metodlarını çağırma + trek.SpeedUp(3); // Her zaman setter ve getter metodları kullanmalısınız trek.Cadence = 100; - // ToString is a convention to display the value of this Object. + // ToString objenin değerini göstermek için kullanılır. Console.WriteLine("trek info: " + trek.Info()); - // Instantiate a new Penny Farthing + // Yeni bir Penny Farthing sınıfı türetmek PennyFarthing funbike = new PennyFarthing(1, 10); Console.WriteLine("funbike info: " + funbike.Info()); Console.Read(); - } // End main method + } // Ana metodun sonu // CONSOLE ENTRY A console application must have a main method as an entry point public static void Main(string[] args) -- cgit v1.2.3 From 765e4d3be987edd441b5f3cdee83543645fca642 Mon Sep 17 00:00:00 2001 From: Melih Mucuk Date: Wed, 31 Dec 2014 19:30:07 +0200 Subject: lasssstttt --- tr-tr/csharp-tr.html.markdown | 232 +++++++++++++++++++++--------------------- 1 file changed, 114 insertions(+), 118 deletions(-) (limited to 'tr-tr') diff --git a/tr-tr/csharp-tr.html.markdown b/tr-tr/csharp-tr.html.markdown index 37a1090a..cfbee5e8 100644 --- a/tr-tr/csharp-tr.html.markdown +++ b/tr-tr/csharp-tr.html.markdown @@ -153,7 +153,7 @@ on a new line! ""Wow!"", the masses cried"; List intList = new List(); List stringList = new List(); List z = new List { 9000, 1000, 1337 }; // tanımlama - // <> işareti genelleme içindir - Güzel özellikler sekmesini inceleyin + // <> işareti generic ifadeler içindir - Güzel özellikler sekmesini inceleyin // Listelerin varsayılan bir değeri yoktur; // İndekse erişmeden önce değer eklenmiş olmalıdır @@ -342,39 +342,39 @@ on a new line! ""Wow!"", the masses cried"; Console.Read(); } // Ana metodun sonu - // CONSOLE ENTRY A console application must have a main method as an entry point + // KONSOLE BAŞLANGICI Bir konsol uygulaması başlangıç olarak mutlaka ana metod'a sahip olmalı public static void Main(string[] args) { OtherInterestingFeatures(); } // - // INTERESTING FEATURES + // İLGİNÇ ÖZELLİKLER // - // DEFAULT METHOD SIGNATURES + // VARSAYILAN METOD TANIMLAMALARI - public // Visibility - static // Allows for direct call on class without object - int // Return Type, + public // Görünebilir + static // Sınıf üzerinden obje türetmeden çağırılabilir + int // Dönüş Tipi, MethodSignatures( - int maxCount, // First variable, expects an int - int count = 0, // will default the value to 0 if not passed in + int maxCount, // İlk değişken, int değer bekler + int count = 0, // Eğer değer gönderilmezse varsayılan olarak 0 değerini alır int another = 3, - params string[] otherParams // captures all other parameters passed to method + params string[] otherParams // Metoda gönderilen diğer bütün parametreleri alır ) { return -1; } - // Methods can have the same name, as long as the signature is unique + // Metodlar tanımlamalar benzersiz ise aynı isimleri alabilirler public static void MethodSignatures(string maxCount) { } - // GENERICS - // The classes for TKey and TValue is specified by the user calling this function. - // This method emulates the SetDefault of Python + // GENERIC'LER + // TKey ve TValue değerleri kullanıcı tarafından bu fonksiyon çağırılırken belirtilir. + // Bu metod Python'daki SetDefault'a benzer public static TValue SetDefault( IDictionary dictionary, TKey key, @@ -386,68 +386,66 @@ on a new line! ""Wow!"", the masses cried"; return result; } - // You can narrow down the objects that are passed in + // Gönderilen objeleri daraltabilirsiniz public static void IterateAndPrint(T toPrint) where T: IEnumerable { - // We can iterate, since T is a IEnumerable + // Eğer T IEnumerable ise tekrarlayabiliriz foreach (var item in toPrint) - // Item is an int + // Item bir int Console.WriteLine(item.ToString()); } public static void OtherInterestingFeatures() { - // OPTIONAL PARAMETERS + // İSTEĞE BAĞLI PARAMETRELER MethodSignatures(3, 1, 3, "Some", "Extra", "Strings"); - MethodSignatures(3, another: 3); // explicity set a parameter, skipping optional ones + MethodSignatures(3, another: 3); // isteğe bağlı olanlar gönderilmedi - // EXTENSION METHODS + // UZANTI METODLARI int i = 3; - i.Print(); // Defined below + i.Print(); // Aşağıda tanımlandı - // NULLABLE TYPES - great for database interaction / return values - // any value type (i.e. not a class) can be made nullable by suffixing a ? - // ? = - int? nullable = null; // short hand for Nullable + // NULLABLE TYPES - veri tabanı işlemleri için uygun / return values + // Herhangi bir değer tipi sonuna ? eklenerek nullable yapılabilir (sınıflar hariç) + // ? = + int? nullable = null; // Nullable için kısa yol Console.WriteLine("Nullable variable: " + nullable); - bool hasValue = nullable.HasValue; // true if not null + bool hasValue = nullable.HasValue; // eğer null değilse true döner - // ?? is syntactic sugar for specifying default value (coalesce) - // in case variable is null + // ?? varsayılan değer belirlemek için söz dizimsel güzel bir özellik + // bu durumda değişken null'dır int notNullable = nullable ?? 0; // 0 - // IMPLICITLY TYPED VARIABLES - you can let the compiler work out what the type is: + // TİPİ BELİRTİLMEMİŞ DEĞİŞKENLER - compiler değişkenin tipini bilmeden çalışabilir: var magic = "magic is a string, at compile time, so you still get type safety"; - // magic = 9; will not work as magic is a string, not an int + // magic = 9; string gibi çalışmayacaktır, bu bir int değil - // GENERICS + // GENERIC'LER // var phonebook = new Dictionary() { - {"Sarah", "212 555 5555"} // Add some entries to the phone book + {"Sarah", "212 555 5555"} // Telefon rehberine bir kaç numara ekleyelim. }; - // Calling SETDEFAULT defined as a generic above - Console.WriteLine(SetDefault(phonebook, "Shaun", "No Phone")); // No Phone - // nb, you don't need to specify the TKey and TValue since they can be - // derived implicitly + // Yukarıda generic olarak tanımlanan SETDEFAULT'u çağırma + Console.WriteLine(SetDefault(phonebook, "Shaun", "No Phone")); // Telefonu yok + // TKey ve TValue tipini belirtmek zorunda değilsiniz Console.WriteLine(SetDefault(phonebook, "Sarah", "No Phone")); // 212 555 5555 - // LAMBDA EXPRESSIONS - allow you to write code in line - Func square = (x) => x * x; // Last T item is the return value + // LAMBDA IFADELERİ - satır içinde kod yazmanıza olanak sağlar + Func square = (x) => x * x; // Son T nesnesi dönüş değeridir Console.WriteLine(square(3)); // 9 - // DISPOSABLE RESOURCES MANAGEMENT - let you handle unmanaged resources easily. - // Most of objects that access unmanaged resources (file handle, device contexts, etc.) - // implement the IDisposable interface. The using statement takes care of - // cleaning those IDisposable objects for you. + // TEK KULLANIMLIK KAYNAK YÖNETİMİ - Yönetilemeyen kaynakların üstesinden kolayca gelebilirsiniz. + // Bir çok obje yönetilemeyen kaynaklara (dosya yakalama, cihaz içeriği, vb.) + // IDisposable arabirimi ile erişebilir. Using ifadesi sizin için IDisposable objeleri temizler. using (StreamWriter writer = new StreamWriter("log.txt")) { writer.WriteLine("Nothing suspicious here"); - // At the end of scope, resources will be released. - // Even if an exception is thrown. + // Bu bölümün sonunda kaynaklar temilenir. + // Hata fırlatılmış olsa bile. } - // PARALLEL FRAMEWORK + // PARALEL FRAMEWORK // http://blogs.msdn.com/b/csharpfaq/archive/2010/06/01/parallel-programming-in-net-framework-4-getting-started.aspx var websites = new string[] { "http://www.google.com", "http://www.reddit.com", @@ -455,73 +453,71 @@ on a new line! ""Wow!"", the masses cried"; }; var responses = new Dictionary(); - // Will spin up separate threads for each request, and join on them - // before going to the next step! + // Her istek farklı bir thread de işlem görecek + // bir sonraki işleme geçmeden birleştirilecek. Parallel.ForEach(websites, - new ParallelOptions() {MaxDegreeOfParallelism = 3}, // max of 3 threads + new ParallelOptions() {MaxDegreeOfParallelism = 3}, // en fazla 3 thread kullanmak için website => { - // Do something that takes a long time on the file + // Uzun sürecek bir işlem yapın using (var r = WebRequest.Create(new Uri(website)).GetResponse()) { responses[website] = r.ContentType; } }); - // This won't happen till after all requests have been completed + // Bütün istekler tamamlanmadan bu döndü çalışmayacaktır. foreach (var key in responses.Keys) Console.WriteLine("{0}:{1}", key, responses[key]); - // DYNAMIC OBJECTS (great for working with other languages) + // DİNAMİK OBJELER (diğer dillerle çalışırken kullanmak için uygun) dynamic student = new ExpandoObject(); - student.FirstName = "First Name"; // No need to define class first! + student.FirstName = "First Name"; // Önce yeni bir sınıf tanımlamanız gerekmez! - // You can even add methods (returns a string, and takes in a string) + // Hatta metod bile ekleyebilirsiniz (bir string döner, ve bir string alır) student.Introduce = new Func( (introduceTo) => string.Format("Hey {0}, this is {1}", student.FirstName, introduceTo)); Console.WriteLine(student.Introduce("Beth")); - // IQUERYABLE - almost all collections implement this, which gives you a lot of - // very useful Map / Filter / Reduce style methods + // IQUERYABLE - neredeyse bütün koleksiyonlar bundan türer, bu size bir çok + // kullanışlı Map / Filter / Reduce stili metod sağlar. var bikes = new List(); - bikes.Sort(); // Sorts the array - bikes.Sort((b1, b2) => b1.Wheels.CompareTo(b2.Wheels)); // Sorts based on wheels + bikes.Sort(); // Dizi sıralama + bikes.Sort((b1, b2) => b1.Wheels.CompareTo(b2.Wheels)); // Wheels baz alınarak sıralama var result = bikes - .Where(b => b.Wheels > 3) // Filters - chainable (returns IQueryable of previous type) + .Where(b => b.Wheels > 3) // Filters- chainable (bir önceki tipin IQueryable'ını döner) .Where(b => b.IsBroken && b.HasTassles) - .Select(b => b.ToString()); // Map - we only this selects, so result is a IQueryable + .Select(b => b.ToString()); // Map - sadece bunu seçiyoruz, yani sonuç bir IQueryable olacak - var sum = bikes.Sum(b => b.Wheels); // Reduce - sums all the wheels in the collection + var sum = bikes.Sum(b => b.Wheels); // Reduce - koleksiyonda bulunan bütün wheel değerlerinin toplamı - // Create a list of IMPLICIT objects based on some parameters of the bike + // Bike içindeki bazı parametreleri baz alarak bir liste oluşturmak var bikeSummaries = bikes.Select(b=>new { Name = b.Name, IsAwesome = !b.IsBroken && b.HasTassles }); - // Hard to show here, but you get type ahead completion since the compiler can implicitly work - // out the types above! + // Burada göstermek zor ama, compiler yukaridaki tipleri çözümleyebilirse derlenmeden önce tipi verebilir. foreach (var bikeSummary in bikeSummaries.Where(b => b.IsAwesome)) Console.WriteLine(bikeSummary.Name); // ASPARALLEL - // And this is where things get wicked - combines linq and parallel operations + // Linq ve paralel işlemlerini birleştirme var threeWheelers = bikes.AsParallel().Where(b => b.Wheels == 3).Select(b => b.Name); - // this will happen in parallel! Threads will automagically be spun up and the - // results divvied amongst them! Amazing for large datasets when you have lots of - // cores + // bu paralel bir şekilde gerçekleşecek! Threadler otomatik ve sihirli bir şekilde işleri paylaşacak! + // Birden fazla çekirdeğiniz varsa büyük veri setleri ile kullanmak için oldukça uygun bir yapı. - // LINQ - maps a store to IQueryable objects, with delayed execution - // e.g. LinqToSql - maps to a database, LinqToXml maps to an xml document + // LINQ - IQueryable objelerini mapler ve saklar, gecikmeli bir işlemdir + // e.g. LinqToSql - veri tabanını mapler, LinqToXml xml dökümanlarını mapler. var db = new BikeRepository(); - // execution is delayed, which is great when querying a database - var filter = db.Bikes.Where(b => b.HasTassles); // no query run - if (42 > 6) // You can keep adding filters, even conditionally - great for "advanced search" functionality - filter = filter.Where(b => b.IsBroken); // no query run + // işlem gecikmelidir, bir veri tabanı üzerinde sorgulama yaparken harikadır. + var filter = db.Bikes.Where(b => b.HasTassles); // sorgu henüz çalışmadı + if (42 > 6) // Filtreler eklemeye devam edebilirsiniz - ileri düzey arama fonksiyonları için harikadır + filter = filter.Where(b => b.IsBroken); // sorgu henüz çalışmadı var query = filter .OrderBy(b => b.Wheels) .ThenBy(b => b.Name) - .Select(b => b.Name); // still no query run + .Select(b => b.Name); // hala sorgu çalışmadı - // Now the query runs, but opens a reader, so only populates are you iterate through + // Şimdi sorgu çalışıyor, reader'ı açar ama sadece sizin sorgunuza uyanlar foreach döngüsüne girer. foreach (string bike in query) Console.WriteLine(result); @@ -529,98 +525,98 @@ on a new line! ""Wow!"", the masses cried"; } - } // End LearnCSharp class + } // LearnCSharp sınıfının sonu - // You can include other classes in a .cs file + // Bir .cs dosyasına diğer sınıflarıda dahil edebilirsiniz public static class Extensions { - // EXTENSION FUNCTIONS + // UZANTI FONKSİYONLARI public static void Print(this object obj) { Console.WriteLine(obj.ToString()); } } - // Class Declaration Syntax: - // class { - // //data fields, constructors, functions all inside. - // //functions are called as methods in Java. + // Sınıf Tanımlama Sözdizimi: + // class { + // //veri alanları, kurucular , fonksiyonlar hepsi içindedir. + // //Fonksiyonlar Java'daki gibi metod olarak çağırılır. // } public class Bicycle { - // Bicycle's Fields/Variables - public int Cadence // Public: Can be accessed from anywhere + // Bicycle'ın Alanları/Değişkenleri + public int Cadence // Public: herhangi bir yerden erişilebilir { - get // get - define a method to retrieve the property + get // get - değeri almak için tanımlanan metod { return _cadence; } - set // set - define a method to set a proprety + set // set - değer atamak için tanımlanan metod { - _cadence = value; // Value is the value passed in to the setter + _cadence = value; // Değer setter'a gönderilen value değeridir } } private int _cadence; - protected virtual int Gear // Protected: Accessible from the class and subclasses + protected virtual int Gear // Protected: Sınıf ve alt sınıflar tarafından erişilebilir { - get; // creates an auto property so you don't need a member field + get; // bir üye alanına ihtiyacınız yok, bu otomatik olarak bir değer oluşturacaktır set; } - internal int Wheels // Internal: Accessible from within the assembly + internal int Wheels // Internal: Assembly tarafından erişilebilir { get; - private set; // You can set modifiers on the get/set methods + private set; // Nitelik belirleyicileri get/set metodlarında atayabilirsiniz } - int _speed; // Everything is private by default: Only accessible from within this class. - // can also use keyword private + int _speed; // Her şey varsayılan olarak private'dır : Sadece sınıf içinden erişilebilir. + // İsterseniz yinede private kelimesini kullanabilirsiniz. public string Name { get; set; } - // Enum is a value type that consists of a set of named constants - // It is really just mapping a name to a value (an int, unless specified otherwise). - // The approved types for an enum are byte, sbyte, short, ushort, int, uint, long, or ulong. - // An enum can't contain the same value twice. + // Enum sabitler kümesinden oluşan bir değer tipidir. + // Gerçekten sadece bir isim ile bir değeri tutmak için kullanılır. (aksi belirtilmedikçe bir int'dir). + // İzin verilen enum tipleri şunlardır byte, sbyte, short, ushort, int, uint, long, veya ulong. + // Bir enum aynı değeri birden fazla sayıda barındıramaz. public enum BikeBrand { AIST, BMC, - Electra = 42, //you can explicitly set a value to a name + Electra = 42, // bir isme tam bir değer verebilirsiniz Gitane // 43 } - // We defined this type inside a Bicycle class, so it is a nested type - // Code outside of this class should reference this type as Bicycle.Brand + // Bu tipi Bicycle sınıfı içinde tanımladığımız için bu bir bağımlı tipdir. + // Bu sınıf dışında kullanmak için tipi Bicycle.Brand olarak kullanmamız gerekir - public BikeBrand Brand; // After declaring an enum type, we can declare the field of this type + public BikeBrand Brand; // Enum tipini tanımladıktan sonra alan tipini tanımlayabiliriz - // Static members belong to the type itself rather then specific object. - // You can access them without a reference to any object: + // Static üyeler belirli bir obje yerine kendi tipine aittir + // Onlara bir obje referans göstermeden erişebilirsiniz: // Console.WriteLine("Bicycles created: " + Bicycle.bicyclesCreated); static public int BicyclesCreated = 0; - // readonly values are set at run time - // they can only be assigned upon declaration or in a constructor + // readonly değerleri çalışma zamanında atanır + // onlara sadece tanımlama yapılarak ya da kurucular içinden atama yapılabilir readonly bool _hasCardsInSpokes = false; // read-only private - // Constructors are a way of creating classes - // This is a default constructor + // Kurucular sınıf oluşturmanın bir yoludur + // Bu bir varsayılan kurucudur. public Bicycle() { - this.Gear = 1; // you can access members of the object with the keyword this - Cadence = 50; // but you don't always need it + this.Gear = 1; // bu objenin üyelerine this anahtar kelimesi ile ulaşılır + Cadence = 50; // ama her zaman buna ihtiyaç duyulmaz _speed = 5; Name = "Bontrager"; Brand = BikeBrand.AIST; BicyclesCreated++; } - // This is a specified constructor (it contains arguments) + // Bu belirlenmiş bir kurucudur. (argümanlar içerir) public Bicycle(int startCadence, int startSpeed, int startGear, string name, bool hasCardsInSpokes, BikeBrand brand) - : base() // calls base first + : base() // önce base'i çağırın { Gear = startGear; Cadence = startCadence; @@ -630,20 +626,20 @@ on a new line! ""Wow!"", the masses cried"; Brand = brand; } - // Constructors can be chained + // Kurucular zincirleme olabilir public Bicycle(int startCadence, int startSpeed, BikeBrand brand) : this(startCadence, startSpeed, 0, "big wheels", true, brand) { } - // Function Syntax: - // () + // Fonksiyon Sözdizimi: + // () - // classes can implement getters and setters for their fields - // or they can implement properties (this is the preferred way in C#) + // sınıflar getter ve setter'ları alanları için kendisi uygular + // veya kendisi özellikleri uygulayabilir (C# da tercih edilen yol budur) - // Method parameters can have default values. - // In this case, methods can be called with these parameters omitted + // Metod parametreleri varsayılan değerlere sahip olabilir. + // Bu durumda, metodlar bu parametreler olmadan çağırılabilir. public void SpeedUp(int increment = 1) { _speed += increment; -- cgit v1.2.3 From 3f305ab2831b9e3a1ca9dce35ab42386989e9a61 Mon Sep 17 00:00:00 2001 From: Melih Mucuk Date: Wed, 31 Dec 2014 20:07:15 +0200 Subject: completed --- tr-tr/csharp-tr.html.markdown | 71 +++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 36 deletions(-) (limited to 'tr-tr') diff --git a/tr-tr/csharp-tr.html.markdown b/tr-tr/csharp-tr.html.markdown index cfbee5e8..e5cd3730 100644 --- a/tr-tr/csharp-tr.html.markdown +++ b/tr-tr/csharp-tr.html.markdown @@ -636,7 +636,7 @@ on a new line! ""Wow!"", the masses cried"; // () // sınıflar getter ve setter'ları alanları için kendisi uygular - // veya kendisi özellikleri uygulayabilir (C# da tercih edilen yol budur) + // veya property'ler eklenebilir (C# da tercih edilen yol budur) // Metod parametreleri varsayılan değerlere sahip olabilir. // Bu durumda, metodlar bu parametreler olmadan çağırılabilir. @@ -650,35 +650,34 @@ on a new line! ""Wow!"", the masses cried"; _speed -= decrement; } - // properties get/set values - // when only data needs to be accessed, consider using properties. - // properties may have either get or set, or both - private bool _hasTassles; // private variable + // property'lerin get/set değerleri + // sadece veri gerektiği zaman erişilebilir, kullanmak için bunu göz önünde bulundurun. + // property'ler sadece get ya da set'e sahip olabilir veya ikisine birden + private bool _hasTassles; // private değişken public bool HasTassles // public accessor { get { return _hasTassles; } set { _hasTassles = value; } } - // You can also define an automatic property in one line - // this syntax will create a backing field automatically. - // You can set an access modifier on either the getter or the setter (or both) - // to restrict its access: + // Ayrıca tek bir satırda otomatik property tanımlayabilirsiniz. + // bu söz dizimi otomatik olarak alan oluşturacaktır. + // Erişimi kısıtlamak için nitelik belirleyiciler getter veya setter'a ya da ikisine birden atanabilir: public bool IsBroken { get; private set; } - // Properties can be auto-implemented + // Property'ler otomatik eklenmiş olabilir public int FrameSize { get; - // you are able to specify access modifiers for either get or set - // this means only Bicycle class can call set on Framesize + // nitelik beliryecileri get veya set için tanımlayabilirsiniz + // bu sadece Bicycle sınıfı Framesize değerine atama yapabilir demektir private set; } - // It's also possible to define custom Indexers on objects. - // All though this is not entirely useful in this example, you - // could do bicycle[0] which yields "chris" to get the first passenger or - // bicycle[1] = "lisa" to set the passenger. (of this apparent quattrocycle) + // Ayrıca obje üzerinde özel indeksleyici belirlemek mümkündür. + // Tüm bunlar bu örnek için çok kullanışlı değil, + // bicycle[0] ile ilk yolcu olan "chris" i almak mümkün veya + // bicycle[1] = "lisa" ile yolcuyu atayabilirsiniz. (bariz quattrocycle) private string[] passengers = { "chris", "phil", "darren", "regina" } public string this[int i] @@ -692,7 +691,7 @@ on a new line! ""Wow!"", the masses cried"; } } - //Method to display the attribute values of this Object. + //Bu objenin nitelik değerlerini göstermek için bir metod. public virtual string Info() { return "Gear: " + Gear + @@ -704,23 +703,23 @@ on a new line! ""Wow!"", the masses cried"; ; } - // Methods can also be static. It can be useful for helper methods + // Metodlar static olabilir. Yardımcı metodlar için kullanışlı olabilir. public static bool DidWeCreateEnoughBycles() { - // Within a static method, we only can reference static class members + // Bir static metod içinde sadece static sınıf üyeleri referans gösterilebilir return BicyclesCreated > 9000; - } // If your class only needs static members, consider marking the class itself as static. + } // Eğer sınıfınızın sadece static üyelere ihtiyacı varsa, sınıfın kendisini static yapmayı düşünebilirsiniz. - } // end class Bicycle + } // Bicycle sınıfı sonu - // PennyFarthing is a subclass of Bicycle + // PennyFarthing , Bicycle sınıfının alt sınıfıdır. class PennyFarthing : Bicycle { - // (Penny Farthings are those bicycles with the big front wheel. - // They have no gears.) + // (Penny Farthing'ler ön jantı büyük bisikletlerdir. + // Vitesleri yoktur.) - // calling parent constructor + // Ana kurucuyu çağırmak public PennyFarthing(int startCadence, int startSpeed) : base(startCadence, startSpeed, 0, "PennyFarthing", true, BikeBrand.Electra) { @@ -741,23 +740,23 @@ on a new line! ""Wow!"", the masses cried"; public override string Info() { string result = "PennyFarthing bicycle "; - result += base.ToString(); // Calling the base version of the method + result += base.ToString(); // Metodun temel versiyonunu çağırmak return result; } } - // Interfaces only contain signatures of the members, without the implementation. + // Arabirimler sadece üyelerin izlerini içerir, değerlerini değil. interface IJumpable { - void Jump(int meters); // all interface members are implicitly public + void Jump(int meters); // bütün arbirim üyeleri public'tir } interface IBreakable { - bool Broken { get; } // interfaces can contain properties as well as methods & events + bool Broken { get; } // arabirimler property'leri, metodları ve olayları içerebilir } - // Class can inherit only one other class, but can implement any amount of interfaces + // Sınıflar sadece tek bir sınıftan miras alabilir ama sınırsız sayıda arabirime sahip olabilir class MountainBike : Bicycle, IJumpable, IBreakable { int damage = 0; @@ -777,8 +776,8 @@ on a new line! ""Wow!"", the masses cried"; } /// - /// Used to connect to DB for LinqToSql example. - /// EntityFramework Code First is awesome (similar to Ruby's ActiveRecord, but bidirectional) + /// LinqToSql örneği veri tabanına bağlanmak için kullanılır. + /// EntityFramework Code First harika! (Ruby'deki ActiveRecord'a benzer, ama iki yönlü) /// http://msdn.microsoft.com/en-us/data/jj193542.aspx /// public class BikeRepository : DbSet @@ -790,10 +789,10 @@ on a new line! ""Wow!"", the masses cried"; public DbSet Bikes { get; set; } } -} // End Namespace +} // Namespace sonu ``` -## Topics Not Covered +## İşlenmeyen Konular * Flags * Attributes @@ -803,7 +802,7 @@ on a new line! ""Wow!"", the masses cried"; * Winforms * Windows Presentation Foundation (WPF) -## Further Reading +## Daha Fazlasını Okuyun * [DotNetPerls](http://www.dotnetperls.com) * [C# in Depth](http://manning.com/skeet2) @@ -817,4 +816,4 @@ on a new line! ""Wow!"", the masses cried"; -[C# Coding Conventions](http://msdn.microsoft.com/en-us/library/vstudio/ff926074.aspx) +[C# Kodlama Adetleri](http://msdn.microsoft.com/en-us/library/vstudio/ff926074.aspx) -- cgit v1.2.3 From 634efbb8caaf02feba5f09edd450df1d684e6660 Mon Sep 17 00:00:00 2001 From: Melih Mucuk Date: Wed, 31 Dec 2014 20:08:42 +0200 Subject: csharp/tr --- tr-tr/csharp-tr.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tr-tr') diff --git a/tr-tr/csharp-tr.html.markdown b/tr-tr/csharp-tr.html.markdown index e5cd3730..c20f90ad 100644 --- a/tr-tr/csharp-tr.html.markdown +++ b/tr-tr/csharp-tr.html.markdown @@ -789,7 +789,7 @@ on a new line! ""Wow!"", the masses cried"; public DbSet Bikes { get; set; } } -} // Namespace sonu +} // namespace sonu ``` ## İşlenmeyen Konular -- cgit v1.2.3 From 71eda7df766a2be9777d977b8b3b946e37ee82d9 Mon Sep 17 00:00:00 2001 From: Melih Mucuk Date: Wed, 31 Dec 2014 20:11:54 +0200 Subject: csharp/tr --- tr-tr/csharp-tr.html.markdown | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tr-tr') diff --git a/tr-tr/csharp-tr.html.markdown b/tr-tr/csharp-tr.html.markdown index c20f90ad..3573bbd4 100644 --- a/tr-tr/csharp-tr.html.markdown +++ b/tr-tr/csharp-tr.html.markdown @@ -11,6 +11,8 @@ filename: LearnCSharp.cs C# zarif ve tip güvenli nesne yönelimli bir dil olup geliştiricilerin .NET framework üzerinde çalışan güçlü ve güvenli uygulamalar geliştirmesini sağlar. +[Yazım yanlışları ve öneriler için bana ulaşabilirsiniz](mailto:melihmucuk@gmail.com) + [Daha fazlasını okuyun.](http://msdn.microsoft.com/en-us/library/vstudio/z1zx9t92.aspx) ```c# -- cgit v1.2.3 From 3cb53d9e43143d330cd65c2f29fff93ffa0110f4 Mon Sep 17 00:00:00 2001 From: Melih Mucuk Date: Wed, 31 Dec 2014 20:18:46 +0200 Subject: csharp/tr --- tr-tr/csharp-tr.html.markdown | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tr-tr') diff --git a/tr-tr/csharp-tr.html.markdown b/tr-tr/csharp-tr.html.markdown index 3573bbd4..7755ed44 100644 --- a/tr-tr/csharp-tr.html.markdown +++ b/tr-tr/csharp-tr.html.markdown @@ -5,8 +5,11 @@ contributors: - ["Max Yankov", "https://github.com/golergka"] - ["Melvyn Laïly", "http://x2a.yt"] - ["Shaun McCarthy", "http://www.shaunmccarthy.com"] +translators: - ["Melih Mucuk", "http://melihmucuk.com"] +lang: tr-tr filename: LearnCSharp.cs + --- C# zarif ve tip güvenli nesne yönelimli bir dil olup geliştiricilerin .NET framework üzerinde çalışan güçlü ve güvenli uygulamalar geliştirmesini sağlar. -- cgit v1.2.3 From c5c8004450567a4be4c814e3c18725688c1601b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eray=20Ayd=C4=B1n?= Date: Wed, 25 Mar 2015 19:50:46 +0200 Subject: Primitive Datatypes and Operators --- tr-tr/python3-tr.html.markdown | 645 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 645 insertions(+) create mode 100644 tr-tr/python3-tr.html.markdown (limited to 'tr-tr') diff --git a/tr-tr/python3-tr.html.markdown b/tr-tr/python3-tr.html.markdown new file mode 100644 index 00000000..d815e4f9 --- /dev/null +++ b/tr-tr/python3-tr.html.markdown @@ -0,0 +1,645 @@ +--- +language: python3 +contributors: + - ["Louie Dinh", "http://pythonpracticeprojects.com"] + - ["Steven Basart", "http://github.com/xksteven"] + - ["Andre Polykanine", "https://github.com/Oire"] + - ["Andre Polykanine", "https://github.com/Oire"] +translators: + - ["Eray AYDIN", "http://erayaydin.me/"] +lang: tr-tr +filename: learnpython3-tr.py +--- + +Python,90ların başlarında Guido Van Rossum tarafından oluşturulmuştur. En popüler olan dillerden biridir. Beni Python'a aşık eden sebep onun syntax beraklığı. Çok basit bir çalıştırılabilir söz koddur. + +Not: Bu makale Python 3 içindir. Eğer Python 2.7 öğrenmek istiyorsanız [burayı](http://learnxinyminutes.com/docs/python/) kontrol edebilirsiniz. + +```python + +# Single line comments start with a number symbol. + +""" Multiline strings can be written + using three "s, and are often used + as comments +""" + +#################################################### +## 1. Primitive Datatypes and Operators +#################################################### + +# You have numbers +3 # => 3 + +# Math is what you would expect +1 + 1 # => 2 +8 - 1 # => 7 +10 * 2 # => 20 + +# Except division which returns floats by default +35 / 5 # => 7.0 + +# Result of integer division truncated down both for positive and negative. +5 // 3 # => 1 +5.0 // 3.0 # => 1.0 # works on floats too +-5 // 3 # => -2 +-5.0 // 3.0 # => -2.0 + +# When you use a float, results are floats +3 * 2.0 # => 6.0 + +# Modulo operation +7 % 3 # => 1 + +# Exponentiation (x to the yth power) +2**4 # => 16 + +# Enforce precedence with parentheses +(1 + 3) * 2 # => 8 + +# Boolean values are primitives +True +False + +# negate with not +not True # => False +not False # => True + +# Boolean Operators +# Note "and" and "or" are case-sensitive +True and False #=> False +False or True #=> True + +# Note using Bool operators with ints +0 and 2 #=> 0 +-5 or 0 #=> -5 +0 == False #=> True +2 == True #=> False +1 == True #=> True + +# Equality is == +1 == 1 # => True +2 == 1 # => False + +# Inequality is != +1 != 1 # => False +2 != 1 # => True + +# More comparisons +1 < 10 # => True +1 > 10 # => False +2 <= 2 # => True +2 >= 2 # => True + +# Comparisons can be chained! +1 < 2 < 3 # => True +2 < 3 < 2 # => False + +# Strings are created with " or ' +"This is a string." +'This is also a string.' + +# Strings can be added too! But try not to do this. +"Hello " + "world!" # => "Hello world!" + +# A string can be treated like a list of characters +"This is a string"[0] # => 'T' + +# .format can be used to format strings, like this: +"{} can be {}".format("strings", "interpolated") + +# You can repeat the formatting arguments to save some typing. +"{0} be nimble, {0} be quick, {0} jump over the {1}".format("Jack", "candle stick") +#=> "Jack be nimble, Jack be quick, Jack jump over the candle stick" + +# You can use keywords if you don't want to count. +"{name} wants to eat {food}".format(name="Bob", food="lasagna") #=> "Bob wants to eat lasagna" + +# If your Python 3 code also needs to run on Python 2.5 and below, you can also +# still use the old style of formatting: +"%s can be %s the %s way" % ("strings", "interpolated", "old") + + +# None is an object +None # => None + +# Don't use the equality "==" symbol to compare objects to None +# Use "is" instead. This checks for equality of object identity. +"etc" is None # => False +None is None # => True + +# None, 0, and empty strings/lists/dicts all evaluate to False. +# All other values are True +bool(0) # => False +bool("") # => False +bool([]) #=> False +bool({}) #=> False + + +#################################################### +## 2. Variables and Collections +#################################################### + +# Python has a print function +print("I'm Python. Nice to meet you!") + +# No need to declare variables before assigning to them. +# Convention is to use lower_case_with_underscores +some_var = 5 +some_var # => 5 + +# Accessing a previously unassigned variable is an exception. +# See Control Flow to learn more about exception handling. +some_unknown_var # Raises a NameError + +# Lists store sequences +li = [] +# You can start with a prefilled list +other_li = [4, 5, 6] + +# Add stuff to the end of a list with append +li.append(1) # li is now [1] +li.append(2) # li is now [1, 2] +li.append(4) # li is now [1, 2, 4] +li.append(3) # li is now [1, 2, 4, 3] +# Remove from the end with pop +li.pop() # => 3 and li is now [1, 2, 4] +# Let's put it back +li.append(3) # li is now [1, 2, 4, 3] again. + +# Access a list like you would any array +li[0] # => 1 +# Look at the last element +li[-1] # => 3 + +# Looking out of bounds is an IndexError +li[4] # Raises an IndexError + +# You can look at ranges with slice syntax. +# (It's a closed/open range for you mathy types.) +li[1:3] # => [2, 4] +# Omit the beginning +li[2:] # => [4, 3] +# Omit the end +li[:3] # => [1, 2, 4] +# Select every second entry +li[::2] # =>[1, 4] +# Revert the list +li[::-1] # => [3, 4, 2, 1] +# Use any combination of these to make advanced slices +# li[start:end:step] + +# Remove arbitrary elements from a list with "del" +del li[2] # li is now [1, 2, 3] + +# You can add lists +# Note: values for li and for other_li are not modified. +li + other_li # => [1, 2, 3, 4, 5, 6] + +# Concatenate lists with "extend()" +li.extend(other_li) # Now li is [1, 2, 3, 4, 5, 6] + +# Check for existence in a list with "in" +1 in li # => True + +# Examine the length with "len()" +len(li) # => 6 + + +# Tuples are like lists but are immutable. +tup = (1, 2, 3) +tup[0] # => 1 +tup[0] = 3 # Raises a TypeError + +# You can do all those list thingies on tuples too +len(tup) # => 3 +tup + (4, 5, 6) # => (1, 2, 3, 4, 5, 6) +tup[:2] # => (1, 2) +2 in tup # => True + +# You can unpack tuples (or lists) into variables +a, b, c = (1, 2, 3) # a is now 1, b is now 2 and c is now 3 +# Tuples are created by default if you leave out the parentheses +d, e, f = 4, 5, 6 +# Now look how easy it is to swap two values +e, d = d, e # d is now 5 and e is now 4 + + +# Dictionaries store mappings +empty_dict = {} +# Here is a prefilled dictionary +filled_dict = {"one": 1, "two": 2, "three": 3} + +# Look up values with [] +filled_dict["one"] # => 1 + +# Get all keys as a list with "keys()". +# We need to wrap the call in list() because we are getting back an iterable. We'll talk about those later. +# Note - Dictionary key ordering is not guaranteed. +# Your results might not match this exactly. +list(filled_dict.keys()) # => ["three", "two", "one"] + + +# Get all values as a list with "values()". Once again we need to wrap it in list() to get it out of the iterable. +# Note - Same as above regarding key ordering. +list(filled_dict.values()) # => [3, 2, 1] + + +# Check for existence of keys in a dictionary with "in" +"one" in filled_dict # => True +1 in filled_dict # => False + +# Looking up a non-existing key is a KeyError +filled_dict["four"] # KeyError + +# Use "get()" method to avoid the KeyError +filled_dict.get("one") # => 1 +filled_dict.get("four") # => None +# The get method supports a default argument when the value is missing +filled_dict.get("one", 4) # => 1 +filled_dict.get("four", 4) # => 4 + +# "setdefault()" inserts into a dictionary only if the given key isn't present +filled_dict.setdefault("five", 5) # filled_dict["five"] is set to 5 +filled_dict.setdefault("five", 6) # filled_dict["five"] is still 5 + +# Adding to a dictionary +filled_dict.update({"four":4}) #=> {"one": 1, "two": 2, "three": 3, "four": 4} +#filled_dict["four"] = 4 #another way to add to dict + +# Remove keys from a dictionary with del +del filled_dict["one"] # Removes the key "one" from filled dict + + +# Sets store ... well sets +empty_set = set() +# Initialize a set with a bunch of values. Yeah, it looks a bit like a dict. Sorry. +some_set = {1, 1, 2, 2, 3, 4} # some_set is now {1, 2, 3, 4} + +# Can set new variables to a set +filled_set = some_set + +# Add one more item to the set +filled_set.add(5) # filled_set is now {1, 2, 3, 4, 5} + +# Do set intersection with & +other_set = {3, 4, 5, 6} +filled_set & other_set # => {3, 4, 5} + +# Do set union with | +filled_set | other_set # => {1, 2, 3, 4, 5, 6} + +# Do set difference with - +{1, 2, 3, 4} - {2, 3, 5} # => {1, 4} + +# Check for existence in a set with in +2 in filled_set # => True +10 in filled_set # => False + + +#################################################### +## 3. Control Flow and Iterables +#################################################### + +# Let's just make a variable +some_var = 5 + +# Here is an if statement. Indentation is significant in python! +# prints "some_var is smaller than 10" +if some_var > 10: + print("some_var is totally bigger than 10.") +elif some_var < 10: # This elif clause is optional. + print("some_var is smaller than 10.") +else: # This is optional too. + print("some_var is indeed 10.") + + +""" +For loops iterate over lists +prints: + dog is a mammal + cat is a mammal + mouse is a mammal +""" +for animal in ["dog", "cat", "mouse"]: + # You can use format() to interpolate formatted strings + print("{} is a mammal".format(animal)) + +""" +"range(number)" returns a list of numbers +from zero to the given number +prints: + 0 + 1 + 2 + 3 +""" +for i in range(4): + print(i) + +""" +While loops go until a condition is no longer met. +prints: + 0 + 1 + 2 + 3 +""" +x = 0 +while x < 4: + print(x) + x += 1 # Shorthand for x = x + 1 + +# Handle exceptions with a try/except block +try: + # Use "raise" to raise an error + raise IndexError("This is an index error") +except IndexError as e: + pass # Pass is just a no-op. Usually you would do recovery here. +except (TypeError, NameError): + pass # Multiple exceptions can be handled together, if required. +else: # Optional clause to the try/except block. Must follow all except blocks + print("All good!") # Runs only if the code in try raises no exceptions + +# Python offers a fundamental abstraction called the Iterable. +# An iterable is an object that can be treated as a sequence. +# The object returned the range function, is an iterable. + +filled_dict = {"one": 1, "two": 2, "three": 3} +our_iterable = filled_dict.keys() +print(our_iterable) #=> range(1,10). This is an object that implements our Iterable interface + +# We can loop over it. +for i in our_iterable: + print(i) # Prints one, two, three + +# However we cannot address elements by index. +our_iterable[1] # Raises a TypeError + +# An iterable is an object that knows how to create an iterator. +our_iterator = iter(our_iterable) + +# Our iterator is an object that can remember the state as we traverse through it. +# We get the next object by calling the __next__ function. +our_iterator.__next__() #=> "one" + +# It maintains state as we call __next__. +our_iterator.__next__() #=> "two" +our_iterator.__next__() #=> "three" + +# After the iterator has returned all of its data, it gives you a StopIterator Exception +our_iterator.__next__() # Raises StopIteration + +# You can grab all the elements of an iterator by calling list() on it. +list(filled_dict.keys()) #=> Returns ["one", "two", "three"] + + +#################################################### +## 4. Functions +#################################################### + +# Use "def" to create new functions +def add(x, y): + print("x is {} and y is {}".format(x, y)) + return x + y # Return values with a return statement + +# Calling functions with parameters +add(5, 6) # => prints out "x is 5 and y is 6" and returns 11 + +# Another way to call functions is with keyword arguments +add(y=6, x=5) # Keyword arguments can arrive in any order. + +# You can define functions that take a variable number of +# positional arguments +def varargs(*args): + return args + +varargs(1, 2, 3) # => (1, 2, 3) + +# You can define functions that take a variable number of +# keyword arguments, as well +def keyword_args(**kwargs): + return kwargs + +# Let's call it to see what happens +keyword_args(big="foot", loch="ness") # => {"big": "foot", "loch": "ness"} + + +# You can do both at once, if you like +def all_the_args(*args, **kwargs): + print(args) + print(kwargs) +""" +all_the_args(1, 2, a=3, b=4) prints: + (1, 2) + {"a": 3, "b": 4} +""" + +# When calling functions, you can do the opposite of args/kwargs! +# Use * to expand tuples and use ** to expand kwargs. +args = (1, 2, 3, 4) +kwargs = {"a": 3, "b": 4} +all_the_args(*args) # equivalent to foo(1, 2, 3, 4) +all_the_args(**kwargs) # equivalent to foo(a=3, b=4) +all_the_args(*args, **kwargs) # equivalent to foo(1, 2, 3, 4, a=3, b=4) + + +# Function Scope +x = 5 + +def setX(num): + # Local var x not the same as global variable x + x = num # => 43 + print (x) # => 43 + +def setGlobalX(num): + global x + print (x) # => 5 + x = num # global var x is now set to 6 + print (x) # => 6 + +setX(43) +setGlobalX(6) + + +# Python has first class functions +def create_adder(x): + def adder(y): + return x + y + return adder + +add_10 = create_adder(10) +add_10(3) # => 13 + +# There are also anonymous functions +(lambda x: x > 2)(3) # => True + +# TODO - Fix for iterables +# There are built-in higher order functions +map(add_10, [1, 2, 3]) # => [11, 12, 13] +filter(lambda x: x > 5, [3, 4, 5, 6, 7]) # => [6, 7] + +# We can use list comprehensions for nice maps and filters +# List comprehension stores the output as a list which can itself be a nested list +[add_10(i) for i in [1, 2, 3]] # => [11, 12, 13] +[x for x in [3, 4, 5, 6, 7] if x > 5] # => [6, 7] + +#################################################### +## 5. Classes +#################################################### + + +# We subclass from object to get a class. +class Human(object): + + # A class attribute. It is shared by all instances of this class + species = "H. sapiens" + + # Basic initializer, this is called when this class is instantiated. + # Note that the double leading and trailing underscores denote objects + # or attributes that are used by python but that live in user-controlled + # namespaces. Methods(or objects or attributes) like: __init__, __str__, + # __repr__ etc. are called magic methods (or sometimes called dunder methods) + # You should not invent such names on your own. + def __init__(self, name): + # Assign the argument to the instance's name attribute + self.name = name + + # An instance method. All methods take "self" as the first argument + def say(self, msg): + return "{name}: {message}".format(name=self.name, message=msg) + + # A class method is shared among all instances + # They are called with the calling class as the first argument + @classmethod + def get_species(cls): + return cls.species + + # A static method is called without a class or instance reference + @staticmethod + def grunt(): + return "*grunt*" + + +# Instantiate a class +i = Human(name="Ian") +print(i.say("hi")) # prints out "Ian: hi" + +j = Human("Joel") +print(j.say("hello")) # prints out "Joel: hello" + +# Call our class method +i.get_species() # => "H. sapiens" + +# Change the shared attribute +Human.species = "H. neanderthalensis" +i.get_species() # => "H. neanderthalensis" +j.get_species() # => "H. neanderthalensis" + +# Call the static method +Human.grunt() # => "*grunt*" + + +#################################################### +## 6. Modules +#################################################### + +# You can import modules +import math +print(math.sqrt(16)) # => 4 + +# You can get specific functions from a module +from math import ceil, floor +print(ceil(3.7)) # => 4.0 +print(floor(3.7)) # => 3.0 + +# You can import all functions from a module. +# Warning: this is not recommended +from math import * + +# You can shorten module names +import math as m +math.sqrt(16) == m.sqrt(16) # => True + +# Python modules are just ordinary python files. You +# can write your own, and import them. The name of the +# module is the same as the name of the file. + +# You can find out which functions and attributes +# defines a module. +import math +dir(math) + + +#################################################### +## 7. Advanced +#################################################### + +# Generators help you make lazy code +def double_numbers(iterable): + for i in iterable: + yield i + i + +# A generator creates values on the fly. +# Instead of generating and returning all values at once it creates one in each +# iteration. This means values bigger than 15 wont be processed in +# double_numbers. +# Note range is a generator too. Creating a list 1-900000000 would take lot of +# time to be made +# We use a trailing underscore in variable names when we want to use a name that +# would normally collide with a python keyword +range_ = range(1, 900000000) +# will double all numbers until a result >=30 found +for i in double_numbers(range_): + print(i) + if i >= 30: + break + + +# Decorators +# in this example beg wraps say +# Beg will call say. If say_please is True then it will change the returned +# message +from functools import wraps + + +def beg(target_function): + @wraps(target_function) + def wrapper(*args, **kwargs): + msg, say_please = target_function(*args, **kwargs) + if say_please: + return "{} {}".format(msg, "Please! I am poor :(") + return msg + + return wrapper + + +@beg +def say(say_please=False): + msg = "Can you buy me a beer?" + return msg, say_please + + +print(say()) # Can you buy me a beer? +print(say(say_please=True)) # Can you buy me a beer? Please! I am poor :( +``` + +## Ready For More? + +### Free Online + +* [Learn Python The Hard Way](http://learnpythonthehardway.org/book/) +* [Dive Into Python](http://www.diveintopython.net/) +* [Ideas for Python Projects](http://pythonpracticeprojects.com) + +* [The Official Docs](http://docs.python.org/3/) +* [Hitchhiker's Guide to Python](http://docs.python-guide.org/en/latest/) +* [A Crash Course in Python for Scientists](http://nbviewer.ipython.org/5920182) +* [Python Course](http://www.python-course.eu/index.php) + +### Dead Tree + +* [Programming Python](http://www.amazon.com/gp/product/0596158106/ref=as_li_qf_sp_asin_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=0596158106&linkCode=as2&tag=homebits04-20) +* [Dive Into Python](http://www.amazon.com/gp/product/1441413022/ref=as_li_tf_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1441413022&linkCode=as2&tag=homebits04-20) +* [Python Essential Reference](http://www.amazon.com/gp/product/0672329786/ref=as_li_tf_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=0672329786&linkCode=as2&tag=homebits04-20) + -- cgit v1.2.3 From 46273c1ffe60c581968c9b43d1fb603a881823e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eray=20Ayd=C4=B1n?= Date: Wed, 25 Mar 2015 20:34:27 +0200 Subject: Variables and Collections --- tr-tr/python3-tr.html.markdown | 297 ++++++++++++++++++++--------------------- 1 file changed, 148 insertions(+), 149 deletions(-) (limited to 'tr-tr') diff --git a/tr-tr/python3-tr.html.markdown b/tr-tr/python3-tr.html.markdown index d815e4f9..4939f219 100644 --- a/tr-tr/python3-tr.html.markdown +++ b/tr-tr/python3-tr.html.markdown @@ -17,119 +17,119 @@ Not: Bu makale Python 3 içindir. Eğer Python 2.7 öğrenmek istiyorsanız [bur ```python -# Single line comments start with a number symbol. +# Tek satırlık yorum satırı kare(#) işareti ile başlamaktadır. -""" Multiline strings can be written - using three "s, and are often used - as comments +""" Çok satırlı olmasını istediğiniz yorumlar + üç adet tırnak(") işareti ile + yapılmaktadır """ #################################################### -## 1. Primitive Datatypes and Operators +## 1. Temel Veri Türleri ve Operatörler #################################################### -# You have numbers +# Sayılar 3 # => 3 -# Math is what you would expect +# Tahmin edebileceğiniz gibi matematik 1 + 1 # => 2 8 - 1 # => 7 10 * 2 # => 20 -# Except division which returns floats by default +# Bölme işlemi varsayılan olarak onluk döndürür 35 / 5 # => 7.0 -# Result of integer division truncated down both for positive and negative. +# Tam sayı bölmeleri, pozitif ve negatif sayılar için aşağıya yuvarlar 5 // 3 # => 1 -5.0 // 3.0 # => 1.0 # works on floats too +5.0 // 3.0 # => 1.0 # onluklar için de bu böyledir -5 // 3 # => -2 -5.0 // 3.0 # => -2.0 -# When you use a float, results are floats +# Onluk kullanırsanız, sonuç da onluk olur 3 * 2.0 # => 6.0 -# Modulo operation +# Kalan operatörü 7 % 3 # => 1 -# Exponentiation (x to the yth power) +# Üs (2 üzeri 4) 2**4 # => 16 -# Enforce precedence with parentheses +# Parantez ile önceliği değiştirebilirsiniz (1 + 3) * 2 # => 8 -# Boolean values are primitives +# Boolean(Doğru-Yanlış) değerleri standart True False -# negate with not +# 'değil' ile terse çevirme not True # => False not False # => True -# Boolean Operators -# Note "and" and "or" are case-sensitive +# Boolean Operatörleri +# "and" ve "or" büyük küçük harf duyarlıdır True and False #=> False False or True #=> True -# Note using Bool operators with ints +# Bool operatörleri ile sayı kullanımı 0 and 2 #=> 0 -5 or 0 #=> -5 0 == False #=> True 2 == True #=> False 1 == True #=> True -# Equality is == +# Eşitlik kontrolü == 1 == 1 # => True 2 == 1 # => False -# Inequality is != +# Eşitsizlik Kontrolü != 1 != 1 # => False 2 != 1 # => True -# More comparisons +# Diğer karşılaştırmalar 1 < 10 # => True 1 > 10 # => False 2 <= 2 # => True 2 >= 2 # => True -# Comparisons can be chained! +# Zincirleme şeklinde karşılaştırma da yapabilirsiniz! 1 < 2 < 3 # => True 2 < 3 < 2 # => False -# Strings are created with " or ' -"This is a string." -'This is also a string.' +# Yazı(Strings) " veya ' işaretleri ile oluşturulabilir +"Bu bir yazı." +'Bu da bir yazı.' -# Strings can be added too! But try not to do this. -"Hello " + "world!" # => "Hello world!" +# Yazılar da eklenebilir! Fakat bunu yapmanızı önermem. +"Merhaba " + "dünya!" # => "Merhaba dünya!" -# A string can be treated like a list of characters -"This is a string"[0] # => 'T' +# Bir yazı(string) karakter listesi gibi işlenebilir +"Bu bir yazı"[0] # => 'B' -# .format can be used to format strings, like this: -"{} can be {}".format("strings", "interpolated") +# .format ile yazıyı biçimlendirebilirsiniz, şu şekilde: +"{} da ayrıca {}".format("yazılar", "işlenebilir") -# You can repeat the formatting arguments to save some typing. -"{0} be nimble, {0} be quick, {0} jump over the {1}".format("Jack", "candle stick") -#=> "Jack be nimble, Jack be quick, Jack jump over the candle stick" +# Biçimlendirme işleminde aynı argümanı da birden fazla kullanabilirsiniz. +"{0} çeviktir, {0} hızlıdır, {0} , {1} üzerinden atlayabilir".format("Ahmet", "şeker çubuğu") +#=> "Ahmet çeviktir, Ahmet hızlıdır, Ahmet , şeker çubuğu üzerinden atlayabilir" -# You can use keywords if you don't want to count. -"{name} wants to eat {food}".format(name="Bob", food="lasagna") #=> "Bob wants to eat lasagna" +# Argümanın sırasını saymak istemiyorsanız, anahtar kelime kullanabilirsiniz. +"{isim} yemek olarak {yemek} istiyor".format(isim="Ahmet", yemek="patates") #=> "Ahmet yemek olarak patates istiyor" -# If your Python 3 code also needs to run on Python 2.5 and below, you can also -# still use the old style of formatting: -"%s can be %s the %s way" % ("strings", "interpolated", "old") +# Eğer Python 3 kodunuz ayrıca Python 2.5 ve üstünde çalışmasını istiyorsanız, +# eski stil formatlamayı kullanabilirsiniz: +"%s bu %s yolla da %s" % ("yazılar", "eski", "biçimlendirilebilir") -# None is an object +# Hiçbir şey(none) da bir objedir None # => None -# Don't use the equality "==" symbol to compare objects to None -# Use "is" instead. This checks for equality of object identity. -"etc" is None # => False +# Bir değerin none ile eşitlik kontrolü için "==" sembolünü kullanmayın +# Bunun yerine "is" kullanın. Obje türünün eşitliğini kontrol edecektir. +"vb" is None # => False None is None # => True -# None, 0, and empty strings/lists/dicts all evaluate to False. -# All other values are True +# None, 0, ve boş yazılar/listeler/sözlükler hepsi False değeri döndürü. +# Diğer veriler ise True değeri döndürür bool(0) # => False bool("") # => False bool([]) #=> False @@ -137,164 +137,163 @@ bool({}) #=> False #################################################### -## 2. Variables and Collections +## 2. Değişkenler ve Koleksiyonlar #################################################### -# Python has a print function -print("I'm Python. Nice to meet you!") +# Python bir yazdırma fonksiyonuna sahip +print("Ben Python. Tanıştığıma memnun oldum!") -# No need to declare variables before assigning to them. -# Convention is to use lower_case_with_underscores -some_var = 5 -some_var # => 5 +# Değişkenlere veri atamak için önce değişkeni oluşturmanıza gerek yok. +# Düzenli bir değişken için hepsi_kucuk_ve_alt_cizgi_ile_ayirin +bir_degisken = 5 +bir_degisken # => 5 -# Accessing a previously unassigned variable is an exception. -# See Control Flow to learn more about exception handling. -some_unknown_var # Raises a NameError +# Önceden tanımlanmamış değişkene erişmek hata oluşturacaktır. +# Kontrol akışları başlığından hata kontrolünü öğrenebilirsiniz. +bir_bilinmeyen_degisken # NameError hatası oluşturur -# Lists store sequences +# Listeler ile sıralamaları tutabilirsiniz li = [] -# You can start with a prefilled list -other_li = [4, 5, 6] - -# Add stuff to the end of a list with append -li.append(1) # li is now [1] -li.append(2) # li is now [1, 2] -li.append(4) # li is now [1, 2, 4] -li.append(3) # li is now [1, 2, 4, 3] -# Remove from the end with pop -li.pop() # => 3 and li is now [1, 2, 4] -# Let's put it back -li.append(3) # li is now [1, 2, 4, 3] again. - -# Access a list like you would any array +# Önceden doldurulmuş listeler ile başlayabilirsiniz +diger_li = [4, 5, 6] + +# 'append' ile listenin sonuna ekleme yapabilirsiniz +li.append(1) # li artık [1] oldu +li.append(2) # li artık [1, 2] oldu +li.append(4) # li artık [1, 2, 4] oldu +li.append(3) # li artık [1, 2, 4, 3] oldu +# 'pop' ile listenin son elementini kaldırabilirsiniz +li.pop() # => 3 ve li artık [1, 2, 4] +# Çıkarttığımız tekrardan ekleyelim +li.append(3) # li yeniden [1, 2, 4, 3] oldu. + +# Dizi gibi listeye erişim sağlayın li[0] # => 1 -# Look at the last element +# Son elemente bakın li[-1] # => 3 -# Looking out of bounds is an IndexError -li[4] # Raises an IndexError +# Listede olmayan bir elemente erişim sağlamaya çalışmak IndexError hatası oluşturur +li[4] # IndexError hatası oluşturur -# You can look at ranges with slice syntax. -# (It's a closed/open range for you mathy types.) +# Bir kısmını almak isterseniz. li[1:3] # => [2, 4] -# Omit the beginning +# Başlangıç belirtmezseniz li[2:] # => [4, 3] -# Omit the end +# Sonu belirtmesseniz li[:3] # => [1, 2, 4] -# Select every second entry +# Her ikişer objeyi seçme li[::2] # =>[1, 4] -# Revert the list +# Listeyi tersten almak li[::-1] # => [3, 4, 2, 1] -# Use any combination of these to make advanced slices -# li[start:end:step] +# Kombinasyonları kullanarak gelişmiş bir şekilde listenin bir kısmını alabilirsiniz +# li[baslangic:son:adim] -# Remove arbitrary elements from a list with "del" -del li[2] # li is now [1, 2, 3] +# "del" ile isteğe bağlı, elementleri listeden kaldırabilirsiniz +del li[2] # li artık [1, 2, 3] oldu -# You can add lists -# Note: values for li and for other_li are not modified. -li + other_li # => [1, 2, 3, 4, 5, 6] +# Listelerde de ekleme yapabilirsiniz +# Not: değerler üzerinde değişiklik yapılmaz. +li + diger_li # => [1, 2, 3, 4, 5, 6] -# Concatenate lists with "extend()" -li.extend(other_li) # Now li is [1, 2, 3, 4, 5, 6] +# Listeleri birbirine bağlamak için "extend()" kullanılabilir +li.extend(diger_li) # li artık [1, 2, 3, 4, 5, 6] oldu -# Check for existence in a list with "in" +# Listedeki bir elementin olup olmadığı kontrolü "in" ile yapılabilir 1 in li # => True -# Examine the length with "len()" +# Uzunluğu öğrenmek için "len()" kullanılabilir len(li) # => 6 -# Tuples are like lists but are immutable. +# Tüpler listeler gibidir fakat değiştirilemez. tup = (1, 2, 3) tup[0] # => 1 -tup[0] = 3 # Raises a TypeError +tup[0] = 3 # TypeError hatası oluşturur -# You can do all those list thingies on tuples too +# Diğer liste işlemlerini tüplerde de uygulayabilirsiniz len(tup) # => 3 tup + (4, 5, 6) # => (1, 2, 3, 4, 5, 6) tup[:2] # => (1, 2) 2 in tup # => True -# You can unpack tuples (or lists) into variables -a, b, c = (1, 2, 3) # a is now 1, b is now 2 and c is now 3 -# Tuples are created by default if you leave out the parentheses +# Tüpleri(veya listeleri) değişkenlere açabilirsiniz +a, b, c = (1, 2, 3) # 'a' artık 1, 'b' artık 2 ve 'c' artık 3 +# Eğer parantez kullanmazsanız varsayılan oalrak tüpler oluşturulur d, e, f = 4, 5, 6 -# Now look how easy it is to swap two values -e, d = d, e # d is now 5 and e is now 4 +# 2 değeri birbirine değiştirmek bu kadar kolay +e, d = d, e # 'd' artık 5 ve 'e' artık 4 -# Dictionaries store mappings -empty_dict = {} -# Here is a prefilled dictionary -filled_dict = {"one": 1, "two": 2, "three": 3} +# Sözlükler anahtar kodlarla verileri tutar +bos_sozl = {} +# Önceden doldurulmuş sözlük oluşturma +dolu_sozl = {"bir": 1, "iki": 2, "uc": 3} -# Look up values with [] -filled_dict["one"] # => 1 +# Değere bakmak için [] kullanalım +dolu_sozl["bir"] # => 1 -# Get all keys as a list with "keys()". -# We need to wrap the call in list() because we are getting back an iterable. We'll talk about those later. -# Note - Dictionary key ordering is not guaranteed. -# Your results might not match this exactly. -list(filled_dict.keys()) # => ["three", "two", "one"] +# Bütün anahtarları almak için "keys()" kullanılabilir. +# Listelemek için list() kullanacağınız çünkü dönen değerin işlenmesi gerekiyor. Bu konuya daha sonra değineceğiz. +# Not - Sözlük anahtarlarının sıralaması kesin değildir. +# Beklediğiniz çıktı sizinkiyle tam uyuşmuyor olabilir. +list(dolu_sozl.keys()) # => ["uc", "iki", "bir"] -# Get all values as a list with "values()". Once again we need to wrap it in list() to get it out of the iterable. -# Note - Same as above regarding key ordering. -list(filled_dict.values()) # => [3, 2, 1] +# Tüm değerleri almak için "values()" kullanacağız. Dönen değeri biçimlendirmek için de list() kullanmamız gerekiyor +# Not - Sıralama değişebilir. +list(dolu_sozl.values()) # => [3, 2, 1] -# Check for existence of keys in a dictionary with "in" -"one" in filled_dict # => True -1 in filled_dict # => False +# Bir anahtarın sözlükte olup olmadığını "in" ile kontrol edebilirsiniz +"bir" in dolu_sozl # => True +1 in dolu_sozl # => False -# Looking up a non-existing key is a KeyError -filled_dict["four"] # KeyError +# Olmayan bir anahtardan değer elde etmek isterseniz KeyError sorunu oluşacaktır. +dolu_sozl["dort"] # KeyError hatası oluşturur -# Use "get()" method to avoid the KeyError -filled_dict.get("one") # => 1 -filled_dict.get("four") # => None -# The get method supports a default argument when the value is missing -filled_dict.get("one", 4) # => 1 -filled_dict.get("four", 4) # => 4 +# "get()" metodu ile değeri almaya çalışırsanız KeyError sorunundan kurtulursunuz +dolu_sozl.get("bir") # => 1 +dolu_sozl.get("dort") # => None +# "get" metoduna parametre belirterek değerin olmaması durumunda varsayılan bir değer döndürebilirsiniz. +dolu_sozl.get("bir", 4) # => 1 +dolu_sozl.get("dort", 4) # => 4 -# "setdefault()" inserts into a dictionary only if the given key isn't present -filled_dict.setdefault("five", 5) # filled_dict["five"] is set to 5 -filled_dict.setdefault("five", 6) # filled_dict["five"] is still 5 +# "setdefault()" metodu sözlükte, belirttiğiniz anahtarın [olmaması] durumunda varsayılan bir değer atayacaktır +dolu_sozl.setdefault("bes", 5) # dolu_sozl["bes"] artık 5 değerine sahip +dolu_sozl.setdefault("bes", 6) # dolu_sozl["bes"] değişmedi, hala 5 değerine sahip -# Adding to a dictionary -filled_dict.update({"four":4}) #=> {"one": 1, "two": 2, "three": 3, "four": 4} -#filled_dict["four"] = 4 #another way to add to dict +# Sözlüğe ekleme +dolu_sozl.update({"dort":4}) #=> {"bir": 1, "iki": 2, "uc": 3, "dort": 4} +#dolu_sozl["dort"] = 4 #sözlüğe eklemenin bir diğer yolu -# Remove keys from a dictionary with del -del filled_dict["one"] # Removes the key "one" from filled dict +# Sözlükten anahtar silmek için 'del' kullanılabilir +del dolu_sozl["bir"] # "bir" anahtarını dolu sözlükten silecektir -# Sets store ... well sets -empty_set = set() -# Initialize a set with a bunch of values. Yeah, it looks a bit like a dict. Sorry. -some_set = {1, 1, 2, 2, 3, 4} # some_set is now {1, 2, 3, 4} +# Setler ... set işte :D +bos_set = set() +# Seti bir veri listesi ile de oluşturabilirsiniz. Evet, biraz sözlük gibi duruyor. Üzgünüm. +bir_set = {1, 1, 2, 2, 3, 4} # bir_set artık {1, 2, 3, 4} -# Can set new variables to a set -filled_set = some_set +# Sete yeni setler ekleyebilirsiniz +dolu_set = bir_set -# Add one more item to the set -filled_set.add(5) # filled_set is now {1, 2, 3, 4, 5} +# Sete bir diğer öğe ekleme +dolu_set.add(5) # dolu_set artık {1, 2, 3, 4, 5} oldu -# Do set intersection with & -other_set = {3, 4, 5, 6} -filled_set & other_set # => {3, 4, 5} +# Setlerin çakışan kısımlarını almak için '&' kullanabilirsiniz +diger_set = {3, 4, 5, 6} +dolu_set & diger_set # => {3, 4, 5} -# Do set union with | -filled_set | other_set # => {1, 2, 3, 4, 5, 6} +# '|' ile aynı olan elementleri almayacak şekilde setleri birleştirebilirsiniz +dolu_set | diger_set # => {1, 2, 3, 4, 5, 6} -# Do set difference with - +# Farklılıkları almak için "-" kullanabilirsiniz {1, 2, 3, 4} - {2, 3, 5} # => {1, 4} -# Check for existence in a set with in -2 in filled_set # => True -10 in filled_set # => False +# Bir değerin olup olmadığının kontrolü için "in" kullanılabilir +2 in dolu_set # => True +10 in dolu_set # => False #################################################### -- cgit v1.2.3 From 1ab0a6eb5e73079393844719da067c37e84b8fef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eray=20Ayd=C4=B1n?= Date: Wed, 25 Mar 2015 21:05:25 +0200 Subject: Control Flow and Iterables --- tr-tr/python3-tr.html.markdown | 109 ++++++++++++++++++++--------------------- 1 file changed, 54 insertions(+), 55 deletions(-) (limited to 'tr-tr') diff --git a/tr-tr/python3-tr.html.markdown b/tr-tr/python3-tr.html.markdown index 4939f219..b1806e7b 100644 --- a/tr-tr/python3-tr.html.markdown +++ b/tr-tr/python3-tr.html.markdown @@ -297,37 +297,37 @@ dolu_set | diger_set # => {1, 2, 3, 4, 5, 6} #################################################### -## 3. Control Flow and Iterables +## 3. Kontrol Akışları ve Temel Soyutlandırma #################################################### -# Let's just make a variable -some_var = 5 +# Bir değişken oluşturalım +bir_degisken = 5 -# Here is an if statement. Indentation is significant in python! -# prints "some_var is smaller than 10" -if some_var > 10: - print("some_var is totally bigger than 10.") -elif some_var < 10: # This elif clause is optional. - print("some_var is smaller than 10.") -else: # This is optional too. - print("some_var is indeed 10.") +# Burada bir "if" ifadesi var. Girinti(boşluk,tab) python için önemlidir! +# çıktı olarak "bir_degisken 10 dan küçük" yazar +if bir_degisken > 10: + print("bir_degisken 10 dan büyük") +elif bir_degisken < 10: # Bu 'elif' ifadesi zorunlu değildir. + print("bir_degisken 10 dan küçük") +else: # Bu ifade de zorunlu değil. + print("bir_degisken değeri 10") """ -For loops iterate over lists -prints: - dog is a mammal - cat is a mammal - mouse is a mammal +Döngülerle lsiteleri döngüye alabilirsiniz +çıktı: + köpek bir memeli hayvandır + kedi bir memeli hayvandır + fare bir memeli hayvandır """ -for animal in ["dog", "cat", "mouse"]: - # You can use format() to interpolate formatted strings - print("{} is a mammal".format(animal)) +for hayvan in ["köpek", "kedi, "fare"]: + # format ile kolayca yazıyı biçimlendirelim + print("{} bir memeli hayvandır".format(hayvan)) """ -"range(number)" returns a list of numbers -from zero to the given number -prints: +"range(sayi)" bir sayı listesi döndür +0'dan belirttiğiniz sayıyıa kadar +çıktı: 0 1 2 @@ -337,8 +337,8 @@ for i in range(4): print(i) """ -While loops go until a condition is no longer met. -prints: +'While' döngüleri koşul çalıştıkça işlemleri gerçekleştirir. +çıktı: 0 1 2 @@ -347,50 +347,49 @@ prints: x = 0 while x < 4: print(x) - x += 1 # Shorthand for x = x + 1 + x += 1 # Uzun hali x = x + 1 -# Handle exceptions with a try/except block +# Hataları kontrol altına almak için try/except bloklarını kullanabilirsiniz try: - # Use "raise" to raise an error - raise IndexError("This is an index error") + # Bir hata oluşturmak için "raise" kullanabilirsiniz + raise IndexError("Bu bir index hatası") except IndexError as e: - pass # Pass is just a no-op. Usually you would do recovery here. + pass # Önemsiz, devam et. except (TypeError, NameError): - pass # Multiple exceptions can be handled together, if required. -else: # Optional clause to the try/except block. Must follow all except blocks - print("All good!") # Runs only if the code in try raises no exceptions + pass # Çoklu bir şekilde hataları kontrol edebilirsiniz, tabi gerekirse. +else: # İsteğe bağlı bir kısım. Eğer hiçbir hata kontrol mekanizması desteklemiyorsa bu blok çalışacaktır + print("Her şey iyi!") # IndexError, TypeError ve NameError harici bir hatada bu blok çalıştı -# Python offers a fundamental abstraction called the Iterable. -# An iterable is an object that can be treated as a sequence. -# The object returned the range function, is an iterable. +# Temel Soyutlandırma, bir objenin işlenmiş halidir. +# Aşağıdaki örnekte; Obje, range fonksiyonuna temel soyutlandırma gönderdi. -filled_dict = {"one": 1, "two": 2, "three": 3} -our_iterable = filled_dict.keys() -print(our_iterable) #=> range(1,10). This is an object that implements our Iterable interface +dolu_sozl = {"bir": 1, "iki": 2, "uc": 3} +temel_soyut = dolu_sozl.keys() +print(temel_soyut) #=> range(1,10). Bu obje temel soyutlandırma arayüzü ile oluşturuldu -# We can loop over it. -for i in our_iterable: - print(i) # Prints one, two, three +# Temel Soyutlandırılmış objeyi döngüye sokabiliriz. +for i in temel_soyut: + print(i) # Çıktısı: bir, iki, uc -# However we cannot address elements by index. -our_iterable[1] # Raises a TypeError +# Fakat, elementin anahtarına değerine. +temel_soyut[1] # TypeError hatası! -# An iterable is an object that knows how to create an iterator. -our_iterator = iter(our_iterable) +# 'iterable' bir objenin nasıl temel soyutlandırıldığıdır. +iterator = iter(temel_soyut) -# Our iterator is an object that can remember the state as we traverse through it. -# We get the next object by calling the __next__ function. -our_iterator.__next__() #=> "one" +# 'iterator' o obje üzerinde yaptığımız değişiklikleri hatırlayacaktır +# Bir sonraki objeyi almak için __next__ fonksiyonunu kullanabilirsiniz. +iterator.__next__() #=> "bir" -# It maintains state as we call __next__. -our_iterator.__next__() #=> "two" -our_iterator.__next__() #=> "three" +# Bir önceki __next__ fonksiyonumuzu hatırlayıp bir sonraki kullanımda bu sefer ondan bir sonraki objeyi döndürecektir +iterator.__next__() #=> "iki" +iterator.__next__() #=> "uc" -# After the iterator has returned all of its data, it gives you a StopIterator Exception -our_iterator.__next__() # Raises StopIteration +# Bütün nesneleri aldıktan sonra bir daha __next__ kullanımınızda, StopIterator hatası oluşturacaktır. +iterator.__next__() # StopIteration hatası -# You can grab all the elements of an iterator by calling list() on it. -list(filled_dict.keys()) #=> Returns ["one", "two", "three"] +# iterator'deki tüm nesneleri almak için list() kullanabilirsiniz. +list(dolu_sozl.keys()) #=> Returns ["bir", "iki", "uc"] #################################################### -- cgit v1.2.3 From 71d688379641a91f6247920962a005d9af635a70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eray=20Ayd=C4=B1n?= Date: Wed, 25 Mar 2015 21:26:00 +0200 Subject: Functions --- tr-tr/python3-tr.html.markdown | 100 ++++++++++++++++++++--------------------- 1 file changed, 48 insertions(+), 52 deletions(-) (limited to 'tr-tr') diff --git a/tr-tr/python3-tr.html.markdown b/tr-tr/python3-tr.html.markdown index b1806e7b..6babb7d0 100644 --- a/tr-tr/python3-tr.html.markdown +++ b/tr-tr/python3-tr.html.markdown @@ -393,93 +393,89 @@ list(dolu_sozl.keys()) #=> Returns ["bir", "iki", "uc"] #################################################### -## 4. Functions +## 4. Fonksiyonlar #################################################### -# Use "def" to create new functions -def add(x, y): - print("x is {} and y is {}".format(x, y)) - return x + y # Return values with a return statement +# "def" ile yeni fonksiyonlar oluşturabilirsiniz +def topla(x, y): + print("x = {} ve y = {}".format(x, y)) + return x + y # Değer döndürmek için 'return' kullanmalısınız -# Calling functions with parameters -add(5, 6) # => prints out "x is 5 and y is 6" and returns 11 +# Fonksiyonu parametleri ile çağırıyoruz +topla(5, 6) # => çıktı "x = 5 ve y = 6" ve değer olarak 11 döndürür -# Another way to call functions is with keyword arguments -add(y=6, x=5) # Keyword arguments can arrive in any order. +# Bir diğer fonksiyon çağırma yöntemi de anahtar değerleri ile belirtmek +topla(y=6, x=5) # Anahtar değeri belirttiğiniz için parametre sıralaması önemsiz. -# You can define functions that take a variable number of -# positional arguments -def varargs(*args): - return args +# Sınırsız sayıda argüman da alabilirsiniz +def argumanlar(*argumanlar): + return argumanlar -varargs(1, 2, 3) # => (1, 2, 3) +argumanlar(1, 2, 3) # => (1, 2, 3) -# You can define functions that take a variable number of -# keyword arguments, as well -def keyword_args(**kwargs): - return kwargs +# Parametrelerin anahtar değerlerini almak isterseniz +def anahtar_par(**anahtarlar): + return anahtar -# Let's call it to see what happens -keyword_args(big="foot", loch="ness") # => {"big": "foot", "loch": "ness"} +# Çalıştırdığımızda +anahtar_par(anah1="deg1", anah2="deg2") # => {"anah1": "deg1", "anah2": "deg2"} -# You can do both at once, if you like -def all_the_args(*args, **kwargs): - print(args) - print(kwargs) +# İsterseniz, bu ikisini birden kullanabilirsiniz +def tum_argumanlar(*argumanlar, **anahtarla): + print(argumanlar) + print(anahtarla) """ -all_the_args(1, 2, a=3, b=4) prints: +tum_argumanlar(1, 2, a=3, b=4) çıktı: (1, 2) {"a": 3, "b": 4} """ -# When calling functions, you can do the opposite of args/kwargs! -# Use * to expand tuples and use ** to expand kwargs. -args = (1, 2, 3, 4) -kwargs = {"a": 3, "b": 4} -all_the_args(*args) # equivalent to foo(1, 2, 3, 4) -all_the_args(**kwargs) # equivalent to foo(a=3, b=4) -all_the_args(*args, **kwargs) # equivalent to foo(1, 2, 3, 4, a=3, b=4) +# Fonksiyonu çağırırken de aynısını kullanabilirsiniz +argumanlar = (1, 2, 3, 4) +anahtarla = {"a": 3, "b": 4} +tum_argumanlar(*argumanlar) # = foo(1, 2, 3, 4) +tum_argumanlar(**anahtarla) # = foo(a=3, b=4) +tum_argumanlar(*argumanlar, **anahtarla) # = foo(1, 2, 3, 4, a=3, b=4) -# Function Scope +# Fonksiyonlarda kullanacağımız bir değişken oluşturalım x = 5 -def setX(num): - # Local var x not the same as global variable x - x = num # => 43 +def belirleX(sayi): + # Fonksiyon içerisindeki x ile global tanımladığımız x aynı değil + x = sayi # => 43 print (x) # => 43 -def setGlobalX(num): +def globalBelirleX(sayi): global x print (x) # => 5 - x = num # global var x is now set to 6 + x = sayi # global olan x değişkeni artık 6 print (x) # => 6 -setX(43) -setGlobalX(6) +belirleX(43) +globalBelirleX(6) -# Python has first class functions -def create_adder(x): - def adder(y): +# Sınıf fonksiyonları oluşturma +def toplama_olustur(x): + def topla(y): return x + y - return adder + return topla -add_10 = create_adder(10) -add_10(3) # => 13 +ekle_10 = toplama_olustur(10) +ekle_10(3) # => 13 -# There are also anonymous functions +# Bilinmeyen fonksiyon (lambda x: x > 2)(3) # => True # TODO - Fix for iterables -# There are built-in higher order functions -map(add_10, [1, 2, 3]) # => [11, 12, 13] +# Belirli sayıdan yükseğini alma fonksiyonu +map(ekle_10, [1, 2, 3]) # => [11, 12, 13] filter(lambda x: x > 5, [3, 4, 5, 6, 7]) # => [6, 7] -# We can use list comprehensions for nice maps and filters -# List comprehension stores the output as a list which can itself be a nested list -[add_10(i) for i in [1, 2, 3]] # => [11, 12, 13] +# Filtreleme işlemi için liste comprehensions da kullanabiliriz +[ekle_10(i) for i in [1, 2, 3]] # => [11, 12, 13] [x for x in [3, 4, 5, 6, 7] if x > 5] # => [6, 7] #################################################### -- cgit v1.2.3 From e34c67290a311c32a208793f44e5d0d51bf37bc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eray=20Ayd=C4=B1n?= Date: Wed, 25 Mar 2015 21:36:52 +0200 Subject: Classes --- tr-tr/python3-tr.html.markdown | 68 ++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 35 deletions(-) (limited to 'tr-tr') diff --git a/tr-tr/python3-tr.html.markdown b/tr-tr/python3-tr.html.markdown index 6babb7d0..ee858fb6 100644 --- a/tr-tr/python3-tr.html.markdown +++ b/tr-tr/python3-tr.html.markdown @@ -479,59 +479,57 @@ filter(lambda x: x > 5, [3, 4, 5, 6, 7]) # => [6, 7] [x for x in [3, 4, 5, 6, 7] if x > 5] # => [6, 7] #################################################### -## 5. Classes +## 5. Sınıflar #################################################### -# We subclass from object to get a class. -class Human(object): +# Sınıf oluşturmak için objeden alt sınıf oluşturacağız. +class Insan(obje): - # A class attribute. It is shared by all instances of this class - species = "H. sapiens" + # Sınıf değeri. Sınıfın tüm nesneleri tarafından kullanılabilir + tur = "H. sapiens" - # Basic initializer, this is called when this class is instantiated. - # Note that the double leading and trailing underscores denote objects - # or attributes that are used by python but that live in user-controlled - # namespaces. Methods(or objects or attributes) like: __init__, __str__, - # __repr__ etc. are called magic methods (or sometimes called dunder methods) - # You should not invent such names on your own. - def __init__(self, name): - # Assign the argument to the instance's name attribute - self.name = name + # Basit başlatıcı, Sınıf çağrıldığında tetiklenecektir. + # Dikkat edin, iki adet alt çizgi(_) bulunmakta. Bunlar + # python tarafından tanımlanan isimlerdir. + # Kendinize ait bir fonksiyon oluştururken __fonksiyon__ kullanmayınız! + def __init__(self, isim): + # Parametreyi sınıfın değerine atayalım + self.isim = isim - # An instance method. All methods take "self" as the first argument - def say(self, msg): - return "{name}: {message}".format(name=self.name, message=msg) + # Bir metot. Bütün metotlar ilk parametre olarak "self "alır. + def soyle(self, mesaj): + return "{isim}: {mesaj}".format(isim=self.name, mesaj=mesaj) - # A class method is shared among all instances - # They are called with the calling class as the first argument + # Bir sınıf metotu bütün nesnelere paylaştırılır + # İlk parametre olarak sınıf alırlar @classmethod - def get_species(cls): - return cls.species + def getir_tur(snf): + return snf.tur - # A static method is called without a class or instance reference + # Bir statik metot, sınıf ve nesnesiz çağrılır @staticmethod def grunt(): return "*grunt*" -# Instantiate a class -i = Human(name="Ian") -print(i.say("hi")) # prints out "Ian: hi" +# Sınıfı çağıralım +i = Insan(isim="Ahmet") +print(i.soyle("merhaba")) # çıktı "Ahmet: merhaba" -j = Human("Joel") -print(j.say("hello")) # prints out "Joel: hello" +j = Insan("Ali") +print(j.soyle("selam")) # çıktı "Ali: selam" -# Call our class method -i.get_species() # => "H. sapiens" +# Sınıf metodumuzu çağıraim +i.getir_tur() # => "H. sapiens" -# Change the shared attribute -Human.species = "H. neanderthalensis" -i.get_species() # => "H. neanderthalensis" -j.get_species() # => "H. neanderthalensis" +# Paylaşılan değeri değiştirelim +Insan.tur = "H. neanderthalensis" +i.getir_tur() # => "H. neanderthalensis" +j.getir_tur() # => "H. neanderthalensis" -# Call the static method -Human.grunt() # => "*grunt*" +# Statik metodumuzu çağıralım +Insan.grunt() # => "*grunt*" #################################################### -- cgit v1.2.3 From 4d74369df3a33f22442ce5938768500d55e9fa94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eray=20Ayd=C4=B1n?= Date: Thu, 26 Mar 2015 15:23:45 +0200 Subject: Modules --- tr-tr/python3-tr.html.markdown | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'tr-tr') diff --git a/tr-tr/python3-tr.html.markdown b/tr-tr/python3-tr.html.markdown index ee858fb6..83ce892d 100644 --- a/tr-tr/python3-tr.html.markdown +++ b/tr-tr/python3-tr.html.markdown @@ -533,32 +533,32 @@ Insan.grunt() # => "*grunt*" #################################################### -## 6. Modules +## 6. Moduller #################################################### -# You can import modules +# Modülleri içe aktarabilirsiniz import math print(math.sqrt(16)) # => 4 -# You can get specific functions from a module +# Modülden belirli bir fonksiyonları alabilirsiniz from math import ceil, floor print(ceil(3.7)) # => 4.0 print(floor(3.7)) # => 3.0 -# You can import all functions from a module. -# Warning: this is not recommended +# Modüldeki tüm fonksiyonları içe aktarabilirsiniz +# Dikkat: bunu yapmanızı önermem. from math import * -# You can shorten module names +# Modül isimlerini değiştirebilirsiniz. +# Not: Modül ismini kısaltmanız çok daha iyi olacaktır import math as m math.sqrt(16) == m.sqrt(16) # => True -# Python modules are just ordinary python files. You -# can write your own, and import them. The name of the -# module is the same as the name of the file. +# Python modulleri aslında birer python dosyalarıdır. +# İsterseniz siz de yazabilir ve içe aktarabilirsiniz Modulün +# ismi ile dosyanın ismi aynı olacaktır. -# You can find out which functions and attributes -# defines a module. +# Moduldeki fonksiyon ve değerleri öğrenebilirsiniz. import math dir(math) -- cgit v1.2.3 From fde928afa6ef076087acf6c2dbfde0b53ba46e99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eray=20Ayd=C4=B1n?= Date: Thu, 26 Mar 2015 15:36:05 +0200 Subject: Advanced --- tr-tr/python3-tr.html.markdown | 62 ++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 32 deletions(-) (limited to 'tr-tr') diff --git a/tr-tr/python3-tr.html.markdown b/tr-tr/python3-tr.html.markdown index 83ce892d..fcd57229 100644 --- a/tr-tr/python3-tr.html.markdown +++ b/tr-tr/python3-tr.html.markdown @@ -564,56 +564,54 @@ dir(math) #################################################### -## 7. Advanced +## 7. Gelişmiş #################################################### -# Generators help you make lazy code -def double_numbers(iterable): - for i in iterable: +# Oluşturucular uzun uzun kod yazmamanızı sağlayacak ve yardımcı olacaktır +def kare_sayilar(nesne): + for i in nesne: yield i + i -# A generator creates values on the fly. -# Instead of generating and returning all values at once it creates one in each -# iteration. This means values bigger than 15 wont be processed in -# double_numbers. -# Note range is a generator too. Creating a list 1-900000000 would take lot of -# time to be made -# We use a trailing underscore in variable names when we want to use a name that -# would normally collide with a python keyword +# Bir oluşturucu(generator) değerleri anında oluşturur. +# Bir seferde tüm değerleri oluşturup göndermek yerine teker teker her oluşumdan +# sonra geri döndürür. Bu demektir ki, kare_sayilar fonksiyonumuzda 15'ten büyük +# değerler işlenmeyecektir. +# Not: range() da bir oluşturucu(generator)dur. 1-900000000 arası bir liste yapmaya çalıştığınızda +# çok fazla vakit alacaktır. +# Python tarafından belirlenen anahtar kelimelerden kaçınmak için basitçe alt çizgi(_) kullanılabilir. range_ = range(1, 900000000) -# will double all numbers until a result >=30 found -for i in double_numbers(range_): +# kare_sayilar'dan dönen değer 30'a ulaştığında durduralım +for i in kare_sayilar(range_): print(i) if i >= 30: break -# Decorators -# in this example beg wraps say -# Beg will call say. If say_please is True then it will change the returned -# message +# Dekoratörler +# Bu örnekte, +# Eğer lutfen_soyle True ise dönen değer değişecektir. from functools import wraps -def beg(target_function): - @wraps(target_function) - def wrapper(*args, **kwargs): - msg, say_please = target_function(*args, **kwargs) - if say_please: - return "{} {}".format(msg, "Please! I am poor :(") - return msg +def yalvar(hedef_fonksiyon): + @wraps(hedef_fonksiyon) + def metot(*args, **kwargs): + msj, lutfen_soyle = hedef_fonksiyon(*args, **kwargs) + if lutfen_soyle: + return "{} {}".format(msj, "Lütfen! Artık dayanamıyorum :(") + return msj - return wrapper + return metot -@beg -def say(say_please=False): - msg = "Can you buy me a beer?" - return msg, say_please +@yalvar +def soyle(lutfen_soyle=False): + msj = "Bana soda alır mısın?" + return msj, lutfen_soyle -print(say()) # Can you buy me a beer? -print(say(say_please=True)) # Can you buy me a beer? Please! I am poor :( +print(soyle()) # Bana soda alır mısın? +print(soyle(lutfen_soyle=True)) # Ban soda alır mısın? Lutfen! Artık dayanamıyorum :( ``` ## Ready For More? -- cgit v1.2.3 From c26eb3384b7c1201d903acfdee67b1709696c249 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eray=20Ayd=C4=B1n?= Date: Thu, 26 Mar 2015 15:36:45 +0200 Subject: Ready To More? --- tr-tr/python3-tr.html.markdown | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tr-tr') diff --git a/tr-tr/python3-tr.html.markdown b/tr-tr/python3-tr.html.markdown index fcd57229..2477c5da 100644 --- a/tr-tr/python3-tr.html.markdown +++ b/tr-tr/python3-tr.html.markdown @@ -614,9 +614,9 @@ print(soyle()) # Bana soda alır mısın? print(soyle(lutfen_soyle=True)) # Ban soda alır mısın? Lutfen! Artık dayanamıyorum :( ``` -## Ready For More? +## Daha Fazlasına Hazır Mısınız? -### Free Online +### Ücretsiz Online * [Learn Python The Hard Way](http://learnpythonthehardway.org/book/) * [Dive Into Python](http://www.diveintopython.net/) @@ -627,7 +627,7 @@ print(soyle(lutfen_soyle=True)) # Ban soda alır mısın? Lutfen! Artık dayana * [A Crash Course in Python for Scientists](http://nbviewer.ipython.org/5920182) * [Python Course](http://www.python-course.eu/index.php) -### Dead Tree +### Kitaplar * [Programming Python](http://www.amazon.com/gp/product/0596158106/ref=as_li_qf_sp_asin_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=0596158106&linkCode=as2&tag=homebits04-20) * [Dive Into Python](http://www.amazon.com/gp/product/1441413022/ref=as_li_tf_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1441413022&linkCode=as2&tag=homebits04-20) -- cgit v1.2.3 From 212ba8301419923cffb82fa4d4ef7c91832b6096 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eray=20Ayd=C4=B1n?= Date: Mon, 30 Mar 2015 21:26:26 +0000 Subject: Markdown tr-tr language --- tr-tr/markdown-tr.html.markdown | 251 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 251 insertions(+) create mode 100644 tr-tr/markdown-tr.html.markdown (limited to 'tr-tr') diff --git a/tr-tr/markdown-tr.html.markdown b/tr-tr/markdown-tr.html.markdown new file mode 100644 index 00000000..bac8f6fc --- /dev/null +++ b/tr-tr/markdown-tr.html.markdown @@ -0,0 +1,251 @@ +--- +language: markdown +contributors: + - ["Dan Turkel", "http://danturkel.com/"] +translators: + - ["Eray AYDIN", "http://erayaydin.me/"] +lang: tr-tr +filename: markdown-tr.md +--- + +Markdown, 2004 yılında John Gruber tarafından oluşturuldu. Asıl amacı kolay okuma ve yazmayı sağlamakla beraber kolayca HTML (artık bir çok diğer formatlara) dönüşüm sağlamaktır. + + +```markdown + + + + + + +# Bu bir

+## Bu bir

+### Bu bir

+#### Bu bir

+##### Bu bir

+###### Bu bir
+ + +Bu bir h1 +========= + +Bu bir h2 +--------- + + + +*Bu yazı italik.* +_Bu yazı da italik._ + +**Bu yazı kalın.** +__Bu yazı da kalın.__ + +***Bu yazı hem kalın hem italik.*** +**_Bu da öyle!_** +*__Hatta bu bile!__* + + +~~Bu yazı üstü çizili olarak gözükecek.~~ + + + +Bu bir paragraf. Paragrafın içeriğine devam ediyorum, eğlenceli değil mi? + +Şimdi 2. paragrafıma geçtim. +Hala 2. paragraftayım, çünkü boş bir satır bırakmadım. + +Bu da 3. paragrafım! + + + +Bu yazının sonunda 2 boşluk var (bu satırı seçerek kontrol edebilirsiniz). + +Bir üst satırda
etiketi var! + + + +> Bu bir blok etiketi. Satırlara ayırmak için +> her satırın başında `>` karakter yerleştirmeli veya tek satırda bütün içeriği yazabilirsiniz. +> Satır `>` karakteri ile başladığı sürece sorun yok. + +> Ayrıca alt alta da blok elementi açabilirsiniz +>> iç içe yani +> düzgün değil mi ? + + + + +* Nesne +* Nesne +* Bir başka nesne + +veya + ++ Nesne ++ Nesne ++ Bir başka nesne + +veya + +- Nesne +- Nesne +- Son bir nesne + + + +1. İlk nesne +2. İkinci nesne +3. Üçüncü nesne + + + +1. İlk nesne +1. İkinci nesne +1. Üçüncü nesne + + + + + +1. İlk nesne +2. İkinci nesne +3. Üçüncü nesne + * Alt nesne + * Alt nesne +4. Dördüncü nesne + + +Kutunun içerisinde `x` yoksa eğer seçim kutusu boş olacaktır. +- [ ] Yapılacak ilk görev. +- [ ] Yapılması gereken bir başka görev +Aşağıdaki seçim kutusu ise içi dolu olacaktır. +- [x] Bu görev başarıyla yapıldı + + + + + Bu bir kod + öyle mi? + + + + my_array.each do |item| + puts item + end + + + +Ahmet `go_to()` fonksiyonun ne yaptığını bilmiyor! + + + +\`\`\`ruby +def foobar + puts "Hello world!" +end +\`\`\` + + + + + + +*** +--- +- - - +**************** + + + + +[Bana tıkla!](http://test.com) + + + +[Bana tıkla!](http://test.com "Test.com'a gider") + + +[Müzik dinle](/muzik/). + + + +[Bu linke tıklayarak][link1] daha detaylı bilgi alabilirsiniz! +[Ayrıca bu linki de inceleyin][foobar] tabi istiyorsanız. + +[link1]: http://test.com/ "harika!" +[foobar]: http://foobar.biz/ "okey!" + + + + + +[Bu][] bir link. +[bu]: http://bubirlink.com + + + + + +![Bu alt etiketine gelecek içerik](http://imgur.com/resmim.jpg "Bu da isteğe bağlı olan bir başlık") + + +![Bu alt etiketi.][resmim] + +[resmim]: bagil/linkler/de/calisiyor.jpg "Başlık isterseniz buraya girebilirsiniz" + + + + + ile +[http://testwebsite.com/](http://testwebsite.com) aynı şeyler + + + + + + + +Bu yazının *yıldızlar arasında gözükmesini* istiyorum fakat italik olmamasını istiyorum, +bunun için, şu şekilde: \*bu yazı italik değil, yıldızlar arasında\*. + + + + +| Sütun1 | Sütun 2 | Sütün 3 | +| :----------- | :------: | ------------: | +| Sola dayalı | Ortalı | Sağa dayalı | +| test | test | test | + + + +Sütun 1 | Sütun 2 | Sütun 3 +:-- | :-: | --: +Çok çirkin göözüküyor | değil | mi? + + + +``` + +Daha detaylı bilgi için, John Gruber'in resmi söz dizimi yazısını [buradan](http://daringfireball.net/projects/markdown/syntax) veya Adam Pritchard'ın mükemmel hatırlatma kağıdını [buradan](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet) inceleyebilirsiniz. -- cgit v1.2.3