From 6be4a9d65ea41ab608852d1464a898500aad5fdd Mon Sep 17 00:00:00 2001 From: NeslihanUTUK <120681285+NeslihanUTUK@users.noreply.github.com> Date: Fri, 27 Dec 2024 00:11:38 +0100 Subject: [PATCH 1/2] new --- nesli_week_1/homework.py | 72 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 nesli_week_1/homework.py diff --git a/nesli_week_1/homework.py b/nesli_week_1/homework.py new file mode 100644 index 0000000..324e5b7 --- /dev/null +++ b/nesli_week_1/homework.py @@ -0,0 +1,72 @@ +#question 2 +# Take a number input from the user and write a Python program that prints even numbers up to this number on the screen. +# Do this first with 'for' and then with 'while' loops. + +#Kullanıcıdan bir sayı girdisi alın ve bu sayıya kadar olan çift sayıları ekrana yazdıran bir Python programı yazın. +# Bunu önce 'for' sonra 'while' döngüleriyle yapın. + + +""" +n = int(input("bir sayi girin: ")) +for i in range(0, n+1): + if i%2 == 0: + print(i) +""" + +"""" + +n = int(input("bir sayi giriniz: ")) +i = 0 +while i <= n: + if i %2 == 0: + print(i) + i = i+1 + +""" + +# Question 6: +# Write a Python code that receives a number from the user and checks whether this number is prime. +## Kullanıcıdan bir sayı alan ve bu sayının asal olup olmadığını kontrol eden bir Python kodu yazın. +""" +sayi = int(input("Bir sayi girin: ")) + +if sayi < 2: + print(f"{sayi} bir asal sayi degildir.") +else: + for i in range(2, sayi): + if sayi % i == 0: + print(f"{sayi} asal sayi degildir") + break + else: + print(f"{sayi} bir asal sayidir. ") + +""" + + +#Question 10: Write the code that calculates the person's weight index and returns the result as underweight, +#overweight or overweight according to the index value. (You can look on the internet for the weight index calculation) +# To do this, ask the user for their weight and height measurements. weight index If it is below 25, it is weak, +# Between 25-30 is normal, If you are over 30-40, you are overweight. If you are over 40, you are overweight. + + + +"""" #Soru 10: Kişinin kilo endeksini hesaplayan ve sonucu düşük kilolu olarak döndüren kodu yazın, +Endeks değerine göre aşırı kilolu veya fazla kilolu. (Ağırlık endeksi hesaplaması için internete bakabilirsiniz) +Bunu yapmak için kullanıcıdan kilo ve boy ölçümlerini isteyin. kilo endeksi 25'in altındaysa zayıf, 25-30 arası normal, +30-40'ın üzerindeyse kilolusunuz. 40'ın üzerindeyseniz fazla kilolusunuz. +""" +boy = float(input("boyunuzu giriniz: ")) +kilo = float(input("kilonuzu girniz: ")) +vucut_kitle_indeksi = float(kilo / boy ** 2) +print("vucut kitle indeksiniz: ", vucut_kitle_indeksi) + +if (vucut_kitle_indeksi <= 30): + if (vucut_kitle_indeksi < 25): + print("zayifsiniz") + else: + print("normal kilodasiniz.") +elif (vucut_kitle_indeksi >= 40): + print ("asiri kilolusunuz") +else: + print ("kilolusunuz") + \ No newline at end of file From c525463b9f9134e7a45355007241d575f088c9e5 Mon Sep 17 00:00:00 2001 From: NeslihanUTUK <120681285+NeslihanUTUK@users.noreply.github.com> Date: Fri, 27 Dec 2024 20:41:01 +0100 Subject: [PATCH 2/2] homework --- nesli_week_1/hackerrank.py | 60 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 nesli_week_1/hackerrank.py diff --git a/nesli_week_1/hackerrank.py b/nesli_week_1/hackerrank.py new file mode 100644 index 0000000..61a9493 --- /dev/null +++ b/nesli_week_1/hackerrank.py @@ -0,0 +1,60 @@ +# 1- https://www.hackerrank.com/challenges/python-arithmetic-operators/problem + +a = int(input()) +b = int(input()) + +print(a + b) +print(a - b) +print(a * b) + +# 2- https://www.hackerrank.com/challenges/find-second-maximum-number-in-a-list/problem +n = int(input()) +arr = list(map(int, input().split())) +arr = list(set(arr)) +arr.sort() +print(arr[-2]) + +# 3- https://www.hackerrank.com/challenges/python-print/problem + +n = int(input().strip()) +for i in range(1, n + 1): + print(i, end='') + +# 4- https://www.hackerrank.com/challenges/finding-the-percentage/problem +n = int(input()) +student_marks = {} +for _ in range(n): + name, *line = input().split() + scores = list(map(float, line)) + student_marks[name] = scores +query_name = input() +scores = student_marks[query_name] +average = sum(scores) / len(scores) +print(f"{average:.2f}") #virgulden sonra ii basamak icin + +#n sayisi kadar for dongusu calisir +#ilk girdileri name yaparken digerleri line oldu. + +#Girdileri hackerrank otomatik aliyor. +#ilk olarak kac ogrenci oldugunu n alir +#sozluk olusturur + +#her ogrencinin ismini bir anahtar(key), notlarinin ise bir liste olarak student_marks sozlugune ekler +#sorgu calistirir:kullanicidan sorgulamak istedigi ogrencinin adini alir ve o ogrencinin notlarini bulur +#Notlarin ortalamasini hesaplar ve yazdirir : + +#1ogrencileri ve notlari toplami: +#student_marks[name] = scores +#bu islem for dongusu icinde olur ve her ogrencinin adi(name)ile notlari(scores) sozluge eklenir + +#2 kullanicinin sorgulanmasi: +#query_name = input() +#scores =students_marks[query_name] + +#kullanicidan bir isim alinir ve bu ismi kullanarak solukten ilgili notlara ulasiriz +#numbers = ["1,"2","3","4"] + +#map fonksiyonu kullanilir +#result = map(int, numbers) +#print(result) +#print(list(result)) \ No newline at end of file