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
41 changes: 41 additions & 0 deletions 1-Random Password.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
"""
As a user, I want to use a program which can generate random password and display the result on user interface.
So that I can generate my password for any application.

Acceptance Criteria:
Password length must be 10 characters long.
It must contain at least 2 upper case letter, 2 digits and 2 special symbols.
You must import some required modules or packages.
The GUI of program must contain at least a button and a label.
The result should be display on the password label when the user click the generate button.
"""
import random
import string
import tkinter as tk


def gen_pass(lenght=10):
letters = string.ascii_lowercase
up_letters = string.ascii_uppercase
digits = string.digits
symbols = string.punctuation
passlist = random.sample(letters, 4)+random.sample(up_letters, 2)+random.sample(digits, 2)+random.sample(symbols, 2)
password = ''.join(random.sample(passlist, lenght)) # her deger 1 kere kullanilir
# password = ''.join(random.choice(passlist) for i in range(lenght)) # her deger 1 den fazla denk gelebilir yada gelmeyebilir
label2 = tk.Label(root, text='Your Password : '+password+'\n', fg="black", )
label2.pack()


root = tk.Tk()
root.title("Password Generator")

# Information
label1 = tk.Label(root, text=" Please click the button for generate your password \n")
label1.pack()
# root.geometry("400x350") #ana pencere boyutu ayarlanabilir yada veri girisi ile otomatik genisler

# Password Generate button
PassGenButton = tk.Button(root, bg="DeepSkyBlue2", fg="black", text="Generate My Password", command=lambda: gen_pass())
PassGenButton.pack()

root.mainloop()
44 changes: 44 additions & 0 deletions 2 - The Least Common Multiple.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
"""
As a user, I want to use a program which can calculate the least common multiple (L.C.M.) of four numbers.
So that I can find the least common multiple (L.C.M.) of my inputs.

Acceptance Criteria:

Ask user to enter the four numbers.
Use try/except blocks to verify input entries and warn the user for Nan or non numerical inputs.
Calculate the least common multiple (L.C.M.) of four numbers
Use gcd function in module of math
"""
# Python program to find LCM of four numbers wíthout use gcd functon in module of math
numlist = []
for x in range(4):
while True:
try:
a = int(input("Enter four numbers to calculate their LCM: "))
break
except ValueError:
print("You entered non numerical, please enter the number correctly")
numlist.append(a)

# Function to return gcd of two numbers


def gcd(a, b):
if a == 0:
return b
return gcd(b % a, a)

# Function to return LCM of two numbers


def lcm(a, b):
return int((a / gcd(a, b)) * b)

# Function to return LCM of four numbers


def lcm4(t, x, y, z):
return lcm(lcm(lcm(t, x), y), z)


print('LCM of', numlist, 'is', lcm4(numlist[0], numlist[1], numlist[2], numlist[3]))
37 changes: 37 additions & 0 deletions 2 - The Least Common Multiple_2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
"""
As a user, I want to use a program which can calculate the least common multiple (L.C.M.) of four numbers.
So that I can find the least common multiple (L.C.M.) of my inputs.

Acceptance Criteria:

Ask user to enter the four numbers.
Use try/except blocks to verify input entries and warn the user for Nan or non numerical inputs.
Calculate the least common multiple (L.C.M.) of four numbers
Use gcd function in module of math
"""
# Python program to find LCM of four numbers wíth use gcd functon in module of math
from math import gcd
numlist = []
for x in range(4):
while True:
try:
a = int(input("Enter four numbers to calculate their LCM: "))
break
except ValueError:
print("You entered non numerical, please enter the number correctly")

numlist.append(a)

# Function to return LCM of two numbers


def lcm(a, b):
return int((a / gcd(a, b)) * b)
# Function to return LCM of four numbers


def lcm4(t, x, y, z):
return lcm(lcm(lcm(t, x), y), z)


print('LCM of', numlist, 'is', lcm4(numlist[0], numlist[1], numlist[2], numlist[3]))
51 changes: 51 additions & 0 deletions 3- Number Guessing Game.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
"""
WAs a player, I want to play a game which I can guess a number the computer chooses in the range I chose.
So that I can try to find the correct number which was selected by computer.

Acceptance Criteria:

Computer must randomly pick an integer from user selected a range, i.e., from A to B, where A and B belong to Integer.
Your program should prompt the user for guesses
if the user guesses incorrectly, it should print whether the guess is too high or too low.
If the user guesses correctly, the program should print total time and total number of guesses.
You must import some required modules or packages
You can assume that the user will enter valid input.
"""
import random
from time import time

print("******************************************************\n"
"*** Quess the number ***\n"
"******************************************************")
print("Enter the range of the game")

while True:
try:
low_lim = int(input('Please Enter Lower Limit of Prediction: '))
upp_lim = int(input('Please Enter Upper Limit of Prediction: '))
break
except ValueError:
print("Please enter only number")

t_time = time()
number = random.randint(low_lim, upp_lim)
counter = 0
guess = []
print("***I'm ready. Guess my number***")
while guess != number:
counter += 1
try:
guess = int(input("\nEnter your guess: "))
except (ValueError, TypeError):
print("Please enter a number")

if guess > number:
print("Try again! It is Too high...")
elif guess < number:
print("Try again! It is Too low...")
else:
print("\nCongratulation!!!")
print("My Number is", number)
print("Total number of your guesses, ", counter)
t_time = time() - t_time
print("Total time of your guesses, ", round(t_time, 1), "seconds")