diff --git a/W4_Q1_Pass_Generator.py b/W4_Q1_Pass_Generator.py new file mode 100644 index 0000000..6205042 --- /dev/null +++ b/W4_Q1_Pass_Generator.py @@ -0,0 +1,57 @@ +#C@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@1 +# PyCoder Coding Class:4 @ +# Cabir Erguven @ +# Week : 4 @ +# Question : 1 @ +# Date: 30.01.2021 @ +#C@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@1 +# +# Random Password Generator +# +# 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 tkinter as tk + +def generate(): + names_upper = " ABCDEFGHIJKLMNOPRSTUVXYZ" + names_lower = "abcdefghijklmnoprstuvxyz" + spe_char = "!@$%&*_-+=" + digits ="1234567890" + + result_lower = random.sample(names_lower,3) + result_upper = random.sample(names_upper,3) + result_char = random.sample(spe_char,2) + result_num = random.sample(digits,2) + + join_list = result_lower+result_upper+result_char+result_num + random.shuffle(join_list) + a = ("".join(join_list)) + + message2 = tk.Label(root, text=a) + message2.pack() + + +root = tk.Tk() +root.title("Password Generator") + +# Instruction +message = tk.Label(root,text=" Please click the Generate button for your password ") +message.pack() +root.geometry("300x350") + +# Generate button +generateButton = tk.Button(root, bg="red", text="Generate", command=lambda:generate()) +generateButton.pack() + +root.mainloop() + diff --git a/W4_Q2_LCM.py b/W4_Q2_LCM.py new file mode 100644 index 0000000..50dba2e --- /dev/null +++ b/W4_Q2_LCM.py @@ -0,0 +1,40 @@ +#C@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@1 +# PyCoder Coding Class:4 @ +# Cabir Erguven @ +# Week : 4 @ +# Question : 2 @ +# Date: 30.01.2021 @ +#C@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@1 +# +# 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 +list = [] +res = 1 +a = 0 + + +for x in range(4): + while True: + try: + a = int(input("Enter four numbers to calculate their LCM: ")) + break + except ValueError: + print("You entered NaN, please enter the numbers correctly") + + + list.append(a) + +lcf_step1 = int((list[0] * list[1]) / math.gcd(list[0], list[1])) # recursive can be used +lcf_step2 = int((lcf_step1 * list[2]) / math.gcd(lcf_step1, list[2])) +lcf_step3 = int((lcf_step2 * list[3]) / math.gcd(lcf_step2, list[3])) + +print("LCF of", list[0], list[1], list[2], list[3], "is:", lcf_step3) diff --git a/W4_Q3_Guess_the_number.py b/W4_Q3_Guess_the_number.py new file mode 100644 index 0000000..342fbe1 --- /dev/null +++ b/W4_Q3_Guess_the_number.py @@ -0,0 +1,67 @@ +#C@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@1 +# PyCoder Coding Class:4 @ +# Cabir Erguven @ +# Week : 4 @ +# Question : 3 @ +# Date: 30.01.2021 @ +#C@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@1 +# +# Number Guessing Game +# +# 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. + +from timeit import default_timer as timer +import random + +print("******* GUESS THE NUMBER *******") +print("Enter the range of the number you want to find") + +while True: + try: + begin = int(input("Enter the first number: ")) + finish = int(input("Enter the last number: ")) + break + except ValueError: + print("Please enter only number") + + +start = timer() +number = random.randint(begin, finish) +count = 0 +guess = [] + +while guess != number: + count += 1 + + # try: + # guess = int(input("Please enter a number: ")) + # except ValueError: + # print("Please enter a valid number!") + + try: + guess = int(input("\nEnter your guess: ")) + + if guess > number: + print(" It is too high") + elif guess < number: + print(" It is too low") + else: + print("\nCongratulation!!!") + print("You guessed in",count,"times.") + + except (ValueError, TypeError): + print("Please enter a valid number") + +end = timer() +print("It took", round((end - start), 2), "seconds to finish the game!") diff --git a/W4_Q4__Calculator.py b/W4_Q4__Calculator.py new file mode 100644 index 0000000..ead2de3 --- /dev/null +++ b/W4_Q4__Calculator.py @@ -0,0 +1,53 @@ +#C@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@1 +# PyCoder Coding Class:4 @ +# Cabir Erguven @ +# Week : 4 @ +# Question : 4 @ +# Date: 30.01.2021 @ +#C@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@1 +# +# Mis Calculator +# +# 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 +import add_of_calculator as a, subtract_of_calculator as s, multiply_of_calculator as m, divide_of_calculator as d +while True: + operation_list = ["+","-","*", "/"] + operation = input("Which operation do you want to perform ' + - * / ' ?") + + if operation not in operation_list: + print("Operation is INVALID! \nEnter only the following symbols ' + - * / ' ") + break + try: + first = int(input("enter first number: ")) + second = int(input("enter second number: ")) + except (ValueError, NameError): + print("Please Enter only number") + break + + if operation == "+": + print("The result is: ",math.ceil(a.add(first,second))) + elif operation == "-": + print("The result is: ",math.ceil(s.subtract(first,second))) + elif operation == "*": + print("The result is: ",math.ceil(m.multiply(first,second))) + elif operation == "/": + print("The result is: ",math.ceil(d.divide(first,second))) + + answer = input("\nDo you want to perform more operation? [Y /N]") + if answer == ("n" or "N"): + print ("See you again! ") + break + diff --git a/W4_Q4_add_of_calculator.py b/W4_Q4_add_of_calculator.py new file mode 100644 index 0000000..bf4667a --- /dev/null +++ b/W4_Q4_add_of_calculator.py @@ -0,0 +1,3 @@ +def add(a,b): + result = float(a) + float (b) + return result \ No newline at end of file diff --git a/W4_Q4_divide_of_calculator.py b/W4_Q4_divide_of_calculator.py new file mode 100644 index 0000000..d658011 --- /dev/null +++ b/W4_Q4_divide_of_calculator.py @@ -0,0 +1,3 @@ +def divide(a,b): + result = float(a) / float (b) + return result \ No newline at end of file diff --git a/W4_Q4_multiply_of_calculator.py b/W4_Q4_multiply_of_calculator.py new file mode 100644 index 0000000..a027791 --- /dev/null +++ b/W4_Q4_multiply_of_calculator.py @@ -0,0 +1,3 @@ +def multiply(a,b): + result = float(a) * float (b) + return result \ No newline at end of file diff --git a/W4_Q4_subtract_of_calculator.py b/W4_Q4_subtract_of_calculator.py new file mode 100644 index 0000000..3a83a06 --- /dev/null +++ b/W4_Q4_subtract_of_calculator.py @@ -0,0 +1,3 @@ +def subtract(a,b): + result = float(a) - float (b) + return result \ No newline at end of file diff --git a/W4_Q5_Password_Generator_Package.py b/W4_Q5_Password_Generator_Package.py new file mode 100644 index 0000000..b7e7635 --- /dev/null +++ b/W4_Q5_Password_Generator_Package.py @@ -0,0 +1,9 @@ +''' +You tube videolari indirmek icin +''' + + + +def download_link(): + return +