diff --git a/4.1_Random_Password.py b/4.1_Random_Password.py new file mode 100644 index 0000000..d79e640 --- /dev/null +++ b/4.1_Random_Password.py @@ -0,0 +1,67 @@ +''' +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. +''' + + +# http://54.234.188.223:8501/ +# streamlit run app.py + +from random import choice,shuffle +import streamlit as st +html_temp = """ +
+

Generate Your Password

+
""" +st.markdown(html_temp,unsafe_allow_html=True) + +from PIL import Image +im = Image.open("image.jpg") +st.image(im, width=700) + +upper_cases='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +lower_cases='abcdefghijklmnopqrstuvwxyz' +digits='0123456789' +specials='!"#$%&\()*+,-./:;<=>?@[]^_`{|}~' +all_char=upper_cases+lower_cases+digits+specials + +st.sidebar.header("Configure the Password Features:") +lenght=st.slider('What is the lenght of password?',0,20,10) +upper_case_count=st.sidebar.slider('What is the count of the upper cases at least?',0,10,2) +lower_case_count=st.sidebar.slider('What is the count of the lower cases at least?',0,10,2) +digit_count=st.sidebar.slider('What is the count of the digits at least?',0,10,2) +special_count=st.sidebar.slider('What is the count of the special characters at least?',0,10,2) + + +if st.button('Generate'): + upper,lower,special,digit,password=['' for _ in range(5)] + + for i in range(upper_case_count): + upper += choice(upper_cases) + + for i in range(lower_case_count): + lower += choice(lower_cases) + + for i in range(digit_count): + digit += choice(digits) + + for i in range(special_count): + special += choice(specials) + + must_be = upper + lower + digit + special + + for i in range(lenght-len(must_be)): + password += choice(all_char) + + password+=must_be + password=list(password) + shuffle(password) + + st.success(f'''Password: "{''.join(password)}"''') \ No newline at end of file diff --git a/4.2_The_Least_Common_Multiple.py b/4.2_The_Least_Common_Multiple.py new file mode 100644 index 0000000..1e83fdd --- /dev/null +++ b/4.2_The_Least_Common_Multiple.py @@ -0,0 +1,35 @@ +""" +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 +""" +from math import gcd + +def isValid(n:str) ->bool: + try: + 1/int(n) + except Exception: + print("Entry is invalid! Try again...\n") + return False + else: + return True + +nums=[] +while len(nums)<4: + n=input(f"Number_{len(nums)+1}: ") + if isValid(n): nums.append(int(n)) + +gcd1 = gcd(nums[0],nums[1]) +gcd2 = gcd(nums[2],nums[3]) +lcm_1 = nums[0]*nums[1] // gcd1 +lcm_2 = nums[2]*nums[3] // gcd2 + +print(f"\nEBOB{nums} = {gcd(gcd1,gcd2)}\n" + f"EKOK{nums} = {lcm_1*lcm_2//gcd(lcm_1,lcm_2)}") \ No newline at end of file diff --git a/4.3_Number_Guessing_Game.py b/4.3_Number_Guessing_Game.py new file mode 100644 index 0000000..b05227e --- /dev/null +++ b/4.3_Number_Guessing_Game.py @@ -0,0 +1,35 @@ +''' +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. +''' + +from random import randint +from time import time + +target=randint(int(input('Lower Limit: ')),int(input('Upper Limit: '))) + +print('Predict the Number:') +diff=time() +counter=0 +while True: + p=int(input()) + counter+=1 + if p==target: + diff=time()-diff + print(f'\nCongratulations!!!\nTarget Number is {target}', + f'Number of Guesses: {counter}', + f'Time Passed: {round(diff,1)} sec.',sep='\n') + break + else: + if p > target: print('Too low...') + else: print('Too high...') + \ No newline at end of file diff --git a/4.4_Mis_Calculator.py b/4.4_Mis_Calculator.py new file mode 100644 index 0000000..57131b5 --- /dev/null +++ b/4.4_Mis_Calculator.py @@ -0,0 +1,51 @@ +""" +4- Mis Calculator + +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 operations import add, sum, multiply, divide + +def isValid(n:str) ->bool: + try: + float(n) + except Exception: + print("Entry is invalid! Try again...\n") + return False + else: + return True +while True: + nums=[] + while len(nums)<2: + n=input(f"Number_{len(nums)+1}: ") + if isValid(n): nums.append(int(n)) + + while True: + op=int(input('1-Addition\n2-Subtraction\n3-Multiplication\n4-Division\n\nSelect the operation number from the list above: ')) + if op in [1,2,3,4]: break + print("Entry is invalid! Try again...\n") + + if op==1: + result=add(nums[0],nums[1]) + elif op==2: + result=sum(nums[0],nums[1]) + elif op==3: + result=multiply(nums[0],nums[1]) + elif op==4 and nums[1] != 0: + result=divide(nums[0],nums[1]) + + operate = (op==1)*'+' or (op==2)*'-' or (op==3)*'*' or (op==4)*'/' + print(f"{nums[0]} {operate} {nums[1]} = {math.ceil(result)}") + + if input('Do you want to continue? [y/n]:').lower()=='n': + break \ No newline at end of file diff --git a/image.jpg b/image.jpg new file mode 100644 index 0000000..2123316 Binary files /dev/null and b/image.jpg differ diff --git a/operations.py b/operations.py new file mode 100644 index 0000000..5c56c39 --- /dev/null +++ b/operations.py @@ -0,0 +1,11 @@ +def add(a,b): + return a+b + +def sum(a,b): + return a-b + +def multiply(a,b): + return a*b + +def divide(a,b): + return a/b \ No newline at end of file