├── .gitattributes ├── Blackjack ├── __pycache__ │ └── logo.cpython-310.pyc ├── blackjack.py ├── logo.py └── tempCodeRunnerFile.py ├── Coffe Machine with OOP ├── .upm │ └── store.json ├── __pycache__ │ ├── coffee_maker.cpython-310.pyc │ ├── coffee_maker.cpython-38.pyc │ ├── menu.cpython-310.pyc │ ├── menu.cpython-38.pyc │ ├── money_machine.cpython-310.pyc │ └── money_machine.cpython-38.pyc ├── coffee_maker.py ├── main.py ├── menu.py └── money_machine.py ├── Coffee Machine ├── Logo.py ├── Untitled-2.clj ├── __pycache__ │ └── Logo.cpython-310.pyc └── cofeemachine.py ├── Grafics └── main.py ├── Guess a number ├── game.py └── tempCodeRunnerFile.py ├── Higher lower ├── Logo.py ├── Untitled-1.py ├── __pycache__ │ ├── Logo.cpython-310.pyc │ └── data.cpython-310.pyc └── data.py ├── README.md ├── Rock paper scissors └── paper ├── True love └── true_love.py ├── buzz fizz └── test.py ├── caesar cipher ├── __pycache__ │ └── logo.cpython-310.pyc ├── code.py └── logo.py ├── calculator └── calculator.py ├── day16 └── main.py └── password generator └── pswrd.py /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /Blackjack/__pycache__/logo.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ranimbenkerri/Python-Programing/b49f5f4471cde826cad5a95afe60e26cde81ab09/Blackjack/__pycache__/logo.cpython-310.pyc -------------------------------------------------------------------------------- /Blackjack/blackjack.py: -------------------------------------------------------------------------------- 1 | from logo import L 2 | import random 3 | print(L) 4 | def yes(user, computer): 5 | number = [11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10] 6 | card1 = int(random.choice(number)) 7 | computer2 = int(random.choice(number)) 8 | user = user + card1 9 | if computer < 17: 10 | computer = computer + computer 11 | 12 | print(user) 13 | print(computer) 14 | def compare(user_score, computer_score): 15 | #Bug fix. If you and the computer are both over, you lose. 16 | if user_score > 21 and computer_score > 21: 17 | return "You went over. You lose 😤" 18 | 19 | 20 | if user_score == computer_score: 21 | return "Draw 🙃" 22 | elif computer_score == 0: 23 | return "Lose, opponent has Blackjack 😱" 24 | elif user_score == 0: 25 | return "Win with a Blackjack 😎" 26 | elif user_score > 21: 27 | return "You went over. You lose 😭" 28 | elif computer_score > 21: 29 | return "Opponent went over. You win 😁" 30 | elif user_score > computer_score: 31 | return "You win 😃" 32 | else: 33 | return "You lose 😤" 34 | 35 | 36 | 37 | 38 | 39 | 40 | number = [11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10] 41 | card1 = random.choice(number) 42 | card2 = random.choice(number) 43 | user_score = int(card1 + card2) 44 | print(f"Your cards : [{card1}, {card2}] current score : {user_score}") 45 | computer = random.choice(number) 46 | computer2 = random.choice(number) 47 | computer_score = int(computer + computer2) 48 | print(computer_score) 49 | print(f"computer's first card : [{computer}]") 50 | q = True 51 | i=0 52 | while i<5 and q == True: 53 | user = input("type 'y' to get another card , type 'n' to pass : ") 54 | if user == 'y': 55 | yes(user_score, computer_score) 56 | if user == 'n': 57 | print(compare(user_score, computer_score)) 58 | q=False 59 | ################################################################### 60 | 61 | 62 | ############### Our Blackjack House Rules ##################### 63 | 64 | # ## The deck is unlimited in size. 65 | # ## There are no jokers. 66 | # ## The Jack/Queen/King all count as 10. 67 | # ## The the Ace can count as 11 or 1. 68 | # ## Use the following list as the deck of cards: 69 | # ## cards = [11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10] 70 | # ## The cards in the list have equal probability of being drawn. 71 | # ## Cards are not removed from the deck as they are drawn. 72 | 73 | # ##################### Hints ##################### 74 | 75 | # #Hint 1: Go to this website and try out the Blackjack game: 76 | # # https://games.washingtonpost.com/games/blackjack/ 77 | # #Then try out the completed Blackjack project here: 78 | # # http://blackjack-final.appbrewery.repl.run 79 | 80 | # #Hint 2: Read this breakdown of program requirements: 81 | # # http://listmoz.com/view/6h34DJpvJBFVRlZfJvxF 82 | # #Then try to create your own flowchart for the program. 83 | 84 | # #Hint 3: Download and read this flow chart I've created: 85 | # # https://drive.google.com/uc?export=download&id=1rDkiHCrhaf9eX7u7yjM1qwSuyEk-rPnt 86 | 87 | # #Hint 4: Create a deal_card() function that uses the List below to *return* a random card. 88 | # #11 is the Ace. 89 | # import random 90 | 91 | 92 | # def deal_card(): 93 | # """Returns a random card from the deck.""" 94 | # cards = [11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10] 95 | # card = random.choice(cards) 96 | # return card 97 | 98 | # #Hint 6: Create a function called calculate_score() that takes a List of cards as input 99 | # #and returns the score. 100 | # #Look up the sum() function to help you do this. 101 | # def calculate_score(cards): 102 | # """Take a list of cards and return the score calculated from the cards""" 103 | 104 | # #Hint 7: Inside calculate_score() check for a blackjack (a hand with only 2 cards: ace + 10) and return 0 instead of the actual score. 0 will represent a blackjack in our game. 105 | # if sum(cards) == 21 and len(cards) == 2: 106 | # return 0 107 | # #Hint 8: Inside calculate_score() check for an 11 (ace). If the score is already over 21, remove the 11 and replace it with a 1. You might need to look up append() and remove(). 108 | # if 11 in cards and sum(cards) > 21: 109 | # cards.remove(11) 110 | # cards.append(1) 111 | # return sum(cards) 112 | 113 | # #Hint 13: Create a function called compare() and pass in the user_score and computer_score. If the computer and user both have the same score, then it's a draw. If the computer has a blackjack (0), then the user loses. If the user has a blackjack (0), then the user wins. If the user_score is over 21, then the user loses. If the computer_score is over 21, then the computer loses. If none of the above, then the player with the highest score wins. 114 | # def compare(user_score, computer_score): 115 | # #Bug fix. If you and the computer are both over, you lose. 116 | # if user_score > 21 and computer_score > 21: 117 | # return "You went over. You lose 😤" 118 | 119 | 120 | # if user_score == computer_score: 121 | # return "Draw 🙃" 122 | # elif computer_score == 0: 123 | # return "Lose, opponent has Blackjack 😱" 124 | # elif user_score == 0: 125 | # return "Win with a Blackjack 😎" 126 | # elif user_score > 21: 127 | # return "You went over. You lose 😭" 128 | # elif computer_score > 21: 129 | # return "Opponent went over. You win 😁" 130 | # elif user_score > computer_score: 131 | # return "You win 😃" 132 | # else: 133 | # return "You lose 😤" 134 | 135 | # def play_game(): 136 | 137 | 138 | 139 | # #Hint 5: Deal the user and computer 2 cards each using deal_card() 140 | # user_cards = [] 141 | # computer_cards = [] 142 | # is_game_over = False 143 | 144 | # for _ in range(2): 145 | # user_cards.append(deal_card()) 146 | # computer_cards.append(deal_card()) 147 | 148 | # #Hint 11: The score will need to be rechecked with every new card drawn and the checks in Hint 9 need to be repeated until the game ends. 149 | 150 | # while not is_game_over: 151 | # #Hint 9: Call calculate_score(). If the computer or the user has a blackjack (0) or if the user's score is over 21, then the game ends. 152 | # user_score = calculate_score(user_cards) 153 | # computer_score = calculate_score(computer_cards) 154 | # print(f" Your cards: {user_cards}, current score: {user_score}") 155 | # print(f" Computer's first card: {computer_cards[0]}") 156 | 157 | # if user_score == 0 or computer_score == 0 or user_score > 21: 158 | # is_game_over = True 159 | # else: 160 | # #Hint 10: If the game has not ended, ask the user if they want to draw another card. If yes, then use the deal_card() function to add another card to the user_cards List. If no, then the game has ended. 161 | # user_should_deal = input("Type 'y' to get another card, type 'n' to pass: ") 162 | # if user_should_deal == "y": 163 | # user_cards.append(deal_card()) 164 | # else: 165 | # is_game_over = True 166 | 167 | # #Hint 12: Once the user is done, it's time to let the computer play. The computer should keep drawing cards as long as it has a score less than 17. 168 | # while computer_score != 0 and computer_score < 17: 169 | # computer_cards.append(deal_card()) 170 | # computer_score = calculate_score(computer_cards) 171 | 172 | # print(f" Your final hand: {user_cards}, final score: {user_score}") 173 | # print(f" Computer's final hand: {computer_cards}, final score: {computer_score}") 174 | # print(compare(user_score, computer_score)) 175 | 176 | # #Hint 14: Ask the user if they want to restart the game. If they answer yes, clear the console and start a new game of blackjack and show the logo from art.py. 177 | # while input("Do you want to play a game of Blackjack? Type 'y' or 'n': ") == "y": 178 | 179 | # play_game() 180 | 181 | 182 | 183 | 184 | -------------------------------------------------------------------------------- /Blackjack/logo.py: -------------------------------------------------------------------------------- 1 | L = """ 2 | .------. _ _ _ _ _ 3 | |A_ _ |. | | | | | | (_) | | 4 | |( \/ ).-----. | |__ | | __ _ ___| | ___ __ _ ___| | __ 5 | | \ /|K /\ | | '_ \| |/ _` |/ __| |/ / |/ _` |/ __| |/ / 6 | | \/ | / \ | | |_) | | (_| | (__| <| | (_| | (__| < 7 | `-----| \ / | |_.__/|_|\__,_|\___|_|\_\ |\__,_|\___|_|\_\\ 8 | | \/ K| _/ | 9 | `------' |__/ 10 | """ 11 | 12 | 13 | -------------------------------------------------------------------------------- /Blackjack/tempCodeRunnerFile.py: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Coffe Machine with OOP/.upm/store.json: -------------------------------------------------------------------------------- 1 | {"version":2,"languages":{"python-python3-poetry":{"guessedImportsHash":"fc77462af5f173e034673cbb5745ee6e"}}} 2 | -------------------------------------------------------------------------------- /Coffe Machine with OOP/__pycache__/coffee_maker.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ranimbenkerri/Python-Programing/b49f5f4471cde826cad5a95afe60e26cde81ab09/Coffe Machine with OOP/__pycache__/coffee_maker.cpython-310.pyc -------------------------------------------------------------------------------- /Coffe Machine with OOP/__pycache__/coffee_maker.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ranimbenkerri/Python-Programing/b49f5f4471cde826cad5a95afe60e26cde81ab09/Coffe Machine with OOP/__pycache__/coffee_maker.cpython-38.pyc -------------------------------------------------------------------------------- /Coffe Machine with OOP/__pycache__/menu.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ranimbenkerri/Python-Programing/b49f5f4471cde826cad5a95afe60e26cde81ab09/Coffe Machine with OOP/__pycache__/menu.cpython-310.pyc -------------------------------------------------------------------------------- /Coffe Machine with OOP/__pycache__/menu.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ranimbenkerri/Python-Programing/b49f5f4471cde826cad5a95afe60e26cde81ab09/Coffe Machine with OOP/__pycache__/menu.cpython-38.pyc -------------------------------------------------------------------------------- /Coffe Machine with OOP/__pycache__/money_machine.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ranimbenkerri/Python-Programing/b49f5f4471cde826cad5a95afe60e26cde81ab09/Coffe Machine with OOP/__pycache__/money_machine.cpython-310.pyc -------------------------------------------------------------------------------- /Coffe Machine with OOP/__pycache__/money_machine.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ranimbenkerri/Python-Programing/b49f5f4471cde826cad5a95afe60e26cde81ab09/Coffe Machine with OOP/__pycache__/money_machine.cpython-38.pyc -------------------------------------------------------------------------------- /Coffe Machine with OOP/coffee_maker.py: -------------------------------------------------------------------------------- 1 | class CoffeeMaker: 2 | """Models the machine that makes the coffee""" 3 | def __init__(self): 4 | self.resources = { 5 | "water": 300, 6 | "milk": 200, 7 | "coffee": 100, 8 | } 9 | 10 | def report(self): 11 | """Prints a report of all resources.""" 12 | print(f"Water: {self.resources['water']}ml") 13 | print(f"Milk: {self.resources['milk']}ml") 14 | print(f"Coffee: {self.resources['coffee']}g") 15 | 16 | def is_resource_sufficient(self, drink): 17 | """Returns True when order can be made, False if ingredients are insufficient.""" 18 | can_make = True 19 | for item in drink.ingredients: 20 | if drink.ingredients[item] > self.resources[item]: 21 | print(f"Sorry there is not enough {item}.") 22 | can_make = False 23 | return can_make 24 | 25 | def make_coffee(self, order): 26 | """Deducts the required ingredients from the resources.""" 27 | for item in order.ingredients: 28 | self.resources[item] -= order.ingredients[item] 29 | print(f"Here is your {order.name} ☕️. Enjoy!") 30 | -------------------------------------------------------------------------------- /Coffe Machine with OOP/main.py: -------------------------------------------------------------------------------- 1 | from menu import Menu, MenuItem 2 | from coffee_maker import CoffeeMaker 3 | from money_machine import MoneyMachine 4 | 5 | menu = Menu() 6 | Coffe = CoffeeMaker() 7 | money = MoneyMachine() 8 | print(money.report()) 9 | 10 | is_on = True 11 | while is_on: 12 | options = menu.get_items() 13 | machine = input(f"what whould you like ? {options} : ").lower() 14 | if machine == 'off': 15 | is_on=False 16 | elif machine == 'report': 17 | Coffe.report() 18 | money.report() 19 | else: 20 | drink=menu.find_drink(machine) 21 | if Coffe.is_resource_sufficient(drink) and money.make_payment(drink.cost) : 22 | Coffe.make_coffee(drink) 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Coffe Machine with OOP/menu.py: -------------------------------------------------------------------------------- 1 | class MenuItem: 2 | """Models each Menu Item.""" 3 | def __init__(self, name, water, milk, coffee, cost): 4 | self.name = name 5 | self.cost = cost 6 | self.ingredients = { 7 | "water": water, 8 | "milk": milk, 9 | "coffee": coffee 10 | } 11 | 12 | 13 | class Menu: 14 | """Models the Menu with drinks.""" 15 | def __init__(self): 16 | self.menu = [ 17 | MenuItem(name="latte", water=200, milk=150, coffee=24, cost=2.5), 18 | MenuItem(name="espresso", water=50, milk=0, coffee=18, cost=1.5), 19 | MenuItem(name="cappuccino", water=250, milk=50, coffee=24, cost=3), 20 | ] 21 | 22 | def get_items(self): 23 | """Returns all the names of the available menu items""" 24 | options = "" 25 | for item in self.menu: 26 | options += f"{item.name}/" 27 | return options 28 | 29 | def find_drink(self, order_name): 30 | """Searches the menu for a particular drink by name. Returns that item if it exists, otherwise returns None""" 31 | for item in self.menu: 32 | if item.name == order_name: 33 | return item 34 | print("Sorry that item is not available.") 35 | -------------------------------------------------------------------------------- /Coffe Machine with OOP/money_machine.py: -------------------------------------------------------------------------------- 1 | class MoneyMachine: 2 | 3 | CURRENCY = "$" 4 | 5 | COIN_VALUES = { 6 | "quarters": 0.25, 7 | "dimes": 0.10, 8 | "nickles": 0.05, 9 | "pennies": 0.01 10 | } 11 | 12 | def __init__(self): 13 | self.profit = 0 14 | self.money_received = 0 15 | 16 | def report(self): 17 | """Prints the current profit""" 18 | print(f"Money: {self.CURRENCY}{self.profit}") 19 | 20 | def process_coins(self): 21 | """Returns the total calculated from coins inserted.""" 22 | print("Please insert coins.") 23 | for coin in self.COIN_VALUES: 24 | self.money_received += int(input(f"How many {coin}?: ")) * self.COIN_VALUES[coin] 25 | return self.money_received 26 | 27 | def make_payment(self, cost): 28 | """Returns True when payment is accepted, or False if insufficient.""" 29 | self.process_coins() 30 | if self.money_received >= cost: 31 | change = round(self.money_received - cost, 2) 32 | print(f"Here is {self.CURRENCY}{change} in change.") 33 | self.profit += cost 34 | self.money_received = 0 35 | return True 36 | else: 37 | print("Sorry that's not enough money. Money refunded.") 38 | self.money_received = 0 39 | return False 40 | 41 | -------------------------------------------------------------------------------- /Coffee Machine/Logo.py: -------------------------------------------------------------------------------- 1 | logo = """ 2 | _____ __ __ __ __ _ _ 3 | / ____| / _|/ _| | \/ | | | (_) 4 | | | ___ | |_| |_ ___ ___ | \ / | __ _ ___| |__ _ _ __ ___ 5 | | | / _ \| _| _/ _ \/ _ \ | |\/| |/ _` |/ __| '_ \| | '_ \ / _ 6 | | |___| (_) | | | || __/ __/ | | | | (_| | (__| | | | | | | | __/ 7 | \_____\___/|_| |_| \___|\___| |_| |_|\__,_|\___|_| |_|_|_| |_|\___| 8 | 9 | """ -------------------------------------------------------------------------------- /Coffee Machine/Untitled-2.clj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ranimbenkerri/Python-Programing/b49f5f4471cde826cad5a95afe60e26cde81ab09/Coffee Machine/Untitled-2.clj -------------------------------------------------------------------------------- /Coffee Machine/__pycache__/Logo.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ranimbenkerri/Python-Programing/b49f5f4471cde826cad5a95afe60e26cde81ab09/Coffee Machine/__pycache__/Logo.cpython-310.pyc -------------------------------------------------------------------------------- /Coffee Machine/cofeemachine.py: -------------------------------------------------------------------------------- 1 | from platform import machine 2 | from tkinter import Menu 3 | from Logo import logo 4 | print(logo) 5 | 6 | MENU = { 7 | "espresso": { 8 | "ingredients": { 9 | "water": 50, 10 | "coffee": 18, 11 | }, 12 | "cost": 1.5, 13 | }, 14 | "latte": { 15 | "ingredients": { 16 | "water": 200, 17 | "milk": 150, 18 | "coffee": 24, 19 | }, 20 | "cost": 2.5, 21 | }, 22 | "cappuccino": { 23 | "ingredients": { 24 | "water": 250, 25 | "milk": 100, 26 | "coffee": 24, 27 | }, 28 | "cost": 3.0, 29 | } 30 | } 31 | profit = 0 32 | resources = { 33 | "water": 300, 34 | "milk": 200, 35 | "coffee": 100, 36 | } 37 | def process_coins(): 38 | print("Please insert coins.") 39 | total = int(input("how many quarters?: ")) * 0.25 40 | total += int(input("how many dimes?: ")) * 0.1 41 | total += int(input("how many nickles?: ")) * 0.05 42 | total += int(input("how many pennies?: ")) * 0.01 43 | return total 44 | 45 | 46 | def make_coffee(drink_name, order_ingredients): 47 | 48 | for item in order_ingredients: 49 | resources[item] -= order_ingredients[item] 50 | 51 | def is_resource_sufficient(order_ingredients): 52 | for item in order_ingredients: 53 | if order_ingredients[item] > resources[item]: 54 | print(f"sorry there is not enough {item}.") 55 | return False 56 | return True 57 | 58 | 59 | def report(): 60 | for i in resources: 61 | print(resources,resources[i]) 62 | 63 | machine = input("what whould you like ? (espresso/latte/cappuccino)").lower() 64 | if machine == 'report': 65 | report() 66 | 67 | drink = MENU[machine] 68 | if machine == 'espresso': 69 | total = process_coins() 70 | if total < 2.5: 71 | print("sorry there is not enough money") 72 | else: 73 | if is_resource_sufficient(drink["ingredients"]) == False: 74 | print("sorry there are no resource") 75 | is_resource_sufficient(drink["ingredients"]) 76 | remaining_money = total - (MENU['espresso']['cost']) 77 | print(f"You remaining money is {remaining_money}") 78 | print("enjoy your milks") 79 | 80 | if machine == 'latte': 81 | total = process_coins() 82 | if total <(MENU['latte']['cost']): 83 | print("sorry there is not enough money") 84 | else: 85 | if is_resource_sufficient(drink["ingredients"]) == False: 86 | print("sorry there are no resource") 87 | remaining_money = total - (MENU['latte']['cost']) 88 | print(f"You remaining money is {remaining_money}") 89 | print("enjoy your milks") 90 | 91 | if machine == 'cappuccino': 92 | total = process_coins(drink["ingredients"]) 93 | if total <(MENU['cappucino']['cost']): 94 | print("sorry there is not enough money") 95 | else: 96 | if is_resource_sufficient(drink["ingredients"]) == False: 97 | print("sorry there are no resource") 98 | is_resource_sufficient(MENU["ingredients"]) 99 | remaining_money = total - (MENU['cappucino']['cost']) 100 | print(f"You remaining money is {remaining_money}") 101 | print("enjoy your milks") 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /Grafics/main.py: -------------------------------------------------------------------------------- 1 | from turtle import Turtle, Screen 2 | 3 | timmy = Turtle() 4 | 5 | 6 | 7 | 8 | 9 | Screen = Screen() 10 | Screen.exitonclick() -------------------------------------------------------------------------------- /Guess a number/game.py: -------------------------------------------------------------------------------- 1 | from random import randint 2 | 3 | 4 | true_number = randint(1, 100) 5 | print(true_number) 6 | easy = 10 7 | hard = 5 8 | 9 | def true(guess, number): 10 | 11 | if guess > number: 12 | return "too high" 13 | elif guess < number: 14 | return "too low" 15 | else: 16 | return "YOU WIN" 17 | 18 | def end_game(q): 19 | q=True 20 | 21 | 22 | print("welcome to the number Guessing Game ") 23 | user = input("choose a difficulty . Type 'easy' or 'hard' : ") 24 | 25 | if user == 'easy': 26 | a = 10 27 | if user == 'hard': 28 | a = 5 29 | 30 | 31 | q = False 32 | 33 | user_number = 0 34 | while user_number != true_number and a>0 : 35 | print(f"you have {int(a)} attempts") 36 | user_number = int(input("Make a guess: ")) 37 | print(true(int(user_number), int(true_number))) 38 | a=a-1 39 | 40 | if user_number != true_number: 41 | print(f"You lose , the right number is {true_number}") -------------------------------------------------------------------------------- /Guess a number/tempCodeRunnerFile.py: -------------------------------------------------------------------------------- 1 | easy = 10 2 | # hard = 5 3 | 4 | 5 | # def true(guess, number): 6 | # if guess > number: 7 | # return "too high" 8 | # elif guess < number: 9 | # return "too low" 10 | # else: 11 | # return "YOU WIN" 12 | 13 | # print("welcome to the nuber Guessing Game ") 14 | # user = input("choose a difficulty . Type 'easy' or 'hard' : ") 15 | 16 | # if user == 'easy': 17 | # print(f"you have {easy} attempts") 18 | # if user == 'hard': 19 | # print(f"you have {hard} attempts") 20 | 21 | 22 | # q = False 23 | # while not q: 24 | # user_number = input("Make a guess: ") -------------------------------------------------------------------------------- /Higher lower/Logo.py: -------------------------------------------------------------------------------- 1 | logo = """ 2 | _ _ _ _ _ 3 | | | | (_) | | | | 4 | | |__| |_ __ _| |__ ___ _ __ | | _____ _____ _ __ 5 | | __ | |/ _` | '_ \ / _ | '__| | | / _ \ \ /\ / / _ | '__| 6 | | | | | | (_| | | | | __| | | |___| (_) \ V V | __| | 7 | |_| |_|_|\__, |_| |_|\___|_| |______\___/ \_/\_/ \___|_| 8 | __/ | 9 | |___/ 10 | 11 | """ 12 | vs = """ 13 | _ _ ___ 14 | ( \/ / __) 15 | \ /\__ | 16 | \/ (___/ 17 | """ -------------------------------------------------------------------------------- /Higher lower/Untitled-1.py: -------------------------------------------------------------------------------- 1 | 2 | from data import data 3 | from Logo import logo, vs 4 | print(logo) 5 | import random 6 | 7 | 8 | def get_random_account(): 9 | return random.choice(data) 10 | 11 | def format_data(account): 12 | 13 | name = account["name"] 14 | description = account["description"] 15 | country = account["country"] 16 | # print(f'{name}: {account["follower_count"]}') 17 | return f"{name}, a {description}, from {country}" 18 | 19 | def check_answer(guess, a_followers, b_followers): 20 | if a_followers > b_followers: 21 | return guess == "a" 22 | else: 23 | return guess == "b" 24 | 25 | 26 | def game(): 27 | print(logo) 28 | score = 0 29 | game_should_continue = True 30 | account_a = get_random_account() 31 | account_b = get_random_account() 32 | 33 | while game_should_continue: 34 | account_a = account_b 35 | account_b = get_random_account() 36 | 37 | while account_a == account_b: 38 | account_b = get_random_account() 39 | 40 | print(f"Compare A: {format_data(account_a)}.") 41 | print(vs) 42 | print(f"Against B: {format_data(account_b)}.") 43 | 44 | guess = input("Who has more followers? Type 'A' or 'B': ").lower() 45 | a_follower_count = account_a["follower_count"] 46 | b_follower_count = account_b["follower_count"] 47 | is_correct = check_answer(guess, a_follower_count, b_follower_count) 48 | 49 | 50 | print(logo) 51 | if is_correct: 52 | score += 1 53 | print(f"You're right! Current score: {score}.") 54 | else: 55 | game_should_continue = False 56 | print(f"Sorry, that's wrong. Final score: {score}") 57 | 58 | game() 59 | -------------------------------------------------------------------------------- /Higher lower/__pycache__/Logo.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ranimbenkerri/Python-Programing/b49f5f4471cde826cad5a95afe60e26cde81ab09/Higher lower/__pycache__/Logo.cpython-310.pyc -------------------------------------------------------------------------------- /Higher lower/__pycache__/data.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ranimbenkerri/Python-Programing/b49f5f4471cde826cad5a95afe60e26cde81ab09/Higher lower/__pycache__/data.cpython-310.pyc -------------------------------------------------------------------------------- /Higher lower/data.py: -------------------------------------------------------------------------------- 1 | data = [ 2 | {'name':'Ranim', 3 | 'follower_count':500, 4 | 'description': 'Chikour', 5 | 'country': 'Algeria' 6 | 7 | 8 | }, 9 | { 10 | 'name': 'Instagram', 11 | 'follower_count': 346, 12 | 'description': 'Social media platform', 13 | 'country': 'United States' 14 | }, 15 | { 16 | 'name': 'Cristiano Ronaldo', 17 | 'follower_count': 215, 18 | 'description': 'Footballer', 19 | 'country': 'Portugal' 20 | }, 21 | { 22 | 'name': 'Ariana Grande', 23 | 'follower_count': 183, 24 | 'description': 'Musician and actress', 25 | 'country': 'United States' 26 | }, 27 | { 28 | 'name': 'Dwayne Johnson', 29 | 'follower_count': 181, 30 | 'description': 'Actor and professional wrestler', 31 | 'country': 'United States' 32 | }, 33 | { 34 | 'name': 'Selena Gomez', 35 | 'follower_count': 174, 36 | 'description': 'Musician and actress', 37 | 'country': 'United States' 38 | }, 39 | { 40 | 'name': 'Kylie Jenner', 41 | 'follower_count': 172, 42 | 'description': 'Reality TV personality and businesswoman and Self-Made Billionaire', 43 | 'country': 'United States' 44 | }, 45 | { 46 | 'name': 'Kim Kardashian', 47 | 'follower_count': 167, 48 | 'description': 'Reality TV personality and businesswoman', 49 | 'country': 'United States' 50 | }, 51 | { 52 | 'name': 'Lionel Messi', 53 | 'follower_count': 149, 54 | 'description': 'Footballer', 55 | 'country': 'Argentina' 56 | }, 57 | { 58 | 'name': 'Beyoncé', 59 | 'follower_count': 145, 60 | 'description': 'Musician', 61 | 'country': 'United States' 62 | }, 63 | { 64 | 'name': 'Neymar', 65 | 'follower_count': 138, 66 | 'description': 'Footballer', 67 | 'country': 'Brasil' 68 | }, 69 | { 70 | 'name': 'National Geographic', 71 | 'follower_count': 135, 72 | 'description': 'Magazine', 73 | 'country': 'United States' 74 | }, 75 | { 76 | 'name': 'Justin Bieber', 77 | 'follower_count': 133, 78 | 'description': 'Musician', 79 | 'country': 'Canada' 80 | }, 81 | { 82 | 'name': 'Taylor Swift', 83 | 'follower_count': 131, 84 | 'description': 'Musician', 85 | 'country': 'United States' 86 | }, 87 | { 88 | 'name': 'Kendall Jenner', 89 | 'follower_count': 127, 90 | 'description': 'Reality TV personality and Model', 91 | 'country': 'United States' 92 | }, 93 | { 94 | 'name': 'Jennifer Lopez', 95 | 'follower_count': 119, 96 | 'description': 'Musician and actress', 97 | 'country': 'United States' 98 | }, 99 | { 100 | 'name': 'Nicki Minaj', 101 | 'follower_count': 113, 102 | 'description': 'Musician', 103 | 'country': 'Trinidad and Tobago' 104 | }, 105 | { 106 | 'name': 'Nike', 107 | 'follower_count': 109, 108 | 'description': 'Sportswear multinational', 109 | 'country': 'United States' 110 | }, 111 | { 112 | 'name': 'Khloé Kardashian', 113 | 'follower_count': 108, 114 | 'description': 'Reality TV personality and businesswoman', 115 | 'country': 'United States' 116 | }, 117 | { 118 | 'name': 'Miley Cyrus', 119 | 'follower_count': 107, 120 | 'description': 'Musician and actress', 121 | 'country': 'United States' 122 | }, 123 | { 124 | 'name': 'Katy Perry', 125 | 'follower_count': 94, 126 | 'description': 'Musician', 127 | 'country': 'United States' 128 | }, 129 | { 130 | 'name': 'Kourtney Kardashian', 131 | 'follower_count': 90, 132 | 'description': 'Reality TV personality', 133 | 'country': 'United States' 134 | }, 135 | { 136 | 'name': 'Kevin Hart', 137 | 'follower_count': 89, 138 | 'description': 'Comedian and actor', 139 | 'country': 'United States' 140 | }, 141 | { 142 | 'name': 'Ellen DeGeneres', 143 | 'follower_count': 87, 144 | 'description': 'Comedian', 145 | 'country': 'United States' 146 | }, 147 | { 148 | 'name': 'Real Madrid CF', 149 | 'follower_count': 86, 150 | 'description': 'Football club', 151 | 'country': 'Spain' 152 | }, 153 | { 154 | 'name': 'FC Barcelona', 155 | 'follower_count': 85, 156 | 'description': 'Football club', 157 | 'country': 'Spain' 158 | }, 159 | { 160 | 'name': 'Rihanna', 161 | 'follower_count': 81, 162 | 'description': 'Musician and businesswoman', 163 | 'country': 'Barbados' 164 | }, 165 | { 166 | 'name': 'Demi Lovato', 167 | 'follower_count': 80, 168 | 'description': 'Musician and actress', 169 | 'country': 'United States' 170 | }, 171 | { 172 | 'name': "Victoria's Secret", 173 | 'follower_count': 69, 174 | 'description': 'Lingerie brand', 175 | 'country': 'United States' 176 | }, 177 | { 178 | 'name': 'Zendaya', 179 | 'follower_count': 68, 180 | 'description': 'Actress and musician', 181 | 'country': 'United States' 182 | }, 183 | { 184 | 'name': 'Shakira', 185 | 'follower_count': 66, 186 | 'description': 'Musician', 187 | 'country': 'Colombia' 188 | }, 189 | { 190 | 'name': 'Drake', 191 | 'follower_count': 65, 192 | 'description': 'Musician', 193 | 'country': 'Canada' 194 | }, 195 | { 196 | 'name': 'Chris Brown', 197 | 'follower_count': 64, 198 | 'description': 'Musician', 199 | 'country': 'United States' 200 | }, 201 | { 202 | 'name': 'LeBron James', 203 | 'follower_count': 63, 204 | 'description': 'Basketball player', 205 | 'country': 'United States' 206 | }, 207 | { 208 | 'name': 'Vin Diesel', 209 | 'follower_count': 62, 210 | 'description': 'Actor', 211 | 'country': 'United States' 212 | }, 213 | { 214 | 'name': 'Cardi B', 215 | 'follower_count': 67, 216 | 'description': 'Musician', 217 | 'country': 'United States' 218 | }, 219 | { 220 | 'name': 'David Beckham', 221 | 'follower_count': 82, 222 | 'description': 'Footballer', 223 | 'country': 'United Kingdom' 224 | }, 225 | { 226 | 'name': 'Billie Eilish', 227 | 'follower_count': 61, 228 | 'description': 'Musician', 229 | 'country': 'United States' 230 | }, 231 | { 232 | 'name': 'Justin Timberlake', 233 | 'follower_count': 59, 234 | 'description': 'Musician and actor', 235 | 'country': 'United States' 236 | }, 237 | { 238 | 'name': 'UEFA Champions League', 239 | 'follower_count': 58, 240 | 'description': 'Club football competition', 241 | 'country': 'Europe' 242 | }, 243 | { 244 | 'name': 'NASA', 245 | 'follower_count': 56, 246 | 'description': 'Space agency', 247 | 'country': 'United States' 248 | }, 249 | { 250 | 'name': 'Emma Watson', 251 | 'follower_count': 56, 252 | 'description': 'Actress', 253 | 'country': 'United Kingdom' 254 | }, 255 | { 256 | 'name': 'Shawn Mendes', 257 | 'follower_count': 57, 258 | 'description': 'Musician', 259 | 'country': 'Canada' 260 | }, 261 | { 262 | 'name': 'Virat Kohli', 263 | 'follower_count': 55, 264 | 'description': 'Cricketer', 265 | 'country': 'India' 266 | }, 267 | { 268 | 'name': 'Gigi Hadid', 269 | 'follower_count': 54, 270 | 'description': 'Model', 271 | 'country': 'United States' 272 | }, 273 | { 274 | 'name': 'Priyanka Chopra Jonas', 275 | 'follower_count': 53, 276 | 'description': 'Actress and musician', 277 | 'country': 'India' 278 | }, 279 | { 280 | 'name': '9GAG', 281 | 'follower_count': 52, 282 | 'description': 'Social media platform', 283 | 'country': 'China' 284 | }, 285 | { 286 | 'name': 'Ronaldinho', 287 | 'follower_count': 51, 288 | 'description': 'Footballer', 289 | 'country': 'Brasil' 290 | }, 291 | { 292 | 'name': 'Maluma', 293 | 'follower_count': 50, 294 | 'description': 'Musician', 295 | 'country': 'Colombia' 296 | }, 297 | { 298 | 'name': 'Camila Cabello', 299 | 'follower_count': 49, 300 | 'description': 'Musician', 301 | 'country': 'Cuba' 302 | }, 303 | { 304 | 'name': 'NBA', 305 | 'follower_count': 47, 306 | 'description': 'Club Basketball Competition', 307 | 'country': 'United States' 308 | } 309 | ] -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Python-Programing 2 | Small project using python. 3 | -------------------------------------------------------------------------------- /Rock paper scissors/paper: -------------------------------------------------------------------------------- 1 | 2 | import random 3 | user = int(input("what do you choose ? 0 for Rock 1 for paper 2 for scissors\n")) 4 | game = ["Rock","Paper","Scissors"] 5 | if user > 2: 6 | print("You typed an invalide numbre!") 7 | print(f"you choose {game[user]}") 8 | print("-------------------------------------------------------") 9 | r=int(random.randint(0,2)) 10 | print(f"computer choose {game[r]}") 11 | print("-------------------------------------------------------") 12 | if user==0 and r==2: 13 | print("you win") 14 | elif user100: 12 | print("your love score is %",perc,", you go together like ..") 13 | if perc>=80 : 14 | print("your love score is %",perc,", you go together like coca colla and mentos") 15 | 16 | elif perc<80 and perc>40 : 17 | print("your love score is %",perc,", you go alright together") 18 | 19 | else : 20 | print("your love score is %",perc,",They don't really like u sorry mate") 21 | 22 | 23 | -------------------------------------------------------------------------------- /buzz fizz/test.py: -------------------------------------------------------------------------------- 1 | # score = input("entre student score :").split() 2 | 3 | # for n in range(0, len(score)): 4 | # score[n]=int(score[n]) 5 | # print(score) 6 | # highest_score=score[0] 7 | # for a in score: 8 | # if a < highest_score: 9 | # a = highest_score 10 | # print(f"the highest score is : {a}") 11 | #range(a, b, step) 12 | ########################################################## 13 | s=0 14 | for i in range(1, 101): 15 | if(i%2==0): 16 | s=s+i 17 | 18 | print(s) 19 | for i in range(1, 101): 20 | 21 | if(i%15==0): 22 | print("buzz fizz") 23 | elif(i%5==0): 24 | print("buzz") 25 | elif(i%3==0): 26 | print("fizz") 27 | else: 28 | print(i) -------------------------------------------------------------------------------- /caesar cipher/__pycache__/logo.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ranimbenkerri/Python-Programing/b49f5f4471cde826cad5a95afe60e26cde81ab09/caesar cipher/__pycache__/logo.cpython-310.pyc -------------------------------------------------------------------------------- /caesar cipher/code.py: -------------------------------------------------------------------------------- 1 | from ast import AugAssign 2 | from turtle import goto 3 | from logo import Logo 4 | print(Logo) 5 | def cesar(t, s, d): 6 | if d=='encode': 7 | cipher_text="" 8 | for letter in t: 9 | if letter in abc: 10 | position = abc.index(letter) 11 | new = position + s 12 | new=new%26 13 | cipher_text+=abc[new] 14 | if letter not in abc: 15 | cipher_text+=letter 16 | print(f"the new word is : {cipher_text}") 17 | if d=='decode': 18 | cipher_text="" 19 | for letter in t: 20 | position = abc.index(letter) 21 | new = position - s 22 | new_letter= abc[new] 23 | cipher_text+=new_letter 24 | print(f"the new word is : {cipher_text}") 25 | 26 | user_countinue= True 27 | while user_countinue: 28 | abc=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"] 29 | direction = input("type 'encode' to encrypt, type 'decode' for decrypt : ") 30 | text = input("\n type ur text : ").lower() 31 | shift = int(input("\n Type the shift number : ")) 32 | shift = shift % 26 33 | cesar(t=text, d=direction, s= shift) 34 | 35 | user = input("type 'yes' if u wnat to go again,Otherwide type 'no'") 36 | if user == 'no': 37 | user_countinue= False 38 | print("Goodbye") 39 | if user == 'yes': 40 | user_countinue=True 41 | 42 | 43 | -------------------------------------------------------------------------------- /caesar cipher/logo.py: -------------------------------------------------------------------------------- 1 | Logo=""" .__ .__ 2 | ____ _____ ____ ___________ _______ ____ |__|_____ | |__ ___________ 3 | _/ ___|__ \ _/ __ \ / ___/\__ |\_ __ \ _/ ___\| \____ \| | \_/ __ \_ __ | 4 | \ \___ / __ \/ ___/ \___ \ / __ \| | \/ \ \___| | |_> > Y \ ___/| | \/ 5 | \___ >____ /\___ >____ >(____ /__| \___ >__| __/|___| /\___ >__| 6 | \/ \/ \/ \/ \/ \/ |__| \/ \/ """ -------------------------------------------------------------------------------- /calculator/calculator.py: -------------------------------------------------------------------------------- 1 | def add(x ,y): 2 | return x + y 3 | def sub(x ,y): 4 | return x - y 5 | def mult(x ,y): 6 | return x * y 7 | def div(x ,y): 8 | return x / y 9 | def calculation(): 10 | first_number = int(input("enter the first number : ")) 11 | result = 0 12 | cont = True 13 | op = { 14 | "+":add, 15 | "-":sub, 16 | "*":mult, 17 | "/":div 18 | } 19 | while(cont == True ): 20 | for n in op: 21 | print(n) 22 | operation = input("pikc the next operation : ") 23 | num2 = int(input("enter the next number : ")) 24 | calculation = op[operation] 25 | result = calculation(first_number, num2) 26 | print(result) 27 | next = input(f"enter'y' if u want to continue with {result}, or 'n' if u don't : ") 28 | if next == "y": 29 | first_number = result 30 | else: 31 | cont = False 32 | 33 | calculation() 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /day16/main.py: -------------------------------------------------------------------------------- 1 | from turtle import Turtle, Screen 2 | my_screen = Screen() 3 | print(my_screen.canvheight) 4 | my_screen.exitonclick() 5 | 6 | from prettytable import PrettyTable 7 | x = PrettyTable() 8 | x.add_column("prof",["Khalfone","Kharbachi","Samiha Ait taleb"]) 9 | x.add_column("module",["analyse","algebre","Archi"]) 10 | print(x) -------------------------------------------------------------------------------- /password generator/pswrd.py: -------------------------------------------------------------------------------- 1 | import random 2 | abc=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"] 3 | s =["$","@","&","(",")"] 4 | n =["1","2","3","4","5","6","7","8","9"] 5 | pswrd=[] 6 | lettres = int(input("how many lettres would you like in ur password? ")) 7 | for char in range(1, lettres+1): 8 | pswrd+=random.choice(abc) 9 | 10 | symbol = int(input("symbols? ")) 11 | for char in range(1, symbol+1): 12 | pswrd+= random.choice(s) 13 | 14 | numbres = int(input("numbres? ")) 15 | for char in range(1, numbres+1): 16 | pswrd+=random.choice(n) 17 | random.shuffle(pswrd) 18 | p="" 19 | for char in pswrd: 20 | p=p+char 21 | print(p) --------------------------------------------------------------------------------