Skip to content
Open
60 changes: 60 additions & 0 deletions Python_function_exercises.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#1- Verilen bir kelimeyi belirtilen kez ekrana yazdiran python fonksiyonu yazınız.
#1. Print a Word Multiple Times
def print_word(word, count):
for i in range(count):
print(word)

print_word("Hello", 3)


#2- Verilen 2 sayı arasındaki tüm asal sayıları bulan python fonksiyonunu yazınız.
#2. Prime Numbers Between Two Numbers
# A prime number is only divisible by 1 and itself.Examples: 2, 3, 5, 7, 11...
def is_prime(num):
if num < 2:
return False
for i in range(2, int(num**0.5)+1): #loop through all numbers from 2 up to square root of num. +1 because range is exclusive at the end,it stops before the last number.
if num %i == 0: #check if num is divisible by i
return False
return True

def find_primes(start, end):
for num in range(start, end + 1):
if is_prime(num):
print(num)
find_primes(10, 20)

#3- Saati saniyeye çeviren bir fonksiyon yazınız.
#3. Convert Time to Seconds

def convert_to_seconds(hours, minutes, seconds):
total_seconds = hours * 3600 + minutes *60 + seconds
return total_seconds
print(convert_to_seconds(1, 30, 15))


#4- Matematik, Fizik ve Kimya derslerinin Vize ve Final ortalamalarina gore
# (Vize nin %40 i , Finalin %60 i) ogrencinin derslerden hangi not ile gectigini veya kaldigini gosteren bir program yaziniz.
#4. Calculate Student Grades (Vize 40%, Final 60%)

def calculate_grade(vize, final):
average = vize * 0.4 + final * 0.6

if average >= 85:
grade = "AA"
elif average >= 70:
grade = "BB"
elif average >= 55:
grade = "CC"
elif average >= 45:
grade = "DD"
else:
grade = "FF"
if average >= 45:
status = "Passed"
else:
status = "Failed"

print(f"Average: {average:.2f} - Grade: {grade} - Status: {status}") #:.2f floating point (decimal) numbers

calculate_grade(60, 70)
85 changes: 85 additions & 0 deletions Question1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#Project Description: In this assignment, you will create a task manager application using the Python programming language.
#This application will allow users to add, complete, delete, and list their tasks.
#Requirements:
#1-Tasks will be stored in a Python list and each task will be represented as a dictionary. Each task must have the following properties:
#Sequence Number (Automatically assigned). Task Name. Status (Completed, Pending, or Deleted)
#2- Operations that the user can perform:
#Add a new task. Complete a task. Delete a task. List completed tasks. List all tasks with their status. Exit
#3- 4- 5- 6

def greet_user():
print("Welcome to Task Manager")
greet_user() # Call the function

tasks = [] #task list will store all tasks
next_sequence = 1 #this will increase with each new task

# Function to add a new task
def add_task(name): # name is a parameter
global next_sequence
task = {
"Sequence": next_sequence, #automatically assigned number
"Name": name, #task name entered by user
"Status": "Pending" #default status
}
tasks.append(task)
print(f"Task '{name}' added with number {next_sequence}.")
next_sequence += 1 #increase the task number for next task


# Function to complete a task
def complete_task(task_number):
for task in tasks:
if task["Sequence"] == task_number and task["Status"] == "Pending": #find the task by its number and make sure it's not already done
task["Status"] = "Completed" #change status
print(f"Task {task_number} marked as Completed.")
return
print("Task not found or cannot be completed.") #if not found

# Function to delete a task
def delete_task(task_number):
for task in tasks:
if task["Sequence"] == task_number and task["Status"] != "Deleted":
task["Status"] = "Deleted"
print(f"Task {task_number} marked as Deleted.")
return
print("Task not found or already deleted.")

# Function to list all tasks
def list_tasks():
print("\n Task List")
for task in tasks:
print(f"{task['Sequence']}: {task['Name']} - [{task['Status']}]")
print() # Empty line for spacing. extra space after list

# Main function to show the menu and take user input
def main():
while True:
print("Task Manager Menu")
print("1. Add Task")
print("2. Complete Task")
print("3. Delete Task")
print("4. List All Tasks")
print("5. Exit")

choice = input("Choose an option (1-5): ")

if choice == "1":
name = input("Enter the task name: ")
add_task(name)
elif choice == "2":
number = int(input("Enter the task number to complete: "))
complete_task(number)
elif choice == "3":
number = int(input("Enter the task number to delete: "))
delete_task(number)
elif choice == "4":
list_tasks()
elif choice == "5":
print("Exiting Task Manager. Goodbye!")
break
else:
print("Invalid choice. Please try again.")

# Run the program
main()
125 changes: 125 additions & 0 deletions ic_week_3_1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# Görev Yönetim Sistemi
#1- Yeni bir görev ekle
#2- Bir görevi tamamla
#3- Bir görevi sil
#4- Tamamlanan görevleri listele
#5- Tüm görevleri durumlarıyla birlikte listele
#6- Çıkış

gorev_listesi = []
def add_gorev(ID, gorev_tanimi, gorev_durumu):
"""
Yeni bir görev ekler.
"""
gorev_bilgileri = {
"ID": ID,
"Görev Tanınım": gorev_tanimi,
"Görev Durumu": gorev_durumu
}
gorev_listesi.append(gorev_bilgileri)
return gorev_listesi

def menu():
"""
Kullanıcıdan seçim alır.
"""
print("***Görev Yönetim Sistemi***\n")
print("1- Yeni bir görev ekle")
print("2- Bir görevi durumunu değiştir")
print("3- Bir görevi sil")
print("4- Tamamlanan görevleri listele")
print("5- Tüm görevleri durumlarıyla birlikte listele")
print("6- Çıkış\n")

secim = input("Seçiminizi yapın (1-6): ")
if secim not in ["1", "2", "3", "4", "5", "6"]:
print("Geçersiz seçim. Lütfen tekrar deneyin.")
return menu()
return secim

def uygun_id_al():
mevctut_idler = sorted([int(gorev["ID"]) for gorev in gorev_listesi])
for ID in range(1, len(mevctut_idler) + 2):
if ID not in mevctut_idler:
return str(ID)

"""
Kullanıcıdan uygun bir ID alır.
"""

#1- Yeni bir görev ekle
while True:
menu_secim = menu()
if menu_secim == "1":
#ID = input("Görev ID'sini girin: ")
ID = uygun_id_al()
if any(gorev["ID"] == ID for gorev in gorev_listesi):
print("Bu ID'ye sahip bir görev zaten var. Lütfen başka bir ID girin.")
continue
# Görev tanımını ve durumunu al
gorev_tanimi = input("Görev tanımını girin: ")
gorev_durumu = input("Görev durumunu girin (Tamamlandı/Bekliyor/Silindi): ")
if gorev_durumu not in ["Tamamlandı", "Bekliyor", "Silindi"]:
print("Geçersiz görev durumu. Lütfen tekrar deneyin.")
continue
# Görev ekleme fonksiyonunu çağır
add_gorev(ID, gorev_tanimi, gorev_durumu)
print("Görev başarıyla eklendi.")
elif menu_secim == "2":
ID = input("Durumu değiştirmek istediğiniz görev ID'sini girin: ")
if any(gorev["ID"] == ID for gorev in gorev_listesi):
#print("Bu ID bulundu.")
# Görev durumunu güncelle
gorev_durumu = input("Görev durumunu girin (Tamamlandı/Bekliyor/Silindi): ")
if gorev_durumu not in ["Tamamlandı", "Bekliyor", "Silindi"]:
print("Geçersiz görev durumu. Lütfen tekrar deneyin.")
continue
else:
for gorev in gorev_listesi:
if gorev["ID"] == ID:
gorev["Görev Durumu"] = gorev_durumu
print("Görev durumu başarıyla güncellendi.")
else:
print("Bu ID'ye sahip bir görev bulunamadı.")
continue

elif menu_secim == "3":
ID = input("Silmek istediğiniz görev ID'sini girin: ")
if any(gorev["ID"] == ID for gorev in gorev_listesi):
#print("Bu ID bulundu.")
# Görev silme işlemi
for gorev in gorev_listesi:
if gorev["ID"] == ID:
gorev_listesi.remove(gorev)
print("Görev başarıyla silindi.")
else:
print("Bu ID'ye sahip bir görev bulunamadı.")
continue

elif menu_secim == "4":
# Tamamlanan görevleri listele
tamamlanan_gorevler = [gorev for gorev in gorev_listesi if gorev["Görev Durumu"] == "Tamamlandı"]
if tamamlanan_gorevler:
print("Tamamlanan Görevler:")
for gorev in tamamlanan_gorevler:
print(f"ID: {gorev['ID']}, Görev Tanımı: {gorev['Görev Tanınım']}, Görev Durumu: {gorev['Görev Durumu']}")
else:
print("Tamamlanan görev bulunamadı.")

elif menu_secim == "5":
# Tüm görevleri listele
if gorev_listesi:
print("Tüm Görevler:\n")
for gorev in gorev_listesi:
print(f"ID: {gorev['ID']}, Görev Tanımı: {gorev['Görev Tanınım']}, Görev Durumu: {gorev['Görev Durumu']}\n")
else:
print("Görev listesi boş.")

elif menu_secim == "6":

print("Çıkış yapılıyor... İyi günler!")
break
else:
print("Bu özellik henüz uygulanmadı.")


60 changes: 60 additions & 0 deletions ic_week_3_Fnk-4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#1- Verilen bir kelimeyi belirtilen kez ekrana yazdiran python fonksiyonu yazınız.

def kelimeyaz(kelime, sayi):
for i in range(sayi):
print(kelime)


kelime = input("Bir kelime giriniz")
sayi = int(input("Kaç kere yazdırmak istersiniz?"))
kelimeyaz(kelime, sayi)


#2- Verilen 2 sayı arasındaki tüm asal sayıları bulan python fonksiyonunu yazınız.

def asalsayilar(sayi1, sayi2):
asal_sayilar = []
for sayi in range(sayi1, sayi2 + 1):
if sayi > 1:
for i in range(2, int(sayi ** 0.5) + 1):
if sayi % i == 0:
break
else:
asal_sayilar.append(sayi)
return asal_sayilar

print(f"1 ile 10 arası asalsayılar: {asalsayilar(1, 10)}")


#3- Saati saniyeye çeviren bir fonksiyon yazınız.

def saniye():
saat=int(input("Saat: "))
dakika=int(input("Dakika: "))
saniye=int(input("Saniye: "))
toplam_saniye=(saat*3600)+(dakika*60)+saniye
print(f"Toplam saniye: {saat} Saat {dakika} dakika {saniye} saniye toplamı {toplam_saniye} saniyedir")

saniye()


#4- Matematik, Fizik ve Kimya derslerinin Vize ve Final ortalamalarina gore (Vize nin %40 i , Finalin %60 i) ogrencinin derslerden hangi not ile gectigini veya kaldigini gosteren bir program yaziniz.

def vize_final(ders, vnotu, fnotu):
ders = input("Ders adı: ")
vnotu = int(input("Vize notu: "))
fnotu = int(input("Final notu: "))
ortalama = (vnotu * 0.4) + (fnotu * 0.6)
if ortalama >= 0 and ortalama <= 44:
print("FF - Kaldınız")
elif ortalama >= 45 and ortalama <= 54:
print("DD - Geçtiniz")
elif ortalama >= 55 and ortalama <= 69:
print("CC - Geçtiniz")
elif ortalama >= 70 and ortalama <= 84:
print("BB - Geçtiniz")
elif ortalama >= 85 and ortalama <= 100:
print("AA - Geçtiniz")


vize_final("", 0, 0)
29 changes: 29 additions & 0 deletions ic_week_3_hr_1-2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
def sayi_rakam_bolen(n):
"""
Bu fonksiyon, verilen bir sayının rakamlarının verilen sayıyının tam bölemleri sayısını verir.

"""
adet = 0
for i in str(n):
if i != '0' and n % int(i) == 0:
adet += 1
return adet

# count = 0
# for digit in str(n):
# if digit != '0':
# if n % int(digit) == 0:
# count += 1
#return count

print(sayi_rakam_bolen(1012))


def naam(s):
words = s.split(" ")
capitalized_words = [w[0].upper() + w[1:] if w else "" for w in words]
return " ".join(capitalized_words)

print(naam("ahmet 12mehmet ali"))


Loading