├── password generator ├── calculator └── Rock-paper-scissors game /password generator: -------------------------------------------------------------------------------- 1 | import random 2 | b = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*' 3 | try : 4 | C = int ( input ("Type the lenght of the password :")) 5 | D = int(input ("Enter the number of password you want :")) 6 | str ='' 7 | for i in range (0,D): 8 | for j in range (0,C): 9 | str = str + random.choice(b) 10 | print (f"password {i+1} is {str}") 11 | str = '' 12 | except ValueError : 13 | print ("invalid . it must be in integer ") 14 | -------------------------------------------------------------------------------- /calculator: -------------------------------------------------------------------------------- 1 | A=int(input()) 2 | B=int(input()) 3 | print("1.ADD\n2.MULTI\n3.SUB\n4.MODULO\n5.DIVI\n6.EXPONENT\n") 4 | C=int(input()) 5 | if(C==1): 6 | add=A+B 7 | print("ADD",add) 8 | elif(C==2): 9 | multi=A*B 10 | print("MULTI",multi) 11 | elif(C==3): 12 | sub=A-B 13 | print("SUB",sub) 14 | elif(C==4): 15 | mod=A%B 16 | print("MODULO",mod) 17 | elif(C==5): 18 | div=A/B 19 | print("DIVI",div) 20 | elif(C==6): 21 | expo=A**B 22 | print("EXPONENT",expo) 23 | else: 24 | print("invald") 25 | -------------------------------------------------------------------------------- /Rock-paper-scissors game: -------------------------------------------------------------------------------- 1 | import random 2 | def get_computer_choice(): 3 | return random.choice(['rock', 'paper', 'scissors']) 4 | 5 | def determine_winner(user_choice, computer_choice): 6 | if user_choice == computer_choice: 7 | return "tie" 8 | elif (user_choice == 'rock' and computer_choice == 'scissors') or \ 9 | (user_choice == 'scissors' and computer_choice == 'paper') or \ 10 | (user_choice == 'paper' and computer_choice == 'rock'): 11 | return "user" 12 | else: 13 | return "computer" 14 | 15 | def play_round(): 16 | user_choice = input("Choose rock, paper, or scissors: ").lower() 17 | while user_choice not in ['rock', 'paper', 'scissors']: 18 | print("Invalid choice. Please choose again.") 19 | user_choice = input("Choose rock, paper, or scissors: ").lower() 20 | 21 | computer_choice = get_computer_choice() 22 | print(f"Computer chose: {computer_choice}") 23 | 24 | result = determine_winner(user_choice, computer_choice) 25 | if result == "tie": 26 | print("It's a tie!") 27 | elif result == "user": 28 | print("You win!") 29 | else: 30 | print("You lose!") 31 | 32 | return result 33 | 34 | def play_game(): 35 | user_score = 0 36 | computer_score = 0 37 | 38 | while True: 39 | result = play_round() 40 | if result == "user": 41 | user_score += 1 42 | elif result == "computer": 43 | computer_score += 1 44 | 45 | print(f"Score - You: {user_score}, Computer: {computer_score}") 46 | 47 | play_again = input("Do you want to play again? (yes/no): ").lower() 48 | if play_again != 'yes': 49 | break 50 | 51 | print("Thanks for playing!") 52 | 53 | if __name__ == "__main__": 54 | play_game() 55 | 56 | 57 | 58 | --------------------------------------------------------------------------------