Applied Python Training for Beginners
Introduction
Python has quickly become one of the most popular programming languages in the world, and for very good reasons.
With its clean syntax, versatility, and ever-growing library ecosystem, it's a great option for beginners and professionals alike.
Whether you're delving into fields like web development, data analytics, automation, or artificial intelligence, Python offers the tools and community support to get you started quickly and effectively.
This beginner-friendly tutorial is designed to help you take your first steps into Python programming.
We'll take you step by step through the basics, from installing Python and writing your first lines of code to understanding variables, data types, conditions, loops, and functions.
No prior programming experience is required, just curiosity and a willingness to learn.
Why Should You Learn Python Programming?
- Simple and understandable: Python programming language is very simple, elegant and has a structure similar to English. It is very easy to learn and a great choice to start your IT career.
- Open source: Python is open source, which allows you to extend it and do creative projects on it.
- Huge community support: Python has a very large support community. There are over a million questions in the Python category on Stack Overflow.
- Free modules and packages: There are tons of free modules and packages that can help you in every area of development.
- Machine Learning and Artificial Intelligence: Most Machine Learning, Data Science, Graphs and Artificial Intelligence APIs are built on Python. So, if you want to work with these sharp technologies, Python is a great choice.
- Broad use: Python is used by almost every major company worldwide. If you know Python, your chances of finding a job are much higher.
- Unlimited areas of use: Python programming has no limitations. It can be used in Web applications, game development, cryptography, blockchain, scientific calculations, graphics and many other areas.
Python Fundamentals
Here are some basic commands you can start once Python is installed on your system:
As with any language, printing "Hello World" is the first step. This is the simplest way to print a message to the console.
print("Merhaba Dünya")
In Python, variables and data types are the basic building blocks of manipulating data. Here are some basic data types:
isim = "Eray" #Stringer
yas = 24 #Integer
boy = 1.8 #Float
ogrenci_mi = False #Boolean
In Python, comments are used to explain and help document your code. Comments are ignored by Python and do not affect the execution of the code.
# Bu bir tek satırlık yorumdur
"""
Bu çok satırlı bir yorumdur.
Kodunuzu açıklamak için birden fazla satırda yorum yazabilirsiniz.
"""
In Python, the input() function is used to get input, and the print() function is used to show output.
isim = input("İsminizi Giriniz: ")
print("Merhaba,", isim)
Control Flow
Conditionals
Condition statements allow us to perform different actions based on a certain condition. These operations are performed with the keywords if, elif and else.
yas = 20
if yas > 18:
print("Yetişkin")
elif yas == 18:
print("Yeni yetişkin oldu")
else:
print("Reşit değil")
Loops
There are two types of loops in Python:
The 1-for cycle allows for a certain number of repetitions. This loop is often used with functions such as range().
The 2-while loop runs as long as a certain condition is true. The loop continues as long as the condition is True.
# For Döngüsü
for i in range(5):
print(i)
# While Döngüsü
count = 0
while count < 5:
print(count)
count += 1
Functions
Functions are reusable blocks of code. The def keyword is used to define functions in Python.
def selam(isim):
return f"Merhaba, {isim}!"
mesaj = selam("Alice")
print(mesaj)
Default and Keyword Arguments
These arguments make function calls more flexible (for example, greet(name="Guest")).
def selamla(isim="Misafir"):
print("Merhaba,", isim)
selamla() # Varsayılan değeri kullanarak "Misafir" olarak yazdırır
selamla("Bob") # "Bob" ismini kullanarak selam verir
Lambda Functions
In Python, lambda functions are small, anonymous functions defined by the keyword lambda.
They are generally used for short and temporary (disposable) functions and are not reused elsewhere.
A lambda function can take any number of arguments but can only contain a single expression.
carp = lambda x: x * 2
print(carp(5))
Data Structures
Data structures are containers in Python used to store and organize data in an orderly and efficient way.
These structures enable developers to access and perform meaningful operations on data in an orderly manner.
Python provides multiple built-in data structures suitable for a variety of uses: lists, tuples, dictionaries, and sets.
Lists
Lists are ordered and mutable collections of items. They can store items of different data types.
You can use built-in methods to add, delete or change operations on list items.
Lists are often preferred when you need to work with data sortings.
meyveler = ["Elma", "Armut", "Muz"]
print(meyveler)
Tuples
Tuples are ordered and immutable collections. They can also store items of different data types.
Once created, the contents of a tuple cannot be changed. This feature makes tuples useful for storing immutable data or ensuring data integrity.
renkler = ("Kırmızı", "Yeşil", "Mavi")
print(renkler)
Dictionaries
Dictionaries are unordered collections of key-value pairs. This structure provides fast access to and retrieval of data.
Each key must be unique, but values can be any data type. Dictionaries are ideal for storing related data, for example the properties of an object.
kisi = {"ad": "Ahmet", "yas": 25, "sehir": "İstanbul"}
print(kisi)
Sets
Sets are collections of unordered and unique elements. Clusters are often used to perform membership testing and remove duplicate elements. Additionally, sets support mathematical operations, such as union, intersection, and difference.
Example:
essiz_sayı = {1, 2, 3, 4}
print(essiz_sayı)
File Operations
File operations in Python allow you to read data from and write data to files on your system.
This feature is very useful for operations such as logging data, logging events or reading configuration files.
Python makes file operations simple and efficient by using the built-in function open() and context managers such as with for secure file access.
dosya = open("ornek.txt", "w") # Dosya yazma (write) modunda açılır
dosya.write("Merhaba, Python!") # Dosyaya yazı yazılır
dosya.close() # Dosya kapatılır
Error Management
Error handling in Python is a process done using try, except, and finally blocks. These structures help catch and manage errors properly.
Error handling helps prevent programs from crashing unexpectedly and allows you to respond appropriately to different types of errors.
This is a fundamental part of writing robust and reliable code.
try:
result = 10 / 0
except ZeroDivisionError:
print("Sıfıra bölme yapamazsınız!")
finally:
print("Bu blok her zaman çalışır.")
Modules and Packages
Importing Modules
Modules are pre-written pieces of code that you can reuse in your program. Python comes with standard libraries such as math, datetime, and os. These modules provide useful functions for a variety of tasks.
You can also install third-party modules or write your own modules.
import math # math modülünü içe aktarır
print(math.sqrt(16)) # 16'nın karekökünü alır, çıktı: 4.0
Creating Your Own Module
Creating your own module in Python is possible by saving functions in a .py file and importing this file in other scripts.
This increases code reusability and organization, especially in large projects.
Custom modules work like built-in or third-party modules.
Creating Your Own Module
- Create a module file:
- For example, create a file named
mymodule.py.
- For example, create a file named
def selamla(isim):
print(f"Merhaba, {isim}!")
def toplama(a, b):
return a + b
import mymodule # mymodule.py'yi içe aktarır
# mymodule içindeki fonksiyonları kullanabilirsiniz.
mymodule.selamla("Ahmet") # "Merhaba, Ahmet!" yazdırır
sonuc = mymodule.toplama(3, 5)
print(sonuc) # Çıktı: 8
Popular Python Libraries
Python's ecosystem is full of rich libraries that simplify complex tasks and extend the capabilities of the language.
These libraries are widely used in fields such as data science, machine learning, web development and automation.
Below you can find some basic Python libraries that every beginner should familiarize themselves with.
####NumPy
NumPy (Numerical Python) is a library for working with arrays and performing numerical calculations.
Provides support for large, multidimensional arrays and a wide range of mathematical operations. NumPy is fundamental to scientific computing and is widely used in fields such as data analysis and machine learning.
Key Features
- Array: NumPy provides a much more efficient array data structure than Python's built-in list type. Arrays make working with large data sets much faster.
- Mathematical Operations: NumPy offers a wide range of functions for mathematical functions (addition, subtraction, multiplication, division, etc.) and more complex operations (matrix multiplication, linear algebra, Fourier transform, etc.).
- Multidimensional Arrays: NumPy allows you to work with multidimensional arrays (matrices).
import numpy as np
dizi = np.array([1, 2, 3])
print(dizi * 2) # Çıktı: [2 4 6]
Pandas
Pandas is a powerful data manipulation and analysis library built on NumPy.
Pandas offers two main data structures that make it easy to load, analyze, and visualize data: Series and DataFrame.
It is an indispensable tool for data scientists and analysts, especially when working with tabular data.
import pandas as pd
# DataFrame oluşturma
data = {"name": ["Alice", "Bob"], "age": [25, 30]}
df = pd.DataFrame(data)
# DataFrame'i yazdırma
print(df)
Matplotlib
Matplotlib is a plotting library that allows you to create static, animated and interactive visualizations in Python.
It is especially used to create visuals such as line charts, bar charts, histograms and scatter charts.
It is generally preferred to make data visualizations together with Pandas and NumPy.
import matplotlib.pyplot as plt
# Çizgi grafiği oluşturma
plt.plot([1, 2, 3], [4, 5, 6])
# Grafiği gösterme
plt.show()
Result
This Python guide provides a strong foundation for exploring the language. However, to truly learn Python and gain confidence in using it, constant practice is crucial.
Python is a beginner-friendly, versatile and powerful programming language. It will help you in many fields such as data science, machine learning, web development and automation.
In this tutorial, we have provided a comprehensive roadmap of the basics of Python. These include syntax, data structures, control flow, functions, file and error management and basic libraries.
By learning these basic concepts, you equip yourself with the tools necessary to solve real-world problems and move into more specific areas.
Keep doing small projects, exploring more libraries, and contributing to open source projects to improve your skills.
This is the best way to increase your skills and confidence as a Python developer. Deepen your understanding by continuing to practice and develop projects.

