diff --git a/Calculator.py b/Calculator.py new file mode 100644 index 0000000..6069cff --- /dev/null +++ b/Calculator.py @@ -0,0 +1,66 @@ + +import math + +def add(num1, num2): + return (math.ceil(num1 + num2)) # mathceil ile yuvarlamayi buradaki fonksiyonlarda yapiyorum +def subtract(num1, num2): + return (math.ceil(num1 - num2)) +def multiply(num1, num2): + return (math.ceil(num1 * num2)) +def divide(num1, num2): + return (math.ceil(num1 / num2)) + +def calculate(): # hangi islemi yapacagimizi seciyoruz + print("Please select the type of calculation -\n" \ + "1. Add\n" \ + "2. Subtract\n" \ + "3. Multiply\n" \ + "4. Divide\n") + + while True: + select = input("Select type of calculation 1, 2, 3, 4 :") + try: + assert 0 < int(select) < 5 #baska sayi ve rakam girislerinde uyarip tekrar ettiriyoruz + break + except: + print("invalid entry!") + continue + while True: + number_1 = input("Enter first number: ") + number_2 = input("Enter second number: ") + try: + number_1 = float(number_1) # rakam girilmezse uyarip tekrar ettiriyoruz + number_2 = float(number_2) + break + except: + print("invalid entries") + continue + if int(select) == 1: + print(number_1, "+", number_2, "=", #islemine gore yukaridaki toplama, cikarrma vs fonsiyonlari cagiriyoruz + add(number_1, number_2)) + + elif int(select) == 2: + print(number_1, "-", number_2, "=", + subtract(number_1, number_2)) + + elif int(select) == 3: + print(number_1, "*", number_2, "=", + multiply(number_1, number_2)) + + elif int(select) == 4: + try: + assert number_2 != float(0) + except : # 0'a bolumde uyarip, bastan aliyoruz + print("Ooops, ZeroDivisionError!!! ") + else: + print(number_1, "/", number_2, "=", + divide(number_1, number_2)) + + new_operation = input("Would you like a new calculation, key y/n: ") + if new_operation == "y": + calculate() + elif new_operation == "n": # yeni islem yapmak istiyormuyuz + input("\nPress the enter key to exit") + else: + print("Invalid entry byebye..") +calculate() diff --git a/LCM.py b/LCM.py new file mode 100644 index 0000000..06f17e1 --- /dev/null +++ b/LCM.py @@ -0,0 +1,27 @@ + + +from math import gcd + +while True: + print ("Enter 4 number please,") + num1 = input ("Enter number 1: ") + num2 = input ("Enter number 2: ") + num3 = input("Enter number 3: ") + num4 = input("Enter number 4: ") + try: + num1 = int(num1) + num2 = int(num2) + num3 = int(num3) + num4 = int(num4) + break + except ValueError: # sayi girilmez ise uyarip, tekrar ettiriyoruz + print("invalid entries") + continue + +a = [num1, num2, num3, num4] +print ("Entered Numbers :", a) +lcm = a[0] +for i in a[:]: + lcm = lcm*i//gcd(lcm, i) +print("The L.C.M. of :", num1, '-', num2,'-', num3,'-', num4, "is", lcm ) + diff --git a/PasswordGen.py b/PasswordGen.py new file mode 100644 index 0000000..3498c27 --- /dev/null +++ b/PasswordGen.py @@ -0,0 +1,33 @@ + +import random +import string +from tkinter import * +from tkinter.ttk import * + + +root = Tk() +root.title("Password Generator App") +root['background']='#856ff8' +root.geometry("450x450") + + +pass_str = StringVar() +def generate(): # 2'ser tane buyuk harf, rakam ve karakteri seciyoruz, toplam 6 ediyor + random_source = string.ascii_letters + string.digits + string.punctuation + password = random.choice(string.ascii_uppercase) + random.choice(string.ascii_uppercase) + password += random.choice(string.digits) + random.choice(string.digits) + password += random.choice(string.punctuation) + random.choice(string.punctuation) + + for i in range(4): #kalan 4 karakteri yukaridaki kumeden aliyorum + password += random.choice(random_source) + + pass_str.set(password) + + +Label(root, text="Password Generator Application", font="Lucida 20 bold").pack() + +Button(root, text="Generate Password", command=generate).pack(pady=7) + +Entry(root, textvariable=pass_str).pack(pady=2) +root.mainloop() + diff --git a/SayiTahmin.py b/SayiTahmin.py new file mode 100644 index 0000000..a34b99a --- /dev/null +++ b/SayiTahmin.py @@ -0,0 +1,22 @@ + + +import random +import time + +n = random.randint(1, 20) +tahmin = int(input("1 ve 20 arasinda bir sayi giriniz: ")) +start_time = time.time() +count = 0 + +while n != "tahmin": + count += 1 + if tahmin < n: + print ("tahminin dusuk") + tahmin = int(input("1 ve 20 arasinda bir sayi giriniz: ")) + elif tahmin > n: + print ("tahminin yuksek") + tahmin = int(input("1 ve 20 arasinda bir sayi giriniz: ")) + else: + print ("Dogru!", int(time.time() - start_time), "saniyede ve", count, "ncu tahminde bildiniz...") + #print (int(time.time() - start_time), "saniyede bildiniz") + break \ No newline at end of file