├── Screenshot.py ├── countercloak.py ├── drrinking water notification.py ├── generator.py └── passwordchecker.py /Screenshot.py: -------------------------------------------------------------------------------- 1 | 2 | import pyscreenshot 3 | 4 | 5 | image = pyscreenshot.grab() 6 | 7 | image.show() 8 | 9 | 10 | image.save("GeeksforGeeks.png") 11 | -------------------------------------------------------------------------------- /countercloak.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | def countdown(t): 4 | while t: 5 | mins, secs = divmod(t, 60) 6 | timer = '{:02d}:{:02d}'.format(mins, secs) 7 | print(timer, end='\r') import random 8 | 9 | # Print multiline instruction 10 | print('Winning rules of the game ROCK PAPER SCISSORS are:\n' 11 | + "Rock vs Paper -> Paper wins \n" 12 | + "Rock vs Scissors -> Rock wins \n" 13 | + "Paper vs Scissors -> Scissors wins \n") 14 | 15 | while True: 16 | 17 | print("Enter your choice \n 1 - Rock \n 2 - Paper \n 3 - Scissors \n") 18 | 19 | # Take the input from user 20 | choice = int(input("Enter your choice: ")) 21 | 22 | # Looping until user enters valid input 23 | while choice > 3 or choice < 1: 24 | choice = int(input('Enter a valid choice please : ')) 25 | 26 | # Initialize value of choice_name variable corresponding to the choice value 27 | if choice == 1: 28 | choice_name = 'Rock' 29 | elif choice == 2: 30 | choice_name = 'Paper' 31 | else: 32 | choice_name = 'Scissors' 33 | 34 | # Print user choice 35 | print('User choice is:', choice_name) 36 | print("Now it's Computer's Turn...") 37 | 38 | # Computer chooses randomly any number among 1, 2, and 3 39 | comp_choice = random.randint(1, 3) 40 | 41 | # Initialize value of comp_choice_name variable corresponding to the choice value 42 | if comp_choice == 1: 43 | comp_choice_name = 'Rock' 44 | elif comp_choice == 2: 45 | comp_choice_name = 'Paper' 46 | else: 47 | comp_choice_name = 'Scissors' 48 | 49 | print("Computer choice is:", comp_choice_name) 50 | print(choice_name, 'vs', comp_choice_name) 51 | 52 | # Determine the winner 53 | if choice == comp_choice: 54 | result = "DRAW" 55 | elif (choice == 1 and comp_choice == 2) or (comp_choice == 1 and choice == 2): 56 | result = 'Paper' 57 | elif (choice == 1 and comp_choice == 3) or (comp_choice == 1 and choice == 3): 58 | result = 'Rock' 59 | elif (choice == 2 and comp_choice == 3) or (comp_choice == 2 and choice == 3): 60 | result = 'Scissors' 61 | 62 | # Print the result 63 | if result == "DRAW": 64 | print("<== It's a tie! ==>") 65 | elif result == choice_name: 66 | print("<== User wins! ==>") 67 | else: 68 | print("<== Computer wins! ==>") 69 | 70 | # Ask if the user wants to play again 71 | print("Do you want to play again? (Y/N)") 72 | ans = input().lower() 73 | if ans == 'n': 74 | break 75 | 76 | # After coming out of the while loop, print thanks for playing 77 | print("Thanks for playing!") 78 | time.sleep(1) 79 | t -= 1 80 | 81 | print("Fire in the hole!!") 82 | 83 | t = input("Enter the time in seconds: ") 84 | 85 | countdown(int(t)) 86 | -------------------------------------------------------------------------------- /drrinking water notification.py: -------------------------------------------------------------------------------- 1 | import time 2 | from win10toast import ToastNotifier 3 | import datetime 4 | 5 | 6 | def getTimeInput(): 7 | hour = int(input("hours of interval :")) 8 | minutes = int(input("Mins of interval :")) 9 | seconds = int(input("Secs of interval :")) 10 | time_interval = seconds+(minutes*60)+(hour*3600) 11 | return time_interval 12 | 13 | 14 | def log(): 15 | now = datetime.datetime.now() 16 | start_time = now.strftime("%H:%M:%S") 17 | with open("log.txt", 'a') as f: 18 | f.write(f"You drank water {now} \n") 19 | return 0 20 | 21 | 22 | def notify(): 23 | notification = ToastNotifier() 24 | notification.show_toast("Time to drink water") 25 | log() 26 | return 0 27 | 28 | 29 | def starttime(time_interval): 30 | while True: 31 | time.sleep(time_interval) 32 | notify() 33 | 34 | 35 | if __name__ == '__main__': 36 | time_interval = getTimeInput() 37 | starttime(time_interval) 38 | -------------------------------------------------------------------------------- /generator.py: -------------------------------------------------------------------------------- 1 | import string 2 | import random 3 | 4 | # Getting password length 5 | length = int(input("Enter password length: ")) 6 | 7 | print('''Choose character set for password from these : 8 | 1. Digits 9 | 2. Letters 10 | 3. Special characters 11 | 4. Exit''') 12 | 13 | characterList = "" 14 | 15 | # Getting character set for password 16 | while(True): 17 | choice = int(input("Pick a number ")) 18 | if(choice == 1): 19 | 20 | # Adding letters to possible characters 21 | characterList += string.ascii_letters 22 | elif(choice == 2): 23 | 24 | # Adding digits to possible characters 25 | characterList += string.digits 26 | elif(choice == 3): 27 | 28 | # Adding special characters to possible 29 | # characters 30 | characterList += string.punctuation 31 | elif(choice == 4): 32 | break 33 | else: 34 | print("Please pick a valid option!") 35 | 36 | password = [] 37 | 38 | for i in range(length): 39 | 40 | # Picking a random character from our 41 | # character list 42 | randomchar = random.choice(characterList) 43 | 44 | # appending a random character to password 45 | password.append(randomchar) 46 | 47 | # printing password as a string 48 | print("The random password is " + "".join(password)) 49 | -------------------------------------------------------------------------------- /passwordchecker.py: -------------------------------------------------------------------------------- 1 | # Python program to check validation of password 2 | # Module of regular expression is used with search() 3 | import re 4 | password = "R@m@_f0rtu9e$" 5 | flag = 0 6 | while True: 7 | if (len(password)<=8): 8 | flag = -1 9 | break 10 | elif not re.search("[a-z]", password): 11 | flag = -1 12 | break 13 | elif not re.search("[A-Z]", password): 14 | flag = -1 15 | break 16 | elif not re.search("[0-9]", password): 17 | flag = -1 18 | break 19 | elif not re.search("[_@$]" , password): 20 | flag = -1 21 | break 22 | elif re.search("\s" , password): 23 | flag = -1 24 | break 25 | else: 26 | flag = 0 27 | print("Valid Password") 28 | break 29 | 30 | if flag == -1: 31 | print("Not a Valid Password ") --------------------------------------------------------------------------------