├── .gitattributes ├── .gitignore ├── 001-Band Name Generator ├── README.md └── code.py ├── 002-Love Calculator ├── README.md └── code.py ├── 003-Tip Calculator ├── README.md └── code.py ├── 004-Treasure Island Adventure ├── README.md └── code.py ├── 005-Rock Paper Scissors ├── README.md └── code.py ├── 006-Password Generator ├── README.md ├── code1.py └── code2.py ├── 007-Escaping the Maze ├── README.md ├── code1.py └── code2.py ├── 008-Hangman ├── Animal_Names.py ├── Ascii_Art.py ├── README.md └── code.py ├── 009-Caesar Cipher ├── Ascii_Art.py ├── BasicHelper.py ├── Challenger.py ├── Moderator.py └── README.md ├── 010-Secret Auction ├── Ascii_Art.py ├── README.md └── code.py ├── 011-Calculator ├── Ascii_Art.py ├── README.md └── code.py ├── 012-BlackJack ├── Ascii_Art.py ├── README.md └── code.py ├── 013-Make a Guess ├── Ascii_Art.py ├── README.md └── code.py ├── 014-Instagram Followers Game ├── Ascii_Art.py ├── Data.py ├── README.md └── code.py ├── 015-Coffee Machine ├── data.py ├── mycode.py └── solution_code.py ├── 016-Coffee Machine using OOP ├── coffee_maker.py ├── main.py ├── menu.py └── money_machine.py ├── 017-Quiz Game ├── data.py ├── main.py ├── question_model.py └── quiz_brain.py ├── LICENSE ├── Python Libraries ├── PrettyTable.py └── Turtle_Star.py ├── Python Programming └── Python Learning NOTES.docx ├── README.md └── Tools.md /.gitattributes: -------------------------------------------------------------------------------- 1 | # Set Python files to be treated as text 2 | *.py text 3 | 4 | # Set line ending normalization for text files 5 | * text=auto 6 | 7 | # Specify merge strategy for specific files 8 | *.txt merge=union 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | _pycache_/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | lib/ 17 | lib64/ 18 | parts/ 19 | sdist/ 20 | var/ 21 | wheels/ 22 | *.egg-info/ 23 | .installed.cfg 24 | *.egg 25 | MANIFEST 26 | 27 | # IDEs 28 | .idea/ 29 | .vscode/ 30 | *.sublime-project 31 | *.sublime-workspace 32 | 33 | # Environment 34 | .env 35 | .venv 36 | env/ 37 | venv/ 38 | ENV/ 39 | 40 | # Compiled Python files 41 | *.pyc 42 | 43 | # Miscellaneous 44 | *.bak 45 | *.swp -------------------------------------------------------------------------------- /001-Band Name Generator/README.md: -------------------------------------------------------------------------------- 1 | # Band Name Generator 2 | 3 | ## Overview 4 | 5 | This Python script generates a band name by combining the user's city of origin and the name of their pet. 6 | 7 | ## Topics Covered 8 | 9 | 1. **Creating a Greeting** 10 | - *Description*: The code starts with a welcome message for the band name generator. 11 | - 12 | ```python 13 | print("Welcome to the Band Name Generator.") 14 | ``` 15 | 16 | 2. **User Input** 17 | - *Description*: The code prompts the user to input the city they grew up in and the name of their pet. 18 | - 19 | ```python 20 | city = input("Which City did you grow up in?\n") 21 | pet = input("What is the name of your pet?\n") 22 | ``` 23 | 24 | 3. **Combining Inputs (Concatenation)** 25 | - *Description*: The code concatenates the city and pet inputs to generate the band name. 26 | - 27 | ```python 28 | band_name = city + " " + pet 29 | ``` 30 | 31 | 4. **Output** 32 | - *Description*: The code prints the generated band name as output. 33 | - 34 | ```python 35 | print("Your Band Name could be", band_name) 36 | ``` 37 | 38 | -------------------------------------------------------------------------------- /001-Band Name Generator/code.py: -------------------------------------------------------------------------------- 1 | #Creating a Greeting for the program. 2 | print("Welcome to the Band Name Genertor.") 3 | #Ask the user for the city that they grew up in. 4 | city = input("Which City did you grow up in?\n") 5 | #Ask the user for the name of their Pet. 6 | pet = input("What is the name of your pet?\n") 7 | #Combine the city and the pet to generate the Band Name. 8 | band_name = city + " " + pet 9 | #Now return the Band Name. 10 | print("Your Band Name could be",band_name) 11 | -------------------------------------------------------------------------------- /002-Love Calculator/README.md: -------------------------------------------------------------------------------- 1 | # Love Calculator 2 | 3 | ## Overview 4 | 5 | This Python code calculates a "love score" based on the names provided by the user, combining them, converting to lowercase, and counting specific letters to determine the score. It then prints a message based on the score. 6 | 7 | ## Topics Covered 8 | 9 | 1. **Count Function** 10 | - *Description*: The code uses the `count()` function to count occurrences of specific letters in the combined names. 11 | 12 | 2. **Conditional Statements (if, elif, else)** 13 | - *Description*: The code evaluates the love score and prints a corresponding message based on different conditions. 14 | 15 | ## Example from the Code 16 | 17 | ```python 18 | # Count Function 19 | tcount = checking_word.count("t") 20 | 21 | # Conditional Statements (if, elif, else) 22 | if int_total < 10 or int_total > 90: 23 | print(f"Your score is {int_total}, you go together like coke and mentos.") 24 | elif int_total > 40 and int_total < 50: 25 | print(f"Your score is {int_total}, you are alright together.") 26 | else: 27 | print(f"Your score is {int_total}.") 28 | -------------------------------------------------------------------------------- /002-Love Calculator/code.py: -------------------------------------------------------------------------------- 1 | name1 = input("Enter boy name: ") # What is your name? 2 | name2 = input("Enter girl name: ") # What is their name? 3 | #Concatenating the names. 4 | checking_word = name1 + name2 5 | 6 | #Converting into the lowercase letters. 7 | checking_word = checking_word.lower() 8 | 9 | true_count = 0 10 | 11 | #TRUE Checking. 12 | tcount = checking_word.count("t") 13 | rcount = checking_word.count("r") 14 | ucount = checking_word.count("u") 15 | ecount = checking_word.count("e") 16 | total_true_count = tcount + rcount + ucount + ecount 17 | 18 | 19 | #LOVE Checking. 20 | lcount = checking_word.count("l") 21 | ocount = checking_word.count("o") 22 | vcount = checking_word.count("v") 23 | total_love_count = lcount + ocount + vcount + ecount 24 | 25 | #Concatenating the count of 2 words i.e TRUE, lOVE. 26 | Total =str(total_true_count) + str(total_love_count) 27 | int_total = int(Total) 28 | 29 | 30 | #As per the given conditions printing the results. 31 | print("The Love Calculator is calculating your score...") 32 | if int_total < 10 or int_total > 90: 33 | print(f"Your score is {int_total}, you go together like coke and mentos.") 34 | elif int_total > 40 and int_total < 50: 35 | print(f"Your score is {int_total}, you are alright together.") 36 | else: 37 | print(f"Your score is {int_total}.") -------------------------------------------------------------------------------- /003-Tip Calculator/README.md: -------------------------------------------------------------------------------- 1 | # Tip Calculator 2 | 3 | ## Overview 4 | 5 | This Python script calculates the total bill with tip and evenly distributes the cost among a specified number of people. Users input the total bill amount, desired tip percentage, and the number of people splitting the bill. 6 | 7 | ## Topics Covered 8 | 9 | 1. **Input Handling** 10 | - *Description*: User input is gathered using the `input()` function for the total bill, tip percentage, and the number of people. 11 | - *Example*: 12 | ```python 13 | bill_without_tip = float(input("What was the total bill? ")) 14 | ``` 15 | 16 | 2. **Arithmetic Operations** 17 | - *Description*: Basic arithmetic operations are used to calculate the tip, total bill with tip, and the evenly distributed cost among the group. 18 | - 19 | ```python 20 | tip = (bill_without_tip * tip_in_percentage) / 100 21 | ``` 22 | 23 | 3. **String Formatting** 24 | - *Description*: String formatting, specifically f-strings, is employed to present the final output in a readable and formatted manner. 25 | - 26 | ```python 27 | print(f"Each person should pay: {final_distribution_formatted}") 28 | ``` 29 | 30 | 4. **Type Casting** 31 | - *Description*: Type casting is used to convert user input from strings to appropriate data types, such as converting input to float or int. 32 | - 33 | ```python 34 | tip_in_percentage = int(input("How much tip would you like to give? 10, 12, or 15? ")) 35 | ``` 36 | 37 | -------------------------------------------------------------------------------- /003-Tip Calculator/code.py: -------------------------------------------------------------------------------- 1 | print("Welcome to the Tip Calculator") 2 | 3 | #Asking user to enter total bill, tip in percentage, members. 4 | bill_without_tip = float(input("What was the total bill? ")) # 150 5 | tip_in_percentage = int(input("How much tip would you like to give? 10, 12, or 15? ")) # 12 6 | members = int(input("How many people to split the bill? ")) # 5 7 | 8 | #Calculates the Tip 9 | tip = (bill_without_tip * tip_in_percentage) / 100 10 | bill_with_tip = bill_without_tip + tip 11 | group_split = bill_with_tip / members 12 | 13 | # This makes the resultant number to format upto 2 decimal points 14 | final_distribution_formatted = "{:.2f}".format(group_split) 15 | print(f"Each person should pay: {final_distribution_formatted}") 16 | -------------------------------------------------------------------------------- /004-Treasure Island Adventure/README.md: -------------------------------------------------------------------------------- 1 | # Treasure Island Adventure 2 | 3 | ## Overview 4 | 5 | This Python code guides the user through an adventure on Treasure Island, where they make decisions to reach the treasure. 6 | 7 | ## Topics Covered (If, else, elif) 8 | 9 | 1. **Displaying ASCII Art** 10 | - *Description*: The code prints ASCII art representing a decorative header for the game. 11 | - ```python 12 | print(''' 13 | ******************************************************************************* 14 | | | | | 15 | _________|________________.=""_;=.______________|_____________________|_______ 16 | | | ,-"_,="" `"=.| | 17 | |___________________|__"=._o`"-._ `"=.______________|___________________ 18 | | `"=._o`"=._ _`"=._ | 19 | _________|_____________________:=._o "=._."_.-="'"=.__________________|_______ 20 | | | __.--" , ; `"=._o." ,-"""-._ ". | 21 | |___________________|_._" ,. .` ` `` , `"-._"-._ ". '__|___________________ 22 | | |o`"=._` , "` `; .". , "-._"-._; ; | 23 | _________|___________| ;`-.o`"=._; ." ` '`."\` . "-._ /_______________|_______ 24 | | | |o; `"-.o`"=._`` '` " ,__.--o; | 25 | |___________________|_| ; (#) `-.o `"=.`_.--"_o.-; ;___|___________________ 26 | ____/______/______/___|o;._ " `".o|o_.--" ;o;____/______/______/____ 27 | /______/______/______/_"=._o--._ ; | ; ; ;/______/______/______/_ 28 | ____/______/______/______/__"=._o--._ ;o|o; _._;o;____/______/______/____ 29 | /______/______/______/______/____"=._o._; | ;_.--"o.--"_/______/______/______/_ 30 | ____/______/______/______/______/_____"=.o|o_.--""___/______/______/______/____ 31 | /______/______/______/______/______/______/______/______/______/______/_____ / 32 | ******************************************************************************* 33 | ''') 34 | ``` 35 | 36 | 2. **Welcoming Message** 37 | - *Description*: The code displays a welcoming message for the user. 38 | - ```python 39 | print("Welcome to Treasure Island.") 40 | ``` 41 | 42 | 3. **Mission Overview** 43 | - *Description*: The code provides an overview of the user's mission. 44 | - ```python 45 | print("Your mission is to find the treasure.") 46 | ``` 47 | 48 | 4. **Choosing Direction** 49 | - *Description*: The code prompts the user to choose a direction (left or right) at the crossroad. 50 | - ```python 51 | print("You are at a Cross Road. Where do you want to go Left or Right? ") 52 | decision1 = input().lower() 53 | ``` 54 | 55 | 5. **Handling Left Path** 56 | - *Description*: The code guides the user through the left path decision. 57 | - ```python 58 | if decision1 == "left": 59 | # Code for handling the left path decision 60 | ``` 61 | 62 | 6. **Handling Right Path** 63 | - *Description*: The code guides the user through the right path decision. 64 | - ```python 65 | else: 66 | # Code for handling the right path decision 67 | ``` 68 | 69 | 7. **Handling Boat Decision** 70 | - *Description*: The code guides the user through the decision to take a boat. 71 | - ```python 72 | if decision2 == "boat": 73 | # Code for handling the decision to take a boat 74 | ``` 75 | 76 | 8. **Handling Rocky Path Decision** 77 | - *Description*: The code guides the user through the decision to take the rocky path. 78 | - ```python 79 | if decision3 == "rocky": 80 | # Code for handling the decision to take the rocky path 81 | ``` 82 | 83 | 9. **Handling House Door Decision** 84 | - *Description*: The code guides the user through the decision of choosing a door in the house. 85 | - ```python 86 | if decision4 == "yellow": 87 | # Code for handling the decision of choosing the yellow door 88 | elif decision4 == "red": 89 | # Code for handling the decision of choosing the red door 90 | elif decision4 == "blue": 91 | # Code for handling the decision of choosing the blue door 92 | else: 93 | # Default case 94 | ``` 95 | -------------------------------------------------------------------------------- /004-Treasure Island Adventure/code.py: -------------------------------------------------------------------------------- 1 | print(''' 2 | ******************************************************************************* 3 | | | | | 4 | _________|________________.=""_;=.______________|_____________________|_______ 5 | | | ,-"_,="" `"=.| | 6 | |___________________|__"=._o`"-._ `"=.______________|___________________ 7 | | `"=._o`"=._ _`"=._ | 8 | _________|_____________________:=._o "=._."_.-="'"=.__________________|_______ 9 | | | __.--" , ; `"=._o." ,-"""-._ ". | 10 | |___________________|_._" ,. .` ` `` , `"-._"-._ ". '__|___________________ 11 | | |o`"=._` , "` `; .". , "-._"-._; ; | 12 | _________|___________| ;`-.o`"=._; ." ` '`."\` . "-._ /_______________|_______ 13 | | | |o; `"-.o`"=._`` '` " ,__.--o; | 14 | |___________________|_| ; (#) `-.o `"=.`_.--"_o.-; ;___|___________________ 15 | ____/______/______/___|o;._ " `".o|o_.--" ;o;____/______/______/____ 16 | /______/______/______/_"=._o--._ ; | ; ; ;/______/______/______/_ 17 | ____/______/______/______/__"=._o--._ ;o|o; _._;o;____/______/______/____ 18 | /______/______/______/______/____"=._o._; | ;_.--"o.--"_/______/______/______/_ 19 | ____/______/______/______/______/_____"=.o|o_.--""___/______/______/______/____ 20 | /______/______/______/______/______/______/______/______/______/______/_____ / 21 | ******************************************************************************* 22 | ''') 23 | print("Welcome to Treasure Island.") 24 | print("Your mission is to find the treasure.") 25 | print("You are at a Cross Road. Where do you want to go Left or Right? ") 26 | decision1 = input() 27 | decision1 = decision1.lower() 28 | 29 | if decision1 == "left": 30 | print("You came to a lake. There is an island in the middle of the lake. Do you want to wait for a boat or swim?") 31 | decision2 = input() 32 | decision2 = decision2.lower() 33 | 34 | if decision2 == "boat": 35 | print("You arrived at the island safely.\nThere is a mountain. Which path do you prefer for climbing the mountain: rocky or grassy?") 36 | decision3 = input() 37 | decision3 = decision3.lower() 38 | 39 | if decision3 == "rocky": 40 | print("You successfully reached the top of the mountain.\nThere is a house with 3 doors: one red, one blue, one yellow. Which one do you choose? ") 41 | decision4 = input() 42 | decision4 = decision4.lower() 43 | 44 | if decision4 == "yellow": 45 | print("Congratulations. You won the match!") 46 | elif decision4 == "red": 47 | print("'Burned by Fire'. Game Over!") 48 | elif decision4 == "blue": 49 | print("'Eaten by Beasts'. Game Over!") 50 | else: 51 | print("Game Over") 52 | 53 | else: 54 | print("'You encountered a snake'. Game Over!") 55 | 56 | else: 57 | print("'Attacked by Crocodile'. Game Over!") 58 | 59 | else: 60 | print("'Fall in a Hole'. Game Over") 61 | -------------------------------------------------------------------------------- /005-Rock Paper Scissors/README.md: -------------------------------------------------------------------------------- 1 | # Rock Paper Scissors Game 2 | 3 | ## Overview 4 | 5 | This Python code simulates a game of Rock, Paper, Scissors where the user competes against the computer. 6 | 7 | ## Topics Covered 8 | 9 | 1. **User Input and Display** 10 | - *Description*: Prompting the user to choose Rock, Paper, or Scissors and displaying their choice. 11 | ```python 12 | print("What do you choose? Print 0 for Rock, 1 for Paper, 2 for Scissors.") 13 | user_input = int(input()) 14 | print(game_images[user_input]) 15 | ``` 16 | 17 | 2. **Check for Valid Input** 18 | - *Description*: Ensuring the user's input is within the valid range. 19 | ```python 20 | if user_input >= 3: 21 | print("You typed an invalid number. You Lose!") 22 | ``` 23 | 24 | 3. **Generate Computer's Choice and Display** 25 | - *Description*: Randomly selecting Rock, Paper, or Scissors for the computer and displaying its choice. 26 | ```python 27 | computer_input = random.randint(0, 2) 28 | print(game_images[computer_input]) 29 | ``` 30 | 31 | 4. **Main Logic - Decision Making** 32 | - *Description*: Determining the outcome of the game based on the choices made by the user and the computer. 33 | ```python 34 | if (user_input == 0 and computer_input == 2) or (user_input == 1 and computer_input == 0) or (user_input == 2 and computer_input == 1): 35 | print("You Won") 36 | elif user_input == computer_input: 37 | print("Draw") 38 | else: 39 | print("You Lose") 40 | ``` 41 | 42 | -------------------------------------------------------------------------------- /005-Rock Paper Scissors/code.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | #ASCII Art 4 | rock = ''' 5 | _______ 6 | ---' ____) 7 | (_____) 8 | (_____) 9 | (____) 10 | ---.__(___) 11 | ''' 12 | paper = ''' 13 | _______ 14 | ---' ____)____ 15 | ______) 16 | _______) 17 | _______) 18 | ---.__________) 19 | ''' 20 | scissors = ''' 21 | _______ 22 | ---' ____)____ 23 | ______) 24 | __________) 25 | (____) 26 | ---.__(___) 27 | ''' 28 | 29 | game_images = [rock, paper, scissors] 30 | print("What do you choose print 0 for Rock, 1 for Paper, 2 for Scissors.") 31 | 32 | user_input = int(input()) 33 | 34 | #Displays User's choice. 35 | print(game_images[user_input]) 36 | 37 | #Check is the User's input is valid. 38 | if user_input >= 3: 39 | print("You typed an invalid number.You Lose!") 40 | 41 | #Generate Computers Choice. 42 | computer_input = random.randint(0,2) 43 | 44 | #Display computers's choice. 45 | print(game_images[computer_input]) 46 | 47 | #Main Logic - Decision making. 48 | if (user_input == 0 and computer_input == 2) or (user_input == 1 and computer_input == 0)or (user_input == 2 and computer_input == 1): 49 | print("You Won") 50 | elif user_input == computer_input: 51 | print("Draw") 52 | else: 53 | print("You Lose") 54 | 55 | -------------------------------------------------------------------------------- /006-Password Generator/README.md: -------------------------------------------------------------------------------- 1 | # Password Generator Project 2 | 3 | ## Overview 4 | 5 | This Python code is a password generator. It asks the user how many letters, symbols, and numbers they want in their password, and then creates a password based on their preferences. 6 | 7 | ## Topics Covered 8 | 9 | - **Importing Necessary Modules**: 10 | - The script starts by importing the `random` module, which is used to generate random elements. 11 | 12 | - **Lists of Characters**: 13 | - Three lists are created: `letters`, `numbers`, and `symbols`. These lists contain characters that can be used to generate the password. 14 | 15 | - **Welcome Message**: 16 | - The script prints a welcome message to greet the user. 17 | 18 | - **User Input**: 19 | - The script prompts the user to enter how many letters, symbols, and numbers they want in their password. 20 | 21 | - **Generating the Password**: 22 | - It creates an empty list called `password_list` to store the characters of the password. 23 | - For each desired letter, the script randomly selects a letter from the `letters` list and adds it to the `password_list`. 24 | - Similarly, for each desired symbol and number, the script randomly selects a symbol or number respectively, and adds it to the `password_list`. 25 | 26 | - **Shuffling and Concatenating**: 27 | - After all the characters are added to the `password_list`, it shuffles the characters randomly to mix them up. 28 | - Then, it concatenates all the characters in the `password_list` to form the final password. 29 | 30 | - **Output**: 31 | - Finally, the script prints out the generated password for the user to see. 32 | 33 | This script allows users to quickly create a unique and secure password tailored to their preferences. 34 | -------------------------------------------------------------------------------- /006-Password Generator/code1.py: -------------------------------------------------------------------------------- 1 | #Password Generator Project 2 | import random 3 | letters = ['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', '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'] 4 | numbers = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] 5 | symbols = ['!', '#', '$', '%', '&', '(', ')', '*', '+'] 6 | 7 | print("Welcome to the PyPassword Generator!") 8 | nr_letters = int(input("How many letters would you like in your password?\n")) 9 | nr_symbols = int(input(f"How many symbols would you like?\n")) 10 | nr_numbers = int(input(f"How many numbers would you like?\n")) 11 | 12 | password_list = [] 13 | 14 | #selects random letters from letters list according to the user input. 15 | for char in range(1, nr_letters + 1): 16 | password_list.append(random.choice(letters)) 17 | 18 | #selects random symbols from symbols list according to the user input. 19 | for char in range(1, nr_symbols + 1): 20 | password_list += random.choice(symbols) 21 | 22 | #selects random numbers from numbers list according to the user input. 23 | for char in range(1, nr_numbers + 1): 24 | password_list += random.choice(numbers) 25 | 26 | #Randomly shuffles the characters in the list. 27 | random.shuffle(password_list) 28 | 29 | #concatenats each element to make final password 30 | password = "" 31 | for char in password_list: 32 | password += char 33 | 34 | print(f"Your password is: {password}") -------------------------------------------------------------------------------- /006-Password Generator/code2.py: -------------------------------------------------------------------------------- 1 | #Password Generator Project 2 | import random 3 | letters = ['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', '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'] 4 | numbers = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] 5 | symbols = ['!', '#', '$', '%', '&', '(', ')', '*', '+'] 6 | 7 | print("Welcome to the PyPassword Generator!") 8 | number_of_letters= int(input("How many letters would you like in your password?\n")) 9 | number_of_symbols = int(input(f"How many symbols would you like?\n")) 10 | number_of_numbers = int(input(f"How many numbers would you like?\n")) 11 | 12 | ##selects random letters from letters list according to the user input. 13 | selected_letters = random.sample(letters,number_of_letters) 14 | shuffled_letters = random.shuffle(selected_letters) 15 | shuffle_letters_string = ''.join(selected_letters) 16 | 17 | 18 | #selects random numbers from numbers list according to the user input. 19 | selected_numbers = random.sample(numbers,number_of_numbers) 20 | shuffled_numbers = random.shuffle(selected_numbers) 21 | shuffled__numbers_string = ''.join(selected_numbers) 22 | 23 | 24 | #selects random symbols from symbols list according to the user input. 25 | selected_symbols = random.sample(symbols,number_of_symbols) 26 | shuffled_symbols = random.shuffle(selected_symbols) 27 | shuffled_symbols_string= ''.join(selected_symbols) 28 | 29 | concatenated_password = shuffle_letters_string + shuffled__numbers_string + shuffled_symbols_string 30 | final_password =[] 31 | for item in concatenated_password: 32 | final_password.append(item) 33 | final_password_shuffle = random.shuffle(final_password) 34 | pypassword = ''.join(final_password) 35 | print(f"Here is your Password created by Yethishwar code: {pypassword}") -------------------------------------------------------------------------------- /007-Escaping the Maze/README.md: -------------------------------------------------------------------------------- 1 | 2 | # Reeborg's World Challenges 3 | 4 | Reeborg's World is an educational platform that offers a series of programming challenges designed to teach programming concepts in a fun and interactive way. These challenges are presented in a simulated environment where users can write code to control a robot character named Reeborg. 5 | 6 | ## About Reeborg's World 7 | 8 | Reeborg's World provides a visual interface where users can write code to solve various puzzles and tasks. The platform is particularly suitable for beginners learning programming concepts such as loops, conditionals, and functions. 9 | 10 | ## Example Code 11 | 12 | ###Yethishwar code. 13 | ```python 14 | def turn_right(): 15 | """ 16 | Function to turn the robot right by performing three left turns. 17 | """ 18 | turn_left() 19 | turn_left() 20 | turn_left() 21 | 22 | def u_turn(): 23 | """ 24 | Function to make a U-turn by performing two left turns. 25 | """ 26 | turn_left() 27 | turn_left() 28 | 29 | while not at_goal(): 30 | if wall_on_right() and front_is_clear(): 31 | move() 32 | elif wall_on_right() and wall_in_front(): 33 | u_turn() 34 | else: 35 | turn_right() 36 | move() 37 | 38 | 39 | 40 | 41 | ###Anjela mam code. 42 | ```python 43 | def turn_right(): 44 | """ 45 | Function to turn the robot right by performing three left turns. 46 | """ 47 | turn_left() 48 | turn_left() 49 | turn_left() 50 | 51 | def u_turn(): 52 | """ 53 | Function to make a U-turn by performing two left turns. 54 | """ 55 | turn_left() 56 | turn_left() 57 | 58 | while not at_goal(): 59 | if wall_on_right() and front_is_clear(): 60 | move() 61 | elif wall_on_right() and wall_in_front(): 62 | u_turn() 63 | else: 64 | turn_right() 65 | move() 66 | 67 | 68 | ###Click here to know more 69 | https://reeborg.ca/reeborg.html?lang=en&mode=python&menu=worlds%2Fmenus%2Freeborg_intro_en.json&name=Maze&url=worlds%2Ftutorial_en%2Fmaze1.json 70 | -------------------------------------------------------------------------------- /007-Escaping the Maze/code1.py: -------------------------------------------------------------------------------- 1 | '''' 2 | def turn_right(): 3 | turn_left() 4 | turn_left() 5 | turn_left() 6 | 7 | while front_is_clear(): 8 | move() 9 | turn_left() 10 | while not at_goal(): 11 | if right_is_clear() : 12 | turn_right() 13 | move() 14 | elif front_is_clear() : 15 | move() 16 | else: 17 | turn_left() 18 | ''' 19 | #Anjela mam Code -------------------------------------------------------------------------------- /007-Escaping the Maze/code2.py: -------------------------------------------------------------------------------- 1 | ''' 2 | def turn_right(): 3 | turn_left() 4 | turn_left() 5 | turn_left() 6 | 7 | def u_turn(): 8 | turn_left() 9 | turn_left() 10 | 11 | while not at_goal(): 12 | if wall_on_right() and front_is_clear(): 13 | move() 14 | elif wall_on_right() and wall_in_front(): 15 | u_turn() 16 | else: 17 | turn_right() 18 | move() save this code 19 | ''' 20 | #Yethishwar code -------------------------------------------------------------------------------- /008-Hangman/Animal_Names.py: -------------------------------------------------------------------------------- 1 | word_list = [ 2 | 'abruptly', 3 | 'absurd', 4 | 'abyss', 5 | 'affix', 6 | 'askew', 7 | 'alpaca', 8 | 'armadillo', 9 | 'aardvark', 10 | 'anteater', 11 | 'antelope', 12 | 'baboon', 13 | 'badger', 14 | 'bat', 15 | 'beaver', 16 | 'bobcat', 17 | 'buffalo', 18 | 'camel', 19 | 'cheetah', 20 | 'chimpanzee', 21 | 'coyote', 22 | 'crocodile', 23 | 'dingo', 24 | 'dolphin', 25 | 'donkey', 26 | 'elephant', 27 | 'ferret', 28 | 'fox', 29 | 'gazelle', 30 | 'giraffe', 31 | 'gnu', 32 | 'gorilla', 33 | 'hamster', 34 | 'hippopotamus', 35 | 'hyena', 36 | 'iguana', 37 | 'impala', 38 | 'jackal', 39 | 'jaguar', 40 | 'kangaroo', 41 | 'koala', 42 | 'lemur', 43 | 'lion', 44 | 'lynx', 45 | 'mongoose', 46 | 'monkey', 47 | 'moose', 48 | 'narwhal', 49 | 'ocelot', 50 | 'opossum', 51 | 'orangutan', 52 | 'otter', 53 | 'panda', 54 | 'panther', 55 | 'parrot', 56 | 'penguin', 57 | 'platypus', 58 | 'porcupine', 59 | 'puma', 60 | 'quokka', 61 | 'quoll', 62 | 'raccoon', 63 | 'rhinoceros', 64 | 'salamander', 65 | 'seal', 66 | 'skunk', 67 | 'sloth', 68 | 'snake', 69 | 'squirrel', 70 | 'tapir', 71 | 'tiger', 72 | 'walrus', 73 | 'weasel', 74 | 'wombat', 75 | 'zebra', 76 | 'anchovy', 77 | 'barracuda', 78 | 'clownfish', 79 | 'cuttlefish', 80 | 'dolphin', 81 | 'eel', 82 | 'flounder', 83 | 'hammerhead', 84 | 'jellyfish', 85 | 'manatee', 86 | 'narwhal', 87 | 'octopus', 88 | 'otter', 89 | 'penguin', 90 | 'seal', 91 | 'seahorse', 92 | 'shark', 93 | 'squid', 94 | 'starfish', 95 | 'stingray', 96 | 'tuna', 97 | 'whale', 98 | ] 99 | -------------------------------------------------------------------------------- /008-Hangman/Ascii_Art.py: -------------------------------------------------------------------------------- 1 | logo = ''' 2 | _ 3 | | | 4 | | |__ __ _ _ __ __ _ _ __ ___ __ _ _ __ 5 | | '_ \ / _` | '_ \ / _` | '_ ` _ \ / _` | '_ \ 6 | | | | | (_| | | | | (_| | | | | | | (_| | | | | 7 | |_| |_|\__,_|_| |_|\__, |_| |_| |_|\__,_|_| |_| 8 | __/ | 9 | |___/ ''' 10 | 11 | stages = [''' 12 | +---+ 13 | | | 14 | O | 15 | /|\ | 16 | / \ | 17 | | 18 | ========= 19 | ''', ''' 20 | +---+ 21 | | | 22 | O | 23 | /|\ | 24 | / | 25 | | 26 | ========= 27 | ''', ''' 28 | +---+ 29 | | | 30 | O | 31 | /|\ | 32 | | 33 | | 34 | ========= 35 | ''', ''' 36 | +---+ 37 | | | 38 | O | 39 | /| | 40 | | 41 | | 42 | =========''', ''' 43 | +---+ 44 | | | 45 | O | 46 | | | 47 | | 48 | | 49 | ========= 50 | ''', ''' 51 | +---+ 52 | | | 53 | O | 54 | | 55 | | 56 | | 57 | ========= 58 | ''', ''' 59 | +---+ 60 | | | 61 | | 62 | | 63 | | 64 | | 65 | ========= 66 | '''] 67 | -------------------------------------------------------------------------------- /008-Hangman/README.md: -------------------------------------------------------------------------------- 1 | # Hangman Game 2 | 3 | ## Overview 4 | 5 | This Python code implements a Hangman game where the player needs to guess a word by entering letters. The game provides a limited number of attempts to guess the word correctly. If the player exceeds the allowed number of attempts, they lose the game. 6 | 7 | ## Topics Covered. 8 | 9 | 1. **Imports** 10 | - *Description*: The script imports necessary modules and functions. 11 | - 12 | ```python 13 | import random 14 | import os 15 | from Animal_Names import word_list 16 | from Ascii_Art import logo, stages 17 | ``` 18 | 19 | 2. **Clearing the Screen** 20 | - *Description*: The script defines a function to clear the console screen. 21 | - 22 | ```python 23 | def clear(): 24 | os.system('cls' if os.name == 'nt' else 'clear') 25 | ``` 26 | 27 | 3. **Initializing Game Variables** 28 | - *Description*: The script initializes variables such as the chosen word, word length, and remaining lives. 29 | - 30 | ```python 31 | end_of_game = False 32 | chosen_word = random.choice(word_list) 33 | word_length = len(chosen_word) 34 | lives = 6 35 | ``` 36 | 37 | 4. **Main Game Loop** 38 | - *Description*: The script runs the main game loop where the player guesses letters until they either win or lose the game. 39 | - 40 | ```python 41 | while not end_of_game: 42 | # Display current game state 43 | # Prompt player to guess a letter 44 | # Check if guessed letter is in the word 45 | # Update game state accordingly 46 | # Check if player has won or lost 47 | ``` 48 | 49 | 5. **Checking Guesses and Updating Display** 50 | - *Description*: The script checks the player's guessed letter against the chosen word and updates the display accordingly. 51 | - 52 | ```python 53 | for position in range(word_length): 54 | letter = chosen_word[position] 55 | if letter == guess: 56 | display[position] = letter 57 | ``` 58 | 59 | 6. **End of Game Conditions** 60 | - *Description*: The script checks if the player has won or lost the game and prints the appropriate message. 61 | - 62 | ```python 63 | if "_" not in display: 64 | end_of_game = True 65 | print("You Won.") 66 | if lives == 0: 67 | end_of_game = True 68 | print("You Lose") 69 | print(f"The Animal name is: {chosen_word}") 70 | ``` 71 | 72 | 7. **Printing Game State** 73 | - *Description*: The script prints the current state of the Hangman game, including the Hangman figure and the word display. 74 | - 75 | ```python 76 | print(f"{' '.join(display)}") 77 | print(stages[lives]) 78 | ``` 79 | -------------------------------------------------------------------------------- /008-Hangman/code.py: -------------------------------------------------------------------------------- 1 | import random 2 | import os 3 | from Animal_Names import word_list 4 | from Ascii_Art import logo,stages 5 | 6 | 7 | #Clears the console screen. 8 | def clear(): 9 | os.system('cls' if os.name == 'nt' else 'clear') 10 | 11 | 12 | end_of_game = False 13 | chosen_word = random.choice(word_list) 14 | word_length = len(chosen_word) 15 | lives = 6 16 | 17 | print(logo) 18 | 19 | 20 | #Create blanks 21 | display = [] 22 | for _ in range(word_length): 23 | display += "_" 24 | print("The Chosen Word is a animal name.") 25 | print(f"{' '.join(display)}") 26 | while not end_of_game: 27 | guess = input("Guess a letter: ").lower() 28 | clear() 29 | if guess in display: 30 | print(f"You've already guessed --> {guess}") 31 | 32 | #Check guessed letter 33 | for position in range(word_length): 34 | letter = chosen_word[position] 35 | if letter == guess: 36 | display[position] = letter 37 | 38 | if guess not in chosen_word: 39 | if guess not in chosen_word: 40 | print(f"You guessed {guess}, that's not in the word.You lose a life.") 41 | lives -= 1 42 | if lives == 0: 43 | end_of_game = True 44 | print("You Lose") 45 | print(f"The Animal name is: {chosen_word}") 46 | 47 | print(f"{' '.join(display)}") 48 | 49 | #Check if user has got all letters. 50 | if "_" not in display: 51 | end_of_game = True 52 | print("You Won.") 53 | print(stages[lives]) 54 | -------------------------------------------------------------------------------- /009-Caesar Cipher/Ascii_Art.py: -------------------------------------------------------------------------------- 1 | logo = """ 2 | ,adPPYba, ,adPPYYba, ,adPPYba, ,adPPYba, ,adPPYYba, 8b,dPPYba, 3 | a8" "" "" `Y8 a8P_____88 I8[ "" "" `Y8 88P' "Y8 4 | 8b ,adPPPPP88 8PP""""""" `"Y8ba, ,adPPPPP88 88 5 | "8a, ,aa 88, ,88 "8b, ,aa aa ]8I 88, ,88 88 6 | `"Ybbd8"' `"8bbdP"Y8 `"Ybbd8"' `"YbbdP"' `"8bbdP"Y8 88 7 | 88 88 8 | "" 88 9 | 88 10 | ,adPPYba, 88 8b,dPPYba, 88,dPPYba, ,adPPYba, 8b,dPPYba, 11 | a8" "" 88 88P' "8a 88P' "8a a8P_____88 88P' "Y8 12 | 8b 88 88 d8 88 88 8PP""""""" 88 13 | "8a, ,aa 88 88b, ,a8" 88 88 "8b, ,aa 88 14 | `"Ybbd8"' 88 88`YbbdP"' 88 88 `"Ybbd8"' 88 15 | 88 16 | 88 17 | """ -------------------------------------------------------------------------------- /009-Caesar Cipher/BasicHelper.py: -------------------------------------------------------------------------------- 1 | #Basic level program consists of 2 functions encrypt and decrypt. The user must give the input accordingly otherwise it will give error. 2 | from Ascii_Art import logo 3 | alphabet = ['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','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'] 4 | 5 | 6 | def encrypt(text,shift): 7 | encrypted_word = "" 8 | for item in text: 9 | current_position = alphabet.index(item) 10 | new_position = (current_position + shift) 11 | encrypted_word = encrypted_word + alphabet[new_position] 12 | print(f"The encoded text is {encrypted_word}") 13 | 14 | def decrypt(text,shift): 15 | decrypted_word = "" 16 | for item in text: 17 | currrent_position = alphabet.index(item) 18 | new_position = (currrent_position - shift) 19 | decrypted_word += alphabet[new_position] 20 | print(f"The decoded text is {decrypted_word}") 21 | 22 | 23 | print(logo) 24 | 25 | should_continue = True 26 | while should_continue: 27 | direction = input("Type 'encode' to encrypt, type 'decode' to decrypt:\n").lower() 28 | text = input("Type your message:\n").lower() 29 | shift = int(input("Type the shift number:\n")) 30 | if direction == "encode": 31 | encrypt(text,shift) 32 | elif direction == "decode": 33 | decrypt(text,shift) 34 | else: 35 | print("Please choose a correct option(encode/decode)") 36 | decision = input("Type 'Yes' if you want to go again. Otherwise type 'No'").lower() 37 | if decision == "no": 38 | should_continue = False 39 | print("Goodbye") 40 | -------------------------------------------------------------------------------- /009-Caesar Cipher/Challenger.py: -------------------------------------------------------------------------------- 1 | from Ascii_Art import logo 2 | 3 | alphabet = ['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','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'] 4 | 5 | def caesar(initial_text, shift_number, choice): 6 | result_text = "" 7 | if choice == "decode": 8 | shift_number *= -1 9 | for item in initial_text: 10 | if item in alphabet: 11 | current_position = alphabet.index(item) 12 | new_position = (current_position + shift_number) % 26 13 | result_text += alphabet[new_position] 14 | else: 15 | result_text += item 16 | print(f"The {choice}d text is {result_text}") 17 | 18 | print(logo) 19 | 20 | should_continue = True 21 | while should_continue: 22 | direction = input("Type 'encode' to encrypt, type 'decode' to decrypt:\n").lower() 23 | text = input("Type your message:\n").lower() 24 | shift = int(input("Type the shift number:\n")) 25 | caesar(text, shift, direction) 26 | decision = input("Type 'Yes' if you want to go again. Otherwise type 'No'\n").lower() 27 | if decision == "no": 28 | should_continue = False 29 | print("Goodbye") 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /009-Caesar Cipher/Moderator.py: -------------------------------------------------------------------------------- 1 | 2 | from Ascii_Art import logo 3 | print(logo) 4 | 5 | alphabet = ['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','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'] 6 | def caesar(text,shift,direction): 7 | final_result = "" 8 | for item in text: 9 | 10 | current_position = alphabet.index(item) 11 | if direction == "encode": 12 | new_position = (current_position + shift) 13 | elif direction == "decode": 14 | new_position = (current_position - shift) 15 | final_result = final_result + alphabet[new_position] 16 | print(f"The {direction}d text is {final_result}") 17 | 18 | should_continue = True 19 | while should_continue: 20 | direction = input("Type 'encode' to encrypt, type 'decode' to decrypt:\n").lower() 21 | text = input("Type your message:\n").lower() 22 | shift = int(input("Type the shift number:\n")) 23 | caesar(text, shift, direction) 24 | decision = input("Type 'Yes' if you want to go again. Otherwise type 'No'").lower() 25 | if decision == "no": 26 | should_continue = False 27 | print("Goodbye") 28 | 29 | 30 | -------------------------------------------------------------------------------- /009-Caesar Cipher/README.md: -------------------------------------------------------------------------------- 1 | # Caesar Cipher 2 | 3 | ## Introduction 4 | The Caesar Cipher is one of the simplest and oldest encryption techniques. It works by shifting each letter in the plaintext by a fixed number of positions down the alphabet. 5 | 6 | ## How it Works 7 | Let's say we want to encrypt the message "HELLO" using a Caesar Cipher with a shift of 3: 8 | 9 | - H becomes K 10 | - E becomes H 11 | - L becomes O 12 | - L becomes O 13 | - O becomes R 14 | 15 | So, "HELLO" would be encrypted as "KHOOR". 16 | 17 | ## Program written in Three Levels 18 | ### BasicHelper 19 | The BasicHelper program provides a simple implementation of the Caesar Cipher. It prompts the user to enter a message and a shift value, then outputs the encrypted message. 20 | 21 | ### Moderator 22 | The Moderator program offers a more customizable version of the Caesar Cipher. It allows the user to choose between encryption and decryption, specify the message and shift value, and provides options for handling special characters. 23 | 24 | ### Challenger 25 | The Challenger program is an advanced implementation of the Caesar Cipher. It not only encrypts and decrypts messages but also includes additional features such as handling uppercase and lowercase letters separately, and providing options for brute-force 26 | ## Sample Output 27 | 28 | ```plaintext 29 | ,adPPYba, ,adPPYYba, ,adPPYba, ,adPPYba, ,adPPYYba, 8b,dPPYba, 30 | a8" "" "" `Y8 a8P_____88 I8[ "" "" `Y8 88P' "Y8 31 | 8b ,adPPPPP88 8PP" `"Y8ba, ,adPPPPP88 88 32 | "8a, ,aa 88, ,88 "8b, ,aa aa ]8I 88, ,88 88 33 | `"Ybbd8"' `"8bbdP"Y8 `"Ybbd8"' `"YbbdP"' `"8bbdP"Y8 88 34 | 88 88 35 | "" 88 36 | 88 37 | ,adPPYba, 88 8b,dPPYba, 88,dPPYba, ,adPPYba, 8b,dPPYba, 38 | a8" "" 88 88P' "8a 88P' "8a a8P_____88 88P' "Y8 39 | 8b 88 88 d8 88 88 8PP" 88 40 | "8a, ,aa 88 88b, ,a8" 88 88 "8b, ,aa 88 41 | `"Ybbd8"' 88 88`YbbdP"' 88 88 `"Ybbd8"' 88 42 | 88 43 | 88 44 | 45 | Type 'encode' to encrypt, type 'decode' to decrypt: 46 | enCODE 47 | Type your message: 48 | hello 49 | Type the shift number: 50 | 5 51 | The encoded text is mjqqt 52 | Type 'Yes' if you want to go again. Otherwise type 'No' 53 | YES 54 | Type 'encode' to encrypt, type 'decode' to decrypt: 55 | decodE 56 | Type your message: 57 | mjqqt 58 | Type the shift number: 59 | 5 60 | The decoded text is hello 61 | Type 'Yes' if you want to go again. Otherwise type 'No' 62 | NO 63 | Goodbye -------------------------------------------------------------------------------- /010-Secret Auction/Ascii_Art.py: -------------------------------------------------------------------------------- 1 | logo = ''' 2 | ___________ 3 | \ / 4 | )_______( 5 | |"""""""|_.-._,.---------.,_.-._ 6 | | | | | | | ''-. 7 | | |_| |_ _| |_..-' 8 | |_______| '-' `'---------'` '-' 9 | )"""""""( 10 | /_________\\ 11 | .-------------. 12 | /_______________\\ 13 | ''' -------------------------------------------------------------------------------- /010-Secret Auction/README.md: -------------------------------------------------------------------------------- 1 | # Secret Auction Project 2 | 3 | ## Overview 4 | 5 | The Secret Auction Project is a Python program designed to facilitate secret bidding among users. The program allows users to input their name and bid amount without revealing their bids to others. Once all bids are collected, the program determines the winner with the highest bid and announces the result. This project demonstrates the use of dictionaries in Python to store and manage bidding information efficiently. 6 | 7 | ## Dictionaries in Python 8 | 9 | - Dictionaries in Python are unordered collections of key-value pairs. 10 | - Each key in a dictionary must be unique. 11 | - Keys must be immutable objects (e.g., strings, numbers) while values can be of any data type. 12 | - Dictionaries are mutable, meaning you can modify them after creation. 13 | 14 | ## Important Methods for Dictionaries 15 | 16 | - **`dictionary.keys()`**: Returns a view object that displays a list of all the keys in the dictionary. 17 | - **`dictionary.values()`**: Returns a view object that displays a list of all the values in the dictionary. 18 | - **`dictionary.items()`**: Returns a view object that displays a list of key-value tuples in the dictionary. 19 | - **`dictionary.get(key)`**: Returns the value associated with the specified key. If the key is not found, returns None (or a default value if specified). 20 | - **`max(dictionary)`**: Returns the key with the maximum value in the dictionary. 21 | 22 | ## Understanding the Code 23 | 24 | ### Initialization of the Dictionary 25 | 26 | - The code initializes an empty dictionary `my_dict` to store the names of bidders as keys and their corresponding bid amounts as values. 27 | - It uses the input from users to populate this dictionary. 28 | 29 | ### Adding Bids to the Dictionary 30 | 31 | - The code prompts users to input their name and bid amount. 32 | - It then adds this information to the dictionary using the name as the key and the bid amount as the value. 33 | 34 | ### Finding the Winner 35 | 36 | - Once all the bids are collected, the code determines the winner with the highest bid. 37 | - It iterates over the dictionary items to find the key (name) associated with the highest bid value. 38 | - It uses the `max()` function along with `my_dict.values()` to find the maximum bid amount. 39 | 40 | ## Code Explanation 41 | 42 | - The code iterates over the dictionary items to find the winner with the highest bid using a loop. 43 | - It checks each bid amount against the highest bid found so far and updates the highest bid if a higher bid is found. 44 | - Finally, it prints the name of the winner along with the winning bid amount. 45 | 46 | ## Conclusion 47 | 48 | This Document provides an overview of how dictionaries are used in the provided Python code snippet for the Secret Auction Project. It demonstrates how dictionaries can be used to store and manipulate data efficiently, making them suitable for various real-world applications, such as the bidding program in this example. 49 | 50 | ## Sample Output 51 | 52 | ```plaintext 53 | ___________ 54 | \ / 55 | )_______( 56 | |"""""""|_.-._,.---------.,_.-._ 57 | | | | | | | ''-. 58 | | |_| |_ _| |_..-' 59 | |_______| '-' `'---------'` '-' 60 | )"""""""( 61 | /_________\\ 62 | .-------------. 63 | /_______________\\ 64 | 65 | 66 | What is your name?: Yethishwar 67 | What's your Bid amount: $2000 68 | Are there any other bidders? Type 'Yes' or 'No': no 69 | ---------- Clear Screen ---------------------- 70 | What is your name?: Chintu 71 | What's your Bid amount: $1000 72 | Are there any other bidders? Type 'Yes' or 'No': no 73 | ---------- Clear Screen ---------------------- 74 | What is your name?: Preeti 75 | What's your Bid amount: $5000 76 | Are there any other bidders? Type 'Yes' or 'No': no 77 | ---------- Clear Screen ---------------------- 78 | What is your name?: peter 79 | What's your Bid amount: $10 80 | Are there any other bidders? Type 'Yes' or 'No': no 81 | The Winner is Preeti with a bid of $5000 82 | -------------------------------------------------------------------------------- /010-Secret Auction/code.py: -------------------------------------------------------------------------------- 1 | import os 2 | def clear(): 3 | """Clears the console screen.""" 4 | os.system('cls' if os.name == 'nt' else 'clear') 5 | from Ascii_Art import logo 6 | print(logo) 7 | condition = True 8 | my_dict = {} 9 | while condition: 10 | name = input("What is your name?: ") 11 | bid_amount = int(input("What's your Bid amount: $")) 12 | my_dict[name] = bid_amount 13 | 14 | 15 | check = input("Are there any other bidders? Type 'Yes' or 'No': ").lower() 16 | if check == "yes": 17 | clear() 18 | elif check == "no": 19 | condition = False 20 | for (key,value) in my_dict.items(): 21 | max_value = max(my_dict.values()) 22 | for key,value in my_dict.items(): 23 | if value == max_value: 24 | print(f"The Winner is {key} with a bid of ${max_value}") 25 | else: 26 | print("You entered wrong option please try again!") 27 | 28 | #In above code intead of using .max() method we also have another way of approaching below 29 | ''' 30 | def find_highest_bidder(bidding_record): 31 | highest_bid = 0 32 | winner = "" 33 | # bidding_record = {"Angela": 123, "James": 321} 34 | for bidder in bidding_record: 35 | bid_amount = bidding_record[bidder] 36 | if bid_amount > highest_bid: 37 | highest_bid = bid_amount 38 | winner = bidder 39 | print(f"The winner is {winner} with a bid of ${highest_bid}") 40 | ''' -------------------------------------------------------------------------------- /011-Calculator/Ascii_Art.py: -------------------------------------------------------------------------------- 1 | 2 | logo = """ 3 | _____________________ 4 | | _________________ | 5 | | | Pythonista 0. | | .----------------. .----------------. .----------------. .----------------. 6 | | |_________________| | | .--------------. || .--------------. || .--------------. || .--------------. | 7 | | ___ ___ ___ ___ | | | ______ | || | __ | || | _____ | || | ______ | | 8 | | | 7 | 8 | 9 | | + | | | | .' ___ | | || | / \ | || | |_ _| | || | .' ___ | | | 9 | | |___|___|___| |___| | | | / .' \_| | || | / /\ \ | || | | | | || | / .' \_| | | 10 | | | 4 | 5 | 6 | | - | | | | | | | || | / ____ \ | || | | | _ | || | | | | | 11 | | |___|___|___| |___| | | | \ `.___.'\ | || | _/ / \ \_ | || | _| |__/ | | || | \ `.___.'\ | | 12 | | | 1 | 2 | 3 | | x | | | | `._____.' | || ||____| |____|| || | |________| | || | `._____.' | | 13 | | |___|___|___| |___| | | | | || | | || | | || | | | 14 | | | . | 0 | = | | / | | | '--------------' || '--------------' || '--------------' || '--------------' | 15 | | |___|___|___| |___| | '----------------' '----------------' '----------------' '----------------' 16 | |_____________________| 17 | """ 18 | -------------------------------------------------------------------------------- /011-Calculator/README.md: -------------------------------------------------------------------------------- 1 | # Calculator Project 2 | 3 | ## Topics Covered: 4 | 5 | 1. Recursion 6 | 2. Difference between print and return 7 | 3. DOC Strings 8 | 9 | ### 1. Recursion 10 | 11 | Recursion is a programming technique where a function calls itself in order to solve a problem. It's like when you're solving a big puzzle, and you break it into smaller puzzles of the same type to solve them individually. Each time you solve a smaller puzzle, you're closer to solving the big one. 12 | 13 | ### 2. Difference between print and return 14 | 15 | In programming, `print` is like showing your work to someone, while `return` is like giving an answer. When you `print`, you're just displaying information on the screen, but when you `return`, you're sending a value back to where the function was called from, like giving an answer to a question. 16 | 17 | ### 3. DOC Strings 18 | 19 | DOC Strings are like little notes you write to yourself and others to explain what your code does. They help you understand your code better and make it easier for others to use it. It's like writing instructions for a game so that anyone can play it without getting confused. 20 | ## Sample Output 21 | 22 | ```plaintext 23 | 24 | 25 | _____________________ 26 | | _________________ | 27 | | | Pythonista 0. | | .----------------. .----------------. .----------------. .----------------. 28 | | |_________________| | | .--------------. || .--------------. || .--------------. || .--------------. | 29 | | ___ ___ ___ ___ | | | ______ | || | __ | || | _____ | || | ______ | | 30 | | | 7 | 8 | 9 | | + | | | | .' ___ | | || | / \ | || | |_ _| | || | .' ___ | | | 31 | | |___|___|___| |___| | | | / .' \_| | || | / /\ \ | || | | | | || | / .' \_| | | 32 | | | 4 | 5 | 6 | | - | | | | | | | || | / ____ \ | || | | | _ | || | | | | | 33 | | |___|___|___| |___| | | | \ `.___.'\ | || | _/ / \ \_ | || | _| |__/ | | || | \ `.___.'\ | | 34 | | | 1 | 2 | 3 | | x | | | | `._____.' | || ||____| |____|| || | |________| | || | `._____.' | | 35 | | |___|___|___| |___| | | | | || | | || | | || | | | 36 | | | . | 0 | = | | / | | | '--------------' || '--------------' || '--------------' || '--------------' | 37 | | |___|___|___| |___| | '----------------' '----------------' '----------------' '----------------' 38 | |_____________________| 39 | 40 | What's the first number? 10 41 | + 42 | - 43 | * 44 | / 45 | Pick an operation:/ 46 | What's the next number? 5 47 | 10.0 / 5.0 = 2.0 48 | 49 | 'Y' ---> To calculate with 2.0. 50 | 'N' ---> To start from Starting. 51 | 'E' ---> To exit. 52 | ENTER HERE ---> y 53 | Pick an operation:* 54 | What's the next number? 5 55 | 2.0 * 5.0 = 10.0 56 | 57 | 'Y' ---> To calculate with 10.0. 58 | 'N' ---> To start from Starting. 59 | 'E' ---> To exit. 60 | ENTER HERE ---> e 61 | Thank You for using Yethsihwar's Calculator. 62 | -------------------------------------------------------------------------------- /011-Calculator/code.py: -------------------------------------------------------------------------------- 1 | from Ascii_Art import logo 2 | import os 3 | def clear(): 4 | """Clears the console screen.""" 5 | os.system('cls' if os.name == 'nt' else 'clear') 6 | 7 | def Addition(n1,n2): 8 | return n1+n2 9 | def Multiplication(n1,n2): 10 | return n1*n2 11 | def Division(n1,n2): 12 | return n1/n2 13 | def Subtraction(n1,n2): 14 | return n1-n2 15 | 16 | operations = { 17 | "+":Addition, 18 | "-":Subtraction, 19 | "*":Multiplication, 20 | "/":Division 21 | } 22 | 23 | def calculator(): 24 | """ 25 | Recursive Function performs Basic Arithmatic Operations. 26 | """ 27 | print(logo) 28 | num1 = float(input("What's the first number? ")) 29 | for key in operations: 30 | print(key) 31 | is_true = True 32 | while is_true: 33 | operation_symbol = input("Pick an operation:") 34 | if operation_symbol not in operations.keys(): 35 | print("Sorry, You entered Invalid Operational Symbol, Please Try Again!") 36 | else: 37 | num2 = float(input("What's the next number? ")) 38 | function = operations[operation_symbol] 39 | answer = function(num1,num2) 40 | print(f"{num1} {operation_symbol} {num2} = {answer}\n") 41 | 42 | to_continue = input(f"'Y' ---> To calculate with {answer}.\n'N' ---> To start from Starting.\n'E' ---> To exit.\nENTER HERE ---> " ).lower() 43 | 44 | if to_continue == "y": 45 | num1 = answer 46 | elif to_continue == "n": 47 | clear() 48 | calculator() 49 | elif to_continue == "e": 50 | return "Thank You for using Yethsihwar's Calculator" 51 | else: 52 | return "You chose an Invalid Option, Please Try Again!" 53 | 54 | print(calculator()) -------------------------------------------------------------------------------- /012-BlackJack/Ascii_Art.py: -------------------------------------------------------------------------------- 1 | logo = """ 2 | .------. _ _ _ _ _ 3 | |A_ _ |. | | | | | | (_) | | 4 | |( \/ ).-----. | |__ | | __ _ ___| | ___ __ _ ___| | __ 5 | | \ /|K /\ | | '_ \| |/ _` |/ __| |/ / |/ _` |/ __| |/ / 6 | | \/ | / \ | | |_) | | (_| | (__| <| | (_| | (__| < 7 | `-----| \ / | |_.__/|_|\__,_|\___|_|\_\ |\__,_|\___|_|\_\\ 8 | | \/ K| _/ | 9 | `------' |__/ 10 | """ 11 | 12 | -------------------------------------------------------------------------------- /012-BlackJack/README.md: -------------------------------------------------------------------------------- 1 | ## Blackjack Project 2 | 3 | This project is a simple implementation of the Blackjack card game. In Blackjack, the goal is to get cards with a total value as close to 21 as possible without going over. Here's a breakdown of how the project works: 4 | 5 | ### Deck of Cards 6 | 7 | The game uses a standard deck of cards without jokers. Each card has a value: numbered cards are worth their face value, face cards (Jack, Queen, King) are worth 10, and Aces can be worth 11 or 1, whichever is more advantageous to the player. 8 | 9 | ### Gameplay 10 | 11 | - The game starts by dealing two cards to the player and two cards to the dealer (computer). 12 | - The player can see one of the dealer's cards but not the other. 13 | - The player then decides whether to take additional cards ('hit') to improve their hand or stick with what they have ('stand'). 14 | - If the player's total exceeds 21, they bust and lose the game. 15 | - After the player's turn, the dealer reveals their hidden card and draws additional cards if their total is below 17. 16 | - If the dealer's total exceeds 21, they bust, and the player wins. 17 | - The winner is determined based on who has the highest score without exceeding 21. 18 | 19 | ### Functions 20 | 21 | - `deal_card()`: Returns a random card from the deck. This function is used to deal cards to both the player and the dealer. 22 | - `calculate_score(cards)`: Takes a list of cards and returns the total score. Handles special cases like Blackjack and Aces. This function calculates the score for both the player and the dealer. 23 | - `compare(user_score, computer_score)`: Compares the scores of the player and the dealer to determine the winner. It considers different scenarios like Blackjack, busting, and having the highest score. 24 | - `play_game()`: Implements the main game loop, dealing cards, allowing the player to decide whether to hit or stand, and controlling the dealer's actions. This function orchestrates the entire game flow. 25 | - `clear()`: Clears the console screen for a cleaner display. This function helps in maintaining a neat interface between game sessions. 26 | 27 | ### Restart Option 28 | 29 | After each game, the player is asked if they want to play again. If they agree, the console is cleared, and a new game starts. 30 | 31 | This project provides a basic but functional version of Blackjack that allows users to play against a computer dealer. 32 | ### Sample Output: 33 | ```plaintext 34 | 35 | .------. _ _ _ _ _ 36 | |A_ _ |. | | | | | | (_) | | 37 | |( \/ ).-----. | |__ | | __ _ ___| | ___ __ _ ___| | __ 38 | | \ /|K /\ | | '_ \| |/ _` |/ __| |/ / |/ _` |/ __| |/ / 39 | | \/ | / \ | | |_) | | (_| | (__| <| | (_| | (__| < 40 | `-----| \ / | |_.__/|_|\__,_|\___|_|\_\ |\__,_|\___|_|\_\ 41 | | \/ K| _/ | 42 | `------' |__/ 43 | 44 | Your cards: [6, 6], current score: 12 45 | Computer's first card: 10 46 | Type 'y' to get another card, type 'n' to pass: y 47 | Your cards: [6, 6, 2], current score: 14 48 | Computer's first card: 10 49 | Type 'y' to get another card, type 'n' to pass: y 50 | Your cards: [6, 6, 2, 1], current score: 15 51 | Computer's first card: 10 52 | Type 'y' to get another card, type 'n' to pass: y 53 | Your cards: [6, 6, 2, 1, 8], current score: 23 54 | Computer's first card: 10 55 | Your final hand: [6, 6, 2, 1, 8], final score: 23 56 | Computer's final hand: [10, 10], final score: 20 57 | You went over. You lose 😭 58 | Do you want to play a game of Blackjack? Type 'y' or 'n': y-> Clears console screen and starts a nre game, n -> exit. 59 | -------------------------------------------------------------------------------- /012-BlackJack/code.py: -------------------------------------------------------------------------------- 1 | from Ascii_Art import logo 2 | import random 3 | 4 | import os 5 | 6 | def clear(): 7 | """Clears the console screen.""" 8 | os.system('cls' if os.name == 'nt' else 'clear') 9 | 10 | def deal_card(): 11 | """Returns a random card from the deck.""" 12 | cards = [11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10] 13 | card = random.choice(cards) 14 | return card 15 | 16 | def calculate_score(cards): 17 | """Take a list of cards and return the score calculated from the cards""" 18 | 19 | if sum(cards) == 21 and len(cards) == 2: 20 | return 0 21 | 22 | if 11 in cards and sum(cards) > 21: 23 | cards.remove(11) 24 | cards.append(1) 25 | return sum(cards) 26 | 27 | def compare(user_score, computer_score): 28 | if user_score > 21 and computer_score > 21: 29 | return "You went over. You lose 😤" 30 | 31 | if user_score == computer_score: 32 | return "Draw 🙃" 33 | elif computer_score == 0: 34 | return "Lose, opponent has Blackjack 😱" 35 | elif user_score == 0: 36 | return "Win with a Blackjack 😎" 37 | elif user_score > 21: 38 | return "You went over. You lose 😭" 39 | elif computer_score > 21: 40 | return "Opponent went over. You win 😁" 41 | elif user_score > computer_score: 42 | return "You win 😃" 43 | else: 44 | return "You lose 😤" 45 | 46 | def play_game(): 47 | print(logo) 48 | user_cards = [] 49 | computer_cards = [] 50 | is_game_over = False 51 | 52 | for _ in range(2): 53 | user_cards.append(deal_card()) 54 | computer_cards.append(deal_card()) 55 | 56 | while not is_game_over: 57 | user_score = calculate_score(user_cards) 58 | computer_score = calculate_score(computer_cards) 59 | print(f" Your cards: {user_cards}, current score: {user_score}") 60 | print(f" Computer's first card: {computer_cards[0]}") 61 | 62 | if user_score == 0 or computer_score == 0 or user_score > 21: 63 | is_game_over = True 64 | else: 65 | user_should_deal = input("Type 'y' to get another card, type 'n' to pass: ") 66 | if user_should_deal == "y": 67 | user_cards.append(deal_card()) 68 | else: 69 | is_game_over = True 70 | 71 | while computer_score != 0 and computer_score < 17: 72 | computer_cards.append(deal_card()) 73 | computer_score = calculate_score(computer_cards) 74 | 75 | print(f" Your final hand: {user_cards}, final score: {user_score}") 76 | print(f" Computer's final hand: {computer_cards}, final score: {computer_score}") 77 | print(compare(user_score, computer_score)) 78 | 79 | while input("Do you want to play a game of Blackjack? Type 'y' or 'n': ") == "y": 80 | clear() 81 | play_game() 82 | -------------------------------------------------------------------------------- /013-Make a Guess/Ascii_Art.py: -------------------------------------------------------------------------------- 1 | logo = """ 2 | .----------------. .----------------. .----------------. .----------------. .----------------. 3 | | .--------------. || .--------------. || .--------------. || .--------------. || .--------------. | 4 | | | ______ | || | _____ _____ | || | _________ | || | _______ | || | _______ | | 5 | | | .' ___ | | || ||_ _||_ _|| || | |_ ___ | | || | / ___ | | || | / ___ | | | 6 | | | / .' \_| | || | | | | | | || | | |_ \_| | || | | (__ \_| | || | | (__ \_| | | 7 | | | | | ____ | || | | ' ' | | || | | _| _ | || | '.___`-. | || | '.___`-. | | 8 | | | \ `.___] _| | || | \ `--' / | || | _| |___/ | | || | |`\____) | | || | |`\____) | | | 9 | | | `._____.' | || | `.__.' | || | |_________| | || | |_______.' | || | |_______.' | | 10 | | | | || | | || | | || | | || | | | 11 | | '--------------' || '--------------' || '--------------' || '--------------' || '--------------' | 12 | '----------------' '----------------' '----------------' '----------------' '----------------' 13 | """ -------------------------------------------------------------------------------- /013-Make a Guess/README.md: -------------------------------------------------------------------------------- 1 | # Make a Guess Game 2 | 3 | ## Description 4 | 5 | This project is a simple number guessing game where the player has to guess a randomly generated number between 1 and 100. The game offers two difficulty levels: easy and hard. 6 | 7 | ## Topics Covered 8 | 9 | ### Namespaces 10 | 11 | Namespaces organizes the names used in a Python program, preventing naming conflicts and providing a way to access variables, functions, and other objects in a structured manner. 12 | 13 | #### Global Namespace 14 | 15 | The global namespace refers to the namespace at the highest level of the program. In Python, when you define variables or functions outside of any function or class, they belong to the global namespace. 16 | 17 | #### Local Namespace 18 | 19 | The local namespace refers to the namespace within a function or a code block. In Python, when you define variables or functions inside a function, they belong to the local namespace of that function. 20 | 21 | ### Sample Output: 22 | 23 | ```plaintext 24 | 25 | .----------------. .----------------. .----------------. .----------------. .----------------. 26 | | .--------------. || .--------------. || .--------------. || .--------------. || .--------------. | 27 | | | ______ | || | _____ _____ | || | _________ | || | _______ | || | _______ | | 28 | | | .' ___ | | || ||_ _||_ _|| || | |_ ___ | | || | / ___ | | || | / ___ | | | 29 | | | / .' \_| | || | | | | | | || | | |_ \_| | || | | (__ \_| | || | | (__ \_| | | 30 | | | | | ____ | || | | ' ' | | || | | _| _ | || | '.___`-. | || | '.___`-. | | 31 | | | \ `.___] _| | || | \ `--' / | || | _| |___/ | | || | |`\____) | | || | |`\____) | | | 32 | | | `._____.' | || | `.__.' | || | |_________| | || | |_______.' | || | |_______.' | | 33 | | | | || | | || | | || | | || | | | 34 | | '--------------' || '--------------' || '--------------' || '--------------' || '--------------' | 35 | '----------------' '----------------' '----------------' '----------------' '----------------' 36 | 37 | 38 | Welcome to the Number Guessing Game! 39 | I'm Thinking of a number between 1 and 100. 40 | Choose a difficulty. Type 'easy' or 'hard': HaRd 41 | You have 5 attempts remaining to guess the number. 42 | Make a Guess: 20 43 | Too High 44 | You have 4 attempts remaining to guess the number. 45 | Make a Guess: 10 46 | Too High 47 | You have 3 attempts remaining to guess the number. 48 | Make a Guess: 5 49 | Too High 50 | You have 2 attempts remaining to guess the number. 51 | Make a Guess: 2 52 | You Got it! The answer was 2 53 | You've run out of guesses, you lose. 54 | The number is 2 55 | Do you want to play Again Type 'yes' or 'no': no 56 | Thank you for playing the game Program written by Yethishwar. 57 | Your participation is appreciated! 58 | ``` 59 | -------------------------------------------------------------------------------- /013-Make a Guess/code.py: -------------------------------------------------------------------------------- 1 | import random 2 | import os 3 | from Ascii_Art import logo 4 | 5 | def clear_screen(): 6 | """Clears the console screen""" 7 | if os.name == 'nt': 8 | _ = os.system('cls') 9 | 10 | 11 | def check_the_conditions(attempts,rn): 12 | """Checks the conditins and print whether the guess is Low or High""" 13 | to_continue = True 14 | while 0 < attempts and to_continue: 15 | print(f"You have {attempts} attempts remaining to guess the number.") 16 | user_guess = int(input("Make a Guess: ")) 17 | if user_guess < rn: 18 | print("Too Low") 19 | attempts -= 1 20 | elif user_guess > 100: 21 | attempts -= 1 22 | print("OutofBound! Please choose a number between 1 and 100") 23 | elif user_guess > rn: 24 | print("Too High") 25 | attempts -= 1 26 | else: 27 | to_continue = False 28 | print(f"You Got it! The answer was {rn}") 29 | else: 30 | print("You've run out of guesses, you lose.") 31 | print(f"The number is {rn}") 32 | 33 | 34 | def easy_level(rn): 35 | """Switches to Easy level Attempts:- 5""" 36 | attempts = 10 37 | check_the_conditions(attempts,rn) 38 | 39 | def hard_level(rn): 40 | """Switches to Hard level Attempts:- 10""" 41 | attempts = 5 42 | check_the_conditions(attempts,rn) 43 | 44 | play_again = True 45 | while play_again: 46 | print(logo) 47 | print("Welcome to the Number Guessing Game!") 48 | print("I'm Thinking of a number between 1 and 100.") 49 | random_number = random.randint(1,100) 50 | difficulty = input("Choose a difficulty. Type 'easy' or 'hard': ").lower() 51 | if difficulty == 'easy': 52 | easy_level(random_number) 53 | elif difficulty == 'hard': 54 | hard_level(random_number) 55 | else: 56 | print("You choose an incorrect option, Please Try Again!") 57 | want_to_play = input("Do you want to play Again Type 'yes' or 'no': ") 58 | if want_to_play == "yes": 59 | play_again = True 60 | clear_screen() 61 | else: 62 | print("Thank you for playing the game Program written by Yethishwar.\nYour participation is appreciated!") 63 | play_again = False -------------------------------------------------------------------------------- /014-Instagram Followers Game/Ascii_Art.py: -------------------------------------------------------------------------------- 1 | logo = """ 2 | __ ___ __ 3 | / / / (_)___ _/ /_ ___ _____ 4 | / /_/ / / __ `/ __ \/ _ \/ ___/ 5 | / __ / / /_/ / / / / __/ / 6 | /_/ ///_/\__, /_/ /_/\___/_/ 7 | / / /____/_ _____ _____ 8 | / / / __ \ | /| / / _ \/ ___/ 9 | / /___/ /_/ / |/ |/ / __/ / 10 | /_____/\____/|__/|__/\___/_/ 11 | """ 12 | 13 | 14 | vs = """ 15 | _ __ 16 | | | / /____ 17 | | | / / ___/ 18 | | |/ (__ ) 19 | |___/____(_) 20 | """ 21 | print(logo) 22 | print(vs) -------------------------------------------------------------------------------- /014-Instagram Followers Game/Data.py: -------------------------------------------------------------------------------- 1 | data = [ 2 | { 3 | 'name': 'Virat Kohli', 4 | 'follower_count': 55, 5 | 'description': 'Cricketer', 6 | 'country': 'India' 7 | }, 8 | { 9 | 'name': 'Priyanka Chopra Jonas', 10 | 'follower_count': 53, 11 | 'description': 'Actress and musician', 12 | 'country': 'India' 13 | }, 14 | { 15 | 'name': 'Virat Kohli', 16 | 'follower_count': 55, 17 | 'description': 'Cricketer', 18 | 'country': 'India' 19 | }, 20 | { 21 | 'name': 'Narendra Modi', 22 | 'follower_count': 46, 23 | 'description': 'Prime Minister of India', 24 | 'country': 'India' 25 | }, 26 | { 27 | 'name': 'Sachin Tendulkar', 28 | 'follower_count': 44, 29 | 'description': 'Former cricketer', 30 | 'country': 'India' 31 | }, 32 | { 33 | 'name': 'Shah Rukh Khan', 34 | 'follower_count': 41, 35 | 'description': 'Actor', 36 | 'country': 'India' 37 | }, 38 | { 39 | 'name': 'Amitabh Bachchan', 40 | 'follower_count': 40, 41 | 'description': 'Actor', 42 | 'country': 'India' 43 | }, 44 | { 45 | 'name': 'Salman Khan', 46 | 'follower_count': 38, 47 | 'description': 'Actor', 48 | 'country': 'India' 49 | }, 50 | { 51 | 'name': 'Deepika Padukone', 52 | 'follower_count': 36, 53 | 'description': 'Actress', 54 | 'country': 'India' 55 | }, 56 | { 57 | 'name': 'Ratan Tata', 58 | 'follower_count': 35, 59 | 'description': 'Businessman', 60 | 'country': 'India' 61 | }, 62 | { 63 | 'name': 'Akshay Kumar', 64 | 'follower_count': 34, 65 | 'description': 'Actor', 66 | 'country': 'India' 67 | }, 68 | { 69 | 'name': 'Mukesh Ambani', 70 | 'follower_count': 33, 71 | 'description': 'Businessman', 72 | 'country': 'India' 73 | }, 74 | { 75 | 'name': 'Ranveer Singh', 76 | 'follower_count': 32, 77 | 'description': 'Actor', 78 | 'country': 'India' 79 | }, 80 | { 81 | 'name': 'Alia Bhatt', 82 | 'follower_count': 31, 83 | 'description': 'Actress', 84 | 'country': 'India' 85 | }, 86 | { 87 | 'name': 'Virat Kohli', 88 | 'follower_count': 30, 89 | 'description': 'Cricketer', 90 | 'country': 'India' 91 | }, 92 | { 93 | 'name': 'Anushka Sharma', 94 | 'follower_count': 28, 95 | 'description': 'Actress', 96 | 'country': 'India' 97 | }, 98 | { 99 | 'name': 'Rahul Gandhi', 100 | 'follower_count': 27, 101 | 'description': 'Politician', 102 | 'country': 'India' 103 | }, 104 | { 105 | 'name': 'MS Dhoni', 106 | 'follower_count': 25, 107 | 'description': 'Former cricketer', 108 | 'country': 'India' 109 | }, 110 | { 111 | 'name': 'Katrina Kaif', 112 | 'follower_count': 24, 113 | 'description': 'Actress', 114 | 'country': 'India' 115 | }, 116 | { 117 | 'name': 'Shahid Kapoor', 118 | 'follower_count': 23, 119 | 'description': 'Actor', 120 | 'country': 'India' 121 | }, 122 | { 123 | 'name': 'Rohit Sharma', 124 | 'follower_count': 22, 125 | 'description': 'Cricketer', 126 | 'country': 'India' 127 | }, 128 | { 129 | 'name': 'Kapil Sharma', 130 | 'follower_count': 21, 131 | 'description': 'Comedian', 132 | 'country': 'India' 133 | }, 134 | { 135 | 'name': 'Varun Dhawan', 136 | 'follower_count': 20, 137 | 'description': 'Actor', 138 | 'country': 'India' 139 | }, 140 | { 141 | 'name': 'Priyanka Chopra Jonas', 142 | 'follower_count': 19, 143 | 'description': 'Actress and musician', 144 | 'country': 'India' 145 | }, 146 | { 147 | 'name': 'Aamir Khan', 148 | 'follower_count': 18, 149 | 'description': 'Actor', 150 | 'country': 'India' 151 | }, 152 | { 153 | 'name': 'Anil Kapoor', 154 | 'follower_count': 17, 155 | 'description': 'Actor', 156 | 'country': 'India' 157 | }, 158 | { 159 | 'name': 'Kajol', 160 | 'follower_count': 16, 161 | 'description': 'Actress', 162 | 'country': 'India' 163 | }, 164 | { 165 | 'name': 'Rajinikanth', 166 | 'follower_count': 15, 167 | 'description': 'Actor', 168 | 'country': 'India' 169 | }, 170 | { 171 | 'name': 'Ranbir Kapoor', 172 | 'follower_count': 14, 173 | 'description': 'Actor', 174 | 'country': 'India' 175 | }, 176 | { 177 | 'name': 'Shreya Ghoshal', 178 | 'follower_count': 13, 179 | 'description': 'Singer', 180 | 'country': 'India' 181 | }, 182 | { 183 | 'name': 'Hrithik Roshan', 184 | 'follower_count': 12, 185 | 'description': 'Actor', 186 | 'country': 'India' 187 | }, 188 | { 189 | 'name': 'Nawazuddin Siddiqui', 190 | 'follower_count': 11, 191 | 'description': 'Actor', 192 | 'country': 'India' 193 | }, 194 | { 195 | 'name': 'Sonam Kapoor', 196 | 'follower_count': 10, 197 | 'description': 'Actress', 198 | 'country': 'India' 199 | }, 200 | { 201 | 'name': 'Pawan Kalyan', 202 | 'follower_count': 9, 203 | 'description': 'Actor and politician', 204 | 'country': 'India' 205 | }, 206 | { 207 | 'name': 'Vidya Balan', 208 | 'follower_count': 8, 209 | 'description': 'Actress', 210 | 'country': 'India' 211 | }, 212 | { 213 | 'name': 'Nawazuddin Siddiqui', 214 | 'follower_count': 7, 215 | 'description': 'Actor', 216 | 'country': 'India' 217 | }, 218 | { 219 | 'name': 'Mahesh Babu', 220 | 'follower_count': 6, 221 | 'description': 'Actor', 222 | 'country': 'India' 223 | }, 224 | { 225 | 'name': 'Rajkummar Rao', 226 | 'follower_count': 5, 227 | 'description': 'Actor', 228 | 'country': 'India' 229 | }, 230 | { 231 | 'name': 'Prabhas', 232 | 'follower_count': 4, 233 | 'description': 'Actor', 234 | 'country': 'India' 235 | }, 236 | { 237 | 'name': 'Ram Charan', 238 | 'follower_count': 3, 239 | 'description': 'Actor', 240 | 'country': 'India' 241 | }, 242 | { 243 | 'name': 'Allu Arjun', 244 | 'follower_count': 2, 245 | 'description': 'Actor', 246 | 'country': 'India' 247 | }, 248 | { 249 | 'name': 'Rohit Sharma', 250 | 'follower_count': 1, 251 | 'description': 'Cricketer', 252 | 'country': 'India' 253 | }, 254 | { 255 | 'name': 'Shikhar Dhawan', 256 | 'follower_count': 1, 257 | 'description': 'Cricketer', 258 | 'country': 'India' 259 | }, 260 | { 261 | 'name': 'Jasprit Bumrah', 262 | 'follower_count': 1, 263 | 'description': 'Cricketer', 264 | 'country': 'India' 265 | }, 266 | { 267 | 'name': 'Hardik Pandya', 268 | 'follower_count': 1, 269 | 'description': 'Cricketer', 270 | 'country': 'India' 271 | }, 272 | { 273 | 'name': 'Ravindra Jadeja', 274 | 'follower_count': 1, 275 | 'description': 'Cricketer', 276 | 'country': 'India' 277 | }, 278 | { 279 | 'name': 'Rishabh Pant', 280 | 'follower_count': 1, 281 | 'description': 'Cricketer', 282 | 'country': 'India' 283 | }, 284 | { 285 | 'name': 'KL Rahul', 286 | 'follower_count': 1, 287 | 'description': 'Cricketer', 288 | 'country': 'India' 289 | } 290 | ] 291 | -------------------------------------------------------------------------------- /014-Instagram Followers Game/README.md: -------------------------------------------------------------------------------- 1 | # Instagram Followers Game 2 | 3 | This is a simple Python program that quizzes users on which of two randomly selected Instagram profiles has more followers. The program displays two profiles at a time, and the user selects either 'A' or 'B' to indicate which profile they think has more followers. 4 | 5 | ## Topics Covered 6 | 7 | ### 1. Python Basics 8 | 9 | - Variables 10 | - Functions 11 | - Loops (while loop) 12 | - Conditionals (if-else statements) 13 | 14 | ### 2. File Handling 15 | 16 | - Importing data from external files (`Data.py` and `Ascii_Art.py`) 17 | 18 | ### 3. External Libraries 19 | 20 | - Using the `random` module to make random selections 21 | - Using the `os` module to clear the console screen 22 | 23 | ### 4. Data Structures 24 | 25 | - Dictionaries: Storing and accessing profile data 26 | 27 | ### 5. User Input 28 | 29 | - Taking user input to determine the user's choice 30 | 31 | ### 6. String Formatting 32 | 33 | - Formatting strings to display profile information 34 | 35 | ### 7. Conditional Logic 36 | 37 | - Checking if the user's choice is correct 38 | - Using functions to evaluate conditions 39 | 40 | ### 8. Control Flow 41 | 42 | - Looping until a condition is met (`while` loop) 43 | - Breaking out of a loop 44 | 45 | ### 9. Clearing Console Screen 46 | 47 | - Using the `os` module to clear the console screen for a better user experience 48 | 49 | ### 10. Documentation 50 | 51 | - Providing comments within the code for clarity 52 | 53 | ### 11. Error Handling 54 | 55 | - Although not explicitly implemented, potential areas for error handling can be identified, such as handling invalid user inputs. 56 | 57 | ## Sample Output 58 | 59 | ```plaintext 60 | User 61 | Compare A: Selena Gomez, an American singer, from United States. 62 | Against B: Ashton Kutcher, an American actor, from United States. 63 | Who has more followers? Type 'A' or 'B': a 64 | 65 | You're right! Current Score: 1 66 | 67 | Compare A: Selena Gomez, an American singer, from United States. 68 | Against B: Maluma, a Colombian singer, from Colombia. 69 | Who has more followers? Type 'A' or 'B': b 70 | 71 | Sorry! that's wrong Final Score: 1 72 | 73 | -------------------------------------------------------------------------------- /014-Instagram Followers Game/code.py: -------------------------------------------------------------------------------- 1 | 2 | from Data import data 3 | from Ascii_Art import logo, vs 4 | import random 5 | import os 6 | 7 | #Clears the console screen whenever requires. 8 | def clear(): 9 | os.system('cls' if os.name == 'nt' else 'clear') 10 | clear() 11 | 12 | #Checks which person has more followers and returns True or False. 13 | def which_is_greater(count_A,count_B,decision): 14 | if count_A > count_B: 15 | return decision == "a" 16 | else: 17 | return decision == "b" 18 | 19 | score = 0 20 | to_continue = True 21 | random_person2 = random.choice(data) 22 | 23 | #Repeat the loop until user chose an incorrect one.s 24 | while to_continue: 25 | print(logo) 26 | random_person1 = random_person2 27 | random_person2 = random.choice(data) 28 | 29 | if random_person1 == random_person2: 30 | random_person2 = random.choice(data) 31 | 32 | # Fomrating the data inside the dictionary. 33 | person1 = (f"Compare A: {random_person1['name']}, a {random_person1['description']}, from {random_person1['country']}.") 34 | person2 = (f"Against B: {random_person2['name']}, a {random_person2['description']}, from {random_person2['country']}.") 35 | print(person1) 36 | print(vs) 37 | print(person2) 38 | user_desicion = input("Who has more followers? Type 'A' or 'B': ").lower() 39 | person1_followers = random_person1['follower_count'] 40 | person2_followers = random_person2['follower_count'] 41 | is_correct = which_is_greater(person1_followers,person2_followers,user_desicion) 42 | clear() 43 | print(logo) 44 | if is_correct: 45 | score += 1 46 | print(f"You,re right! Current Score: {score}") 47 | else: 48 | to_continue = False 49 | print(f"Sorry! that's wrong Final Score: {score}") -------------------------------------------------------------------------------- /015-Coffee Machine/data.py: -------------------------------------------------------------------------------- 1 | menu = { 2 | "sleepy owl coffee": { 3 | "ingredients": { 4 | "milk": 0, 5 | "water": 50, 6 | "coffee": 18, 7 | }, 8 | "cost": 100, 9 | }, 10 | "irani chai": { 11 | "ingredients": { 12 | "water": 200, 13 | "milk": 150, 14 | "coffee": 24, 15 | }, 16 | "cost": 200, 17 | }, 18 | "masala chai": { 19 | "ingredients": { 20 | "water": 250, 21 | "milk": 100, 22 | "coffee": 24, 23 | }, 24 | "cost": 300, 25 | } 26 | } 27 | 28 | resources = { 29 | "water": 300, 30 | "milk": 200, 31 | "coffee": 100, 32 | "money": 0 33 | } 34 | 35 | -------------------------------------------------------------------------------- /015-Coffee Machine/mycode.py: -------------------------------------------------------------------------------- 1 | from data import menu, resources 2 | import os 3 | # ☕ 4 | # ₹ 5 | def is_transaction_successfull(m_value,item): 6 | """returns true if user entered sufficient money as required to make a drink""" 7 | if m_value >= item['cost']: 8 | change = m_value - item['cost'] 9 | return change, True 10 | else: 11 | return 0,False 12 | def deduct_resources(i): 13 | ingredients = i['ingredients'] 14 | resources['water'] -= ingredients['water'] 15 | resources['milk'] -= ingredients['milk'] 16 | resources['coffee'] -= ingredients['coffee'] 17 | 18 | 19 | def process_coins(): 20 | """Returns the total calculated amount From coins inserted""" 21 | print("Please insert Coins") 22 | one = int(input("How many ONE rupee coins?")) 23 | two = int(input("How many TWO rupee coins?")) 24 | five = int(input("How many FIVE rupee coins?")) 25 | ten = int(input("How many TEN rupee coins?")) 26 | total_value = ((one * 1) + (two * 2) + (five * 5) + (ten * 10)) 27 | return total_value 28 | 29 | def check_resources(item): 30 | """returns true if resources available or false if it is not available""" 31 | ingredients = item['ingredients'] 32 | if (resources['water'] < ingredients['water']): 33 | return "water",False 34 | elif (resources['milk'] < ingredients['milk']): 35 | return "milk",False 36 | elif (resources['coffee'] < ingredients['coffee']): 37 | return "coffee",False 38 | else: 39 | return "available",True 40 | 41 | def return_report(): 42 | """Returns a report of the present resources""" 43 | return f"water: {resources['water']}ml\nmilk: {resources['milk']}ml\ncoffee: {resources['coffee']}g\nmoney: ₹{resources['money']}" 44 | 45 | machine_active = True 46 | while machine_active == True: 47 | user_choice = input("Here is your menu👇\nSleepy Owl Coffee - ₹100\nIrani Chai - ₹200\nMasala Chai - ₹300\nWhat would you like?").lower() 48 | if user_choice == 'off': 49 | machine_active = False 50 | elif user_choice == 'report': 51 | print(f"Here is your report:\n{return_report()}") 52 | elif ((user_choice == 'masala chai') or ( user_choice == 'irani chai') or (user_choice == 'sleepy owl coffee')): 53 | item = menu[user_choice] 54 | is_resources_available = check_resources(item) 55 | if is_resources_available[1] == True: 56 | payment = process_coins() 57 | transaction = is_transaction_successfull(payment, item) 58 | if transaction[1]: 59 | resources['money'] += item['cost'] 60 | if transaction[0] != 0: 61 | print(f"Here is ₹{transaction[0]} change") 62 | deduct_resources(item) 63 | print(f"Here is your {user_choice}☕. ENJOY!") 64 | else: 65 | print("Sorry that's not enough money. Money refunded!") 66 | else: 67 | print(f"Sorry there is not enough {is_resources_available[0]}") 68 | 69 | else: 70 | print("Please select the item which is in the menu Correctly.") 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /015-Coffee Machine/solution_code.py: -------------------------------------------------------------------------------- 1 | MENU = { 2 | "espresso": { 3 | "ingredients": { 4 | "water": 50, 5 | "coffee": 18, 6 | }, 7 | "cost": 1.5, 8 | }, 9 | "latte": { 10 | "ingredients": { 11 | "water": 200, 12 | "milk": 150, 13 | "coffee": 24, 14 | }, 15 | "cost": 2.5, 16 | }, 17 | "cappuccino": { 18 | "ingredients": { 19 | "water": 250, 20 | "milk": 100, 21 | "coffee": 24, 22 | }, 23 | "cost": 3.0, 24 | } 25 | } 26 | 27 | profit = 0 28 | resources = { 29 | "water": 300, 30 | "milk": 200, 31 | "coffee": 100, 32 | } 33 | 34 | 35 | def is_resource_sufficient(order_ingredients): 36 | """Returns True when order can be made, False if ingredients are insufficient.""" 37 | for item in order_ingredients: 38 | if order_ingredients[item] > resources[item]: 39 | print(f"​Sorry there is not enough {item}.") 40 | return False 41 | return True 42 | 43 | 44 | def process_coins(): 45 | """Returns the total calculated from coins inserted.""" 46 | print("Please insert coins.") 47 | total = int(input("how many quarters?: ")) * 0.25 48 | total += int(input("how many dimes?: ")) * 0.1 49 | total += int(input("how many nickles?: ")) * 0.05 50 | total += int(input("how many pennies?: ")) * 0.01 51 | return total 52 | 53 | 54 | def is_transaction_successful(money_received, drink_cost): 55 | """Return True when the payment is accepted, or False if money is insufficient.""" 56 | if money_received >= drink_cost: 57 | change = round(money_received - drink_cost, 2) 58 | print(f"Here is ${change} in change.") 59 | global profit 60 | profit += drink_cost 61 | return True 62 | else: 63 | print("Sorry that's not enough money. Money refunded.") 64 | return False 65 | 66 | 67 | def make_coffee(drink_name, order_ingredients): 68 | """Deduct the required ingredients from the resources.""" 69 | for item in order_ingredients: 70 | resources[item] -= order_ingredients[item] 71 | print(f"Here is your {drink_name} ☕️. Enjoy!") 72 | 73 | 74 | is_on = True 75 | 76 | while is_on: 77 | choice = input("​What would you like? (espresso/latte/cappuccino): ") 78 | if choice == "off": 79 | is_on = False 80 | elif choice == "report": 81 | print(f"Water: {resources['water']}ml") 82 | print(f"Milk: {resources['milk']}ml") 83 | print(f"Coffee: {resources['coffee']}g") 84 | print(f"Money: ${profit}") 85 | else: 86 | drink = MENU[choice] 87 | if is_resource_sufficient(drink["ingredients"]): 88 | payment = process_coins() 89 | if is_transaction_successful(payment, drink["cost"]): 90 | make_coffee(choice, drink["ingredients"]) 91 | 92 | -------------------------------------------------------------------------------- /016-Coffee Machine using 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 | -------------------------------------------------------------------------------- /016-Coffee Machine using OOP/main.py: -------------------------------------------------------------------------------- 1 | from menu import Menu, MenuItem 2 | from coffee_maker import CoffeeMaker 3 | from money_machine import MoneyMachine 4 | 5 | #Making instances of all classes. 6 | coffe_maker = CoffeeMaker() 7 | money_machine = MoneyMachine() 8 | menu = Menu() 9 | 10 | 11 | is_on = True 12 | while is_on : 13 | options = menu.get_items() 14 | choice = input(f"What would you like? {options}:") 15 | if choice == 'off': 16 | is_on = False 17 | elif choice == 'report': 18 | coffe_maker.report() 19 | money_machine.report() 20 | else: 21 | drink = menu.find_drink(choice) 22 | if coffe_maker.is_resource_sufficient(drink): 23 | if money_machine.make_payment(drink.cost ): 24 | coffe_maker.make_coffee(drink) 25 | 26 | -------------------------------------------------------------------------------- /016-Coffee Machine using 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 | -------------------------------------------------------------------------------- /016-Coffee Machine using 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 | -------------------------------------------------------------------------------- /017-Quiz Game/data.py: -------------------------------------------------------------------------------- 1 | question_data = [ 2 | {"text": "A slug's blood is green.", "answer": "True"}, 3 | {"text": "The loudest animal is the African Elephant.", "answer": "False"}, 4 | {"text": "Approximately one quarter of human bones are in the feet.", "answer": "True"}, 5 | {"text": "The total surface area of a human lungs is the size of a football pitch.", "answer": "True"}, 6 | {"text": "In West Virginia, USA, if you accidentally hit an animal with your car," 7 | " you are free to take it home to eat.", "answer": "True"}, 8 | {"text": "In London, UK, if you happen to die in the House of Parliament, you are entitled to a state funeral.", 9 | "answer": "False"}, 10 | {"text": "It is illegal to pee in the Ocean in Portugal.", "answer": "True"}, 11 | {"text": "You can lead a cow down stairs but not up stairs.", "answer": "False"}, 12 | {"text": "Google was originally called 'Backrub'.", "answer": "True"}, 13 | {"text": "Buzz Aldrin's mother's maiden name was 'Moon'.", "answer": "True"}, 14 | {"text": "No piece of square dry paper can be folded in half more than 7 times.", "answer": "False"}, 15 | {"text": "A few ounces of chocolate can to kill a small dog.", "answer": "True"} 16 | ] -------------------------------------------------------------------------------- /017-Quiz Game/main.py: -------------------------------------------------------------------------------- 1 | from question_model import Question 2 | from data import question_data 3 | from quiz_brain import QuizBrain 4 | 5 | question_bank = [] 6 | for item in question_data: 7 | question_text = item['text'] 8 | question_answer = item['answer'] 9 | new_question = Question(question_text,question_answer) 10 | question_bank.append(new_question) 11 | 12 | quiz = QuizBrain(question_bank) 13 | while quiz.still_has_questions(): 14 | quiz.next_question() 15 | print("You've completed the quiz") 16 | print(f"Your final score was: {quiz.score}/{len(question_bank)}") 17 | 18 | # print(question_bank[0].text) -------------------------------------------------------------------------------- /017-Quiz Game/question_model.py: -------------------------------------------------------------------------------- 1 | class Question: 2 | def __init__(self, text, answer): 3 | self.text = text 4 | self.answer = answer 5 | 6 | # new_question = Question('What is my name?', True) 7 | # print(new_question.answer) -------------------------------------------------------------------------------- /017-Quiz Game/quiz_brain.py: -------------------------------------------------------------------------------- 1 | class QuizBrain: 2 | def __init__(self,question_list): 3 | self.question_number = 0 4 | self.question_list = question_list 5 | self.score = 0 6 | 7 | 8 | def still_has_questions(self): 9 | if self.question_number <= len(self.question_list)-1: 10 | return True 11 | else: 12 | return False 13 | def next_question(self): 14 | current_question = self.question_list[self.question_number] 15 | self.question_number += 1 16 | user_answer = input(f"Q.{self.question_number}: {current_question.text} (True/False)?") 17 | self.check_answer(user_answer, current_question.answer) 18 | 19 | def check_answer(self,user_answer, current_answer): 20 | if user_answer.lower() == current_answer.lower(): 21 | self.score += 1 22 | print("You got it. Right!") 23 | else: 24 | print("That's Wrong!") 25 | print(f"The correct answer was: {current_answer}") 26 | print(f"Your Current Score is: {self.score}/{self.question_number}") 27 | print("\n") -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Madavaram Yethishwar 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Python Libraries/PrettyTable.py: -------------------------------------------------------------------------------- 1 | import prettytable as pt 2 | #Creating a prettytable object. 3 | table = pt.PrettyTable() 4 | table.add_column("Name",['Yethishwar','Chintu','Siddhartha','Sai kiran','Preethi']) 5 | table.add_column('Marks',[98,89,100,99,70]) 6 | table.align = 'l' #Alligned data to the left 7 | print(table) 8 | -------------------------------------------------------------------------------- /Python Libraries/Turtle_Star.py: -------------------------------------------------------------------------------- 1 | import turtle 2 | 3 | # Set up the screen 4 | screen = turtle.Screen() 5 | screen.bgcolor("black") 6 | # Create a turtle object 7 | star = turtle.Turtle() 8 | star.color("yellow") 9 | 10 | def draw_star(size): 11 | for _ in range(5): 12 | star.forward(size) 13 | star.right(144) # angle for a star 14 | 15 | draw_star(100) 16 | turtle.done() 17 | -------------------------------------------------------------------------------- /Python Programming/Python Learning NOTES.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MYethishwar/PythonHub/6afa4ddfd833b642a69aee085e21c8afa6342564/Python Programming/Python Learning NOTES.docx -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PythonHub Projects Repository 2 | 3 | Welcome to PythonHub! Below are the projects created up to now: 4 | 5 | ### Project 1: [Band Name Generator](https://github.com/MYethishwar/PythonHub/tree/main/Band%20Name%20Generator(Beginner)) 👈 6 | 7 | **Description**: Generate creative band names by combining random words or user inputs. 8 | 9 | ### Project 2: [Love Calculator](https://github.com/MYethishwar/PythonHub/tree/main/Love%20Calculator(Beginner)) 👈 10 | 11 | **Description**: Calculate the compatibility between two individuals based on their names. 12 | 13 | ### Project 3: [Tip Calculator](https://github.com/MYethishwar/PythonHub/tree/main/Tip%20Calculator(Beginner)) 👈 14 | 15 | **Description**: Calculate the appropriate tip amount based on the total bill and tip percentage. 16 | 17 | ### Project 4: [Treasure Island Adventure](https://github.com/MYethishwar/PythonHub/tree/main/Treasure%20Island%20Adventure(Beginner)) 👈 18 | 19 | **Description**: Embark on an interactive text-based adventure to find hidden treasure. 20 | 21 | ### Project 5: [Rock Paper Scissors](https://github.com/MYethishwar/PythonHub/tree/main/Rock%20Paper%20Scissors(Beginner)) 👈 22 | 23 | **Description**: A classic game where players choose between rock, paper, or scissors, aiming to beat their opponent's choice. 24 | 25 | ### Project 6: [Password Generator](https://github.com/MYethishwar/PythonHub/tree/main/Password%20Generator(Beginner)) 👈 26 | 27 | **Description**: A tool that generates random passwords based on user preferences for the number of letters, symbols, and numbers. 28 | 29 | ### Project 7: [Escaping the Maze](https://github.com/MYethishwar/PythonHub/tree/main/Escaping%20the%20Maze(Beginner)) 👈 30 | 31 | **Description**: Solving Reeborg's World challenge by writing code to escape the maze. 32 | 33 | ### Project 8: [Hangman Game](https://github.com/MYethishwar/PythonHub/tree/main/Hangman(Beginner)) 👈 34 | 35 | **Description**: Guess the hidden word by inputting letters before running out of lives. 36 | 37 | ### Project 9: [Caesar Game](https://github.com/MYethishwar/PythonHub/tree/main/Caesar%20Cipher(Beginner)) 👈 38 | 39 | **Description**: An interactive challenge where players encode and decode secret messages using the classic Caesar Cipher encryption technique. 40 | 41 | ### Project 10: [Secret Auction](https://github.com/MYethishwar/PythonHub/tree/main/Secret%20Auction(Beginner)) 👈 42 | 43 | **Description**: This Project enable participants to anonymously bid on items, with the highest bidder winning while maintaining their bid amount confidential to others. 44 | 45 | ### Project 11: [Calculator](https://github.com/MYethishwar/PythonHub/tree/main/Calculator(Beginner)) 👈 46 | 47 | **Description**: A Python calculator project incorporating basic arithmetic operations, recursion, and documentation strings for clarity and usability. 48 | 49 | ### Project 12: [BlackJack Game](https://github.com/MYethishwar/PythonHub/tree/main/012-BlackJack(Beginner)) 👈 50 | 51 | **Description**: The Blackjack game is a card game where players aim to get cards with a total value as close to 21 as possible without exceeding it. 52 | 53 | ### Project 13: [Make a Guess Game](https://github.com/MYethishwar/PythonHub/tree/main/013-Make%20a%20Guess(Beginner)) 👈 54 | 55 | **Description**: The player has to guess a randomly generated number between 1 and 100. The game offers two difficulty levels: easy and hard. 56 | 57 | ### Project 14: [Instagram Followers Game](https://github.com/MYethishwar/PythonHub/tree/main/014-Instagram%20Followers%20Game(Beginner)) 👈 58 | 59 | **Description**: The playes has to Guess the person who has more followers each time the user wins the score will be incremented. 60 | 61 | ### Project 15: [Coffee Machine](https://github.com/MYethishwar/PythonHub/tree/main/015-Coffee%20Machine(Intermediate)) 👈 62 | 63 | **Description**: Simple real life coffee machine simulator using simple understandable english statements. 64 | 65 | ### Project 16: [Coffee Machine using OOP](https://github.com/MYethishwar/PythonHub/tree/main/016-Coffee%20Machine%20using%20OOP(Intermediate)) 👈 66 | 67 | **Description**: Simple real life coffee machine simulator using predefined classes. 68 | 69 | ### Project 17: [Quiz Game](https://github.com/MYethishwar/PythonHub/tree/main/017-Quiz%20Game(Intermediate)) 👈 70 | 71 | **Description**: quiz game with 12 questions implimented using classes and objects of OOP. 72 | 73 | -------------------------------------------------------------------------------- /Tools.md: -------------------------------------------------------------------------------- 1 | # Tools 2 | ## Ascii Art Generator:- 3 | **Description**:Create your own Ascii Art simply by giving english words. 4 | ### [Ascii Art Generator](https://patorjk.com/software/taag/#p=display&v=2&f=Blocks&t=Guess)👈 5 | 6 | ## PythonTutor(Very Usefull tool to Debug the code). 7 | **Description**: PythonTutor allows users to visualize and step through the execution of Python code. It provides a visual representation of how Python code is executed, showing the changes to variables, data structures, and program state at each step. 8 | ### [Try PythonTutor](https://pythontutor.com/visualize.html#mode=edit)👈 9 | --------------------------------------------------------------------------------