Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions 1-Random Password.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import random
import string
from tkinter import *


def password_generator():
result = ""
for i in range(1, 11):
result = result + random.choices(
string.ascii_uppercase + string.digits + string.punctuation + string.ascii_lowercase).pop()

return result


def is_suitable_password(password):
upper_case_count = 0
lower_case_count = 0
digit_count = 0
symbol_count = 0

for i in password:
if string.ascii_lowercase.count(i) > 0:
lower_case_count += 1
elif string.ascii_uppercase.count(i) > 0:
upper_case_count += 1
elif string.punctuation.count(i) > 0:
symbol_count += 1
else:
digit_count += 1

if digit_count >= 2 and upper_case_count >= 2 and symbol_count >= 2:
return True
else:
return False


def press():
while True:

new_password = password_generator()
if is_suitable_password(new_password) is True:
l1.config(text=new_password)
break


main_frame = Tk(className=" Password Generator App")
main_frame.geometry("400x400")
b1 = Button(main_frame, text="Generate password", command=press).pack()
l1 = Label(main_frame, text="Welcome")
l1.pack()

main_frame.mainloop()
31 changes: 31 additions & 0 deletions 2-The Least Common Multiple.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import math
gcd = math.gcd

while True:
try:
a = int(input("Please enter first number: "))
break
except ValueError:
print("Oops! That was no valid number. Try again...")
while True:
try:
b = int(input("Please enter second number: "))
break
except ValueError:
print("Oops! That was no valid number. Try again...")

while True:
try:
c = int(input("Please enter third number: "))
break
except ValueError:
print("Oops! That was no valid number. Try again...")

while True:
try:
d = int(input("Please enter fourth number: "))
break
except ValueError:
print("Oops! That was no valid number. Try again...")

print("L.C.M. is : " + str(gcd(a, b, c, d)))
27 changes: 27 additions & 0 deletions 3-Number Guessing Game.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import random
import time

start_of_serie = int(input("Please enter your selected range's start:"))
end_of_serie = int(input("Please enter your selected range's end:"))
guess_count = 0
elapsed_time = 0
computer_selection = random.randint(start_of_serie, end_of_serie + 1)
# print(computer_selection)
start_time = time.time()
user_selection = int(input("Please guess a number from what was your selected range and insert: "))
guess_count += 1

while True:

if user_selection == computer_selection:
print("Congratulations")
elapsed_time = time.time() - start_time
print("Elapsed time: " + str(elapsed_time))
print("Guess count: " + str(guess_count))
break
elif user_selection > computer_selection:
user_selection = int(input("Please guess a smaller number than your guess: "))
guess_count += 1
else:
user_selection = int(input("Please guess a bigger number than your guess: "))
guess_count += 1
60 changes: 60 additions & 0 deletions 4- Mis Calculator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import math
from Addition import addition
from Subtraction import subtraction
from Multiplication import multiplication
from Division import division
round_number_ceil = math.ceil


def get_number_input():
while True:
try:
number = float(input("Please enter a float ( with '.' ) number: "))
break
except ValueError:
print("Oops! That was no valid number. Try again...")
return number


def get_operator_symbol():
while True:
try:
symbol = input("Please enter a mathematical operator symbol (+,-,*,/): ")
if symbol != '+' and symbol != '-' and symbol != '*' and symbol != '/':
raise ValueError
break
except ValueError:
print("Oops! That was no valid symbol. Try again...")

return symbol


def get_y_n_answer():
while True:
try:
letter = input("Would you like to make another calculation (Y,N): ")
if letter != 'Y' and letter != 'y' and letter != 'N' and letter != 'n':
raise ValueError
break
except ValueError:
print("Oops! That was no valid symbol. Try again...")

return letter


while True:

operator_symbol = get_operator_symbol()

if operator_symbol == '+':
print("Result: " + str(round_number_ceil(addition(get_number_input(), get_number_input()))))
elif operator_symbol == '-':
print("Result: " + str(round_number_ceil(subtraction(get_number_input(), get_number_input()))))
elif operator_symbol == '*':
print("Result: " + str(round_number_ceil(multiplication(get_number_input(), get_number_input()))))
elif operator_symbol == '/':
print("Result: " + str(round_number_ceil(division(get_number_input(), get_number_input()))))

answer_letter = get_y_n_answer()
if answer_letter == 'N' or answer_letter == 'n':
break
2 changes: 2 additions & 0 deletions Addition.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def addition(a, b):
return a + b
2 changes: 2 additions & 0 deletions Division.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def division(a, b):
return a / b
2 changes: 2 additions & 0 deletions Multiplication.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def multiplication(a, b):
return a * b
2 changes: 2 additions & 0 deletions Subtraction.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def subtraction(a, b):
return a - b