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
47 changes: 47 additions & 0 deletions 1-Random Password.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import tkinter

import random

frame1 = tkinter.Tk()
def random_password():
special_characters = [random.randint(33, 47) for i in range(2)]
nummers = [random.randint(48, 57) for i in range(2)]
hoofdletters = [random.randint(65, 90) for i in range(2)]
kleineletters = [random.randint(97, 122) for i in range(4)]
generated = []

generated.extend(special_characters)
generated.extend(nummers)
generated.extend(hoofdletters)
generated.extend(kleineletters)

password = ''
for i in range(10):
password += chr(generated[i])

password_label = tkinter.Label(frame1, text=password, fg="yellow", bg="blue", font="Arial 18")
password_label.pack(fill=tkinter.X)

def generator():
frame = tkinter.Tk()
frame.title("Random Password Maker")
frame.geometry('600x300')
frame.columnconfigure(0, weight=1)

# frame_Label
label = tkinter.Label(frame, text="The password generator is ready for you!", font=("Arial", "12", "bold"))
label.pack()

# acceptance_criteria_Label
criteria_label = tkinter.Label(frame, text="""Password length must be 10 characters long.
It must contain at least 2 upper case letter, 2 digits and 2 special symbols.""")
criteria_label.pack()

# password_button
button = tkinter.Button(frame, text="Generate a password", fg="green", font=("Arial", "12", "bold"),
command=random_password)
button.pack(padx=150, pady=50)
frame.mainloop()

if __name__ == '__main__':
generator()
41 changes: 41 additions & 0 deletions 2-The Least Common Multiple.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# 2 - The Least Common Multiple

# 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

import math
ebob = math.gcd


numbers = []
ebob_list = []
while True:
try:
number = input("Enter four numbers with spaces between them: ").strip(" ").split()
for i in range(4):
numbers.append(int(number[i]))
break
except:
print("Please enter only valid numbers!")

ebob_list.append(ebob(numbers[0], numbers[1]))
ebob_list.append(ebob(numbers[2], numbers[3]))

ekok_list = []
n = 0
for i in range(2):
i += i
carpim = numbers[i] * numbers[i + 1]
ekok_list.append(int(carpim / ebob_list[n]))
n += 1
ebob_list2 = ebob(ekok_list[0], ekok_list[1])
ekok_result = ekok_list[0] * ekok_list[1]
result = ekok_result / ebob_list2 # sonucta istenen okek i result a atatim.
print("The Least Common Multiple of {},{},{},and {} is ---{}---"
.format(numbers[0], numbers[1], numbers[2], numbers[3], int(result)))
43 changes: 43 additions & 0 deletions 3- Number Guessing Game.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# 3- Number Guessing Game

# As 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
import time


minimum = int(input("Please enter the minimum number: "))
maximum = int(input("Please enter the maximum number: "))
target = random.randint(minimum, maximum)

print("The computer has the number chosen.")

n = 1

time1 = time.time()
while True:
predict = int(input("Your guess: "))
if predict == target:
print("Congratulations!")
break
elif predict > target:
print("Please try a smaller number: ")
n += 1
elif predict < target:
print("Please try a bigger number: ")
n += 1
continue
time2 = time.time()
duration = float(time2 - time1)

print("Elapsed time: {} seconds". format(duration))
print("Number of tries: {}". format(n))
73 changes: 73 additions & 0 deletions 4- Mis Calculator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# As a user, I want to use a program which can calculate basic mathematical operations. So that I can add, subtract, multiply or divide my inputs.

# Acceptance Criteria:

# The calculator must support the Addition, Subtraction, Multiplication and Division operations.
# Define four functions in four files for each of them, with two float numbers as parameters.
# To calculate the answer, use math.ceil() and get the next integer value greater than the result
# Create a menu using the print command with the respective options and take an input choice from the user.
# Using if/elif statements for cases and call the appropriate functions.
# Use try/except blocks to verify input entries and warn the user for incorrect inputs.
# Ask user if calculate numbers again. To implement this, take the input from user Y or N.


import math
from addition import Addition
from subtraction import Subtraction
from multiplication import Multiplication
from division import Division
afronden = math.ceil


def num_input():
while True:
try:
number = float(input("Please enter a float number: "))
break
except ValueError:
print("""Please enter a valid float number using "." """)
return number


def operant():
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("Please enter a valid mathematical operator!")

return symbol


def yes_no():
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:

symbol = operant()

if symbol == '+':
print("Result: " + str(afronden(Addition(num_input(), num_input()))))
elif symbol == '-':
print("Result: " + str(afronden(Subtraction(num_input(), num_input()))))
elif symbol == '*':
print("Result: " + str(afronden(Multiplication(num_input(), num_input()))))
elif symbol == '/':
print("Result: " + str(afronden(Division(num_input(), num_input()))))

antwoord = yes_no()
if antwoord == 'N' or antwoord == '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(x,y):
return x+y
5 changes: 5 additions & 0 deletions division.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
def Division(x,y):
try:
return x/y
except ZeroDivisionError:
return "Numbers can not divided by 0"
2 changes: 2 additions & 0 deletions multiplication.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def Multiplication(x,y):
return x*y
2 changes: 2 additions & 0 deletions subtraction.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def Subtraction(x,y):
return x-y