├── BinarySearch ├── Caeser Cipher.py ├── Card_game_project ├── Code.py ├── Readme.md └── prog_gui.py ├── Code To Find LCM ├── Count_primes ├── Count_primes.py ├── Readme.md └── for..elseclause.py ├── Create Python Program to Find the Square Root.py ├── DNA_sequence_analysis ├── README.md └── bioinformatics_genomic.py ├── Djikshiktra_Algorithm.py ├── Email-response-sender └── email-response-sender │ ├── db.sqlite3 │ ├── emailsender │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-310.pyc │ │ ├── settings.cpython-310.pyc │ │ ├── urls.cpython-310.pyc │ │ └── wsgi.cpython-310.pyc │ ├── asgi.py │ ├── settings.py │ ├── urls.py │ └── wsgi.py │ ├── emailsenderapp │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-310.pyc │ │ ├── admin.cpython-310.pyc │ │ ├── apps.cpython-310.pyc │ │ ├── models.cpython-310.pyc │ │ ├── urls.cpython-310.pyc │ │ └── views.cpython-310.pyc │ ├── admin.py │ ├── apps.py │ ├── migrations │ │ ├── __init__.py │ │ └── __pycache__ │ │ │ └── __init__.cpython-310.pyc │ ├── models.py │ ├── templates │ │ └── query.html │ ├── tests.py │ ├── urls.py │ └── views.py │ └── manage.py ├── Gmail automation ├── Creating App Password ├── Searchfilter_commands.txt ├── input_mail.PNG ├── my_first_mail.PNG ├── readme.md ├── received_mail.PNG ├── receivefileswithpy.py └── sendmailswithpy.py ├── Heap_Sort.py ├── Insertion_Sort.py ├── MatrixMultiplier.py ├── MergeSort.py ├── Num_guess_by_Comp └── num_guess.py ├── Python Program to Find the Square Root.py ├── README.md ├── Snake Game using python ├── README.md ├── Snake_game.py └── snake.jpeg ├── Strassen_Multiplication.py ├── Summerof'69.py ├── Threecupsmonty ├── Readme.md ├── three_cups_monty.PNG └── three_cups_monty.py ├── TicTacToe ├── Finalprogram.py ├── MyfirstTry.py └── Readme.md ├── Tkinter ├── Basic_gui.py ├── Output.PNG ├── TV_Remote.py ├── image.png ├── rangoli.py └── readme.md ├── Tkinter_recommendation_system ├── code.py └── readme.md ├── Web scraping ├── Get_img.py ├── Rating_filter.py ├── Readme.md └── Syntax.txt ├── diamond_symbol.py ├── fibonacci_series.py ├── functionMaxMinMedian.py ├── gui_calculator.py ├── prime_numbers_in_input_range.py ├── quick_sort.py ├── readme.md ├── snake_game.py ├── snakegame.py ├── space_shoote.py ├── space_shooter.py ├── sum_of_elements_of_an_array.py ├── swap_elements_in_array.py ├── tempCodeRunnerFile.py └── towerOfHoni.py /BinarySearch: -------------------------------------------------------------------------------- 1 | def binary_search(arr, x): 2 | low = 0 3 | high = len(arr) - 1 4 | mid = 0 5 | 6 | while low <= high: 7 | 8 | mid = (high + low) // 2 9 | 10 | 11 | if arr[mid] < x: 12 | low = mid + 1 13 | 14 | 15 | elif arr[mid] > x: 16 | high = mid - 1 17 | 18 | 19 | else: 20 | return mid 21 | 22 | 23 | return -1 24 | 25 | 26 | # Test array 27 | arr = [ 1, 10, 15, 20, 30 ] 28 | x = 20 29 | 30 | # Function call 31 | result = binary_search(arr, x) 32 | 33 | if result != -1: 34 | print("Element is present at index", str(result)) 35 | else: 36 | print("Element is not present in array") 37 | -------------------------------------------------------------------------------- /Caeser Cipher.py: -------------------------------------------------------------------------------- 1 | import string 2 | logo = """ 3 | ,adPPYba, ,adPPYYba, ,adPPYba, ,adPPYba, ,adPPYYba, 8b,dPPYba, 4 | a8" "" "" `Y8 a8P_____88 I8[ "" "" `Y8 88P' "Y8 5 | 8b ,adPPPPP88 8PP""""""" `"Y8ba, ,adPPPPP88 88 6 | "8a, ,aa 88, ,88 "8b, ,aa aa ]8I 88, ,88 88 7 | `"Ybbd8"' `"8bbdP"Y8 `"Ybbd8"' `"YbbdP"' `"8bbdP"Y8 88 8 | 88 88 9 | "" 88 10 | 88 11 | ,adPPYba, 88 8b,dPPYba, 88,dPPYba, ,adPPYba, 8b,dPPYba, 12 | a8" "" 88 88P' "8a 88P' "8a a8P_____88 88P' "Y8 13 | 8b 88 88 d8 88 88 8PP""""""" 88 14 | "8a, ,aa 88 88b, ,a8" 88 88 "8b, ,aa 88 15 | `"Ybbd8"' 88 88`YbbdP"' 88 88 `"Ybbd8"' 88 16 | 88 17 | 88 18 | """ 19 | 20 | print(logo) 21 | 22 | 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'] 23 | 24 | 25 | def caesar(start_text, shift_amount, cipher_direction): 26 | end_text = "" 27 | if cipher_direction == "decode": 28 | shift_amount *= -1 29 | 30 | for char in start_text: 31 | if char not in string.ascii_lowercase: 32 | end_text += char 33 | continue 34 | else: 35 | position = alphabet.index(char) 36 | new_position = position + shift_amount 37 | end_text += alphabet[new_position] 38 | 39 | print(f"Here's the {cipher_direction}d result: {end_text}") 40 | 41 | 42 | while True: 43 | direction = input("Type 'encode' to encrypt, type 'decode' to decrypt:\n") 44 | text = input("Type your message:\n").lower() 45 | shift = int(input("Type the shift number:\n")) 46 | caesar(start_text=text, shift_amount=shift % 26, cipher_direction=direction) 47 | restart = input("Do you want to go again, type 'yes' or 'no':\n").lower() 48 | if restart == 'yes': 49 | pass 50 | else: 51 | break 52 | -------------------------------------------------------------------------------- /Card_game_project/Code.py: -------------------------------------------------------------------------------- 1 | #No GUI 2 | 3 | import random 4 | 5 | cards=('Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten', 'Jack', 'Queen', 'King', 'Ace') 6 | suits=("Heart", "Spade", "Diamond","Club") 7 | 8 | points={"Ace":14, "King":13, "Queen":12, "Jack":11, "One":1, "Two":2, "Three":3, "Four":4, "Five":5, 9 | "Six":6, "Seven":7, "Eight":8, "Nine":9, "Ten":10} 10 | 11 | class Cards: 12 | 13 | def __init__(self, suit, rank): 14 | self.rank=rank 15 | self.suit=suit 16 | self.pts=points[rank] 17 | 18 | def __str__(self): 19 | return self.rank 20 | 21 | class Create_Deck: 22 | def __init__(self): 23 | self.deck=[] 24 | 25 | for suit in suits: 26 | for card in cards: 27 | new_card=Cards(suit, card) 28 | self.deck.append(new_card) 29 | 30 | random.shuffle(self.deck) #shuffled the created deck 31 | 32 | def deal_1(self): 33 | return self.deck.pop() 34 | 35 | 36 | def split_deck(self): 37 | d1=[] 38 | d2=[] 39 | for x in range(26): 40 | d1.append(self.deal_1()) 41 | d2.append(self.deal_1()) 42 | 43 | return d1, d2 44 | 45 | class Gameplay: 46 | 47 | def __init__(self, name,deck): 48 | self.name=name 49 | self.deck=deck 50 | 51 | def draw(self): 52 | return self.deck.pop() 53 | 54 | 55 | def add_cards(self,added_cards): 56 | if type(added_cards) == type([]): 57 | self.deck.extend(added_cards) 58 | else: 59 | self.deck.append(added_cards) 60 | print(f"{self.name} player has {len(self.deck)} cards") 61 | 62 | def check_value(card): 63 | return( points[card]) 64 | 65 | def main(): 66 | print("\t WELCOME TO the CARD GAME- WAR!\n\n") 67 | print("Let's shufle,divide and start!") 68 | d=Create_Deck() 69 | play1, play2= d.split_deck() 70 | p1=Gameplay("Player 1", play1) 71 | p2=Gameplay("Player 2", play2) 72 | 73 | 74 | outcome=False 75 | 76 | while(outcome==False): 77 | 78 | if(len(p1.deck)==0): 79 | print("Player 1 is out of cards") 80 | print("Player 2 wins!" ) 81 | outcome=True 82 | break 83 | elif(len(p2.deck)==0): 84 | print("Player 2 is out of cards") 85 | print("Player 1 wins!" ) 86 | outcome=True 87 | break 88 | card1=str(p1.draw()) 89 | card2=str(p2.draw()) 90 | 91 | #Check which card has bigger value 92 | if(check_value(card1)>check_value(card2)): 93 | print("Player one won this round") 94 | p1.add_cards(card2) 95 | elif(check_value(card1)0): 117 | if(check_value(str(p1.deck[-1]))>check_value(str(p2.deck[-1]))): 118 | #Add cards onto winners pile 119 | ctr=0 120 | list_won=[] 121 | #Pop cards from loser's deck 122 | while(ctr<5): 123 | ctr=ctr+1 124 | i=p2.draw() 125 | list_won.append(i) 126 | 127 | 128 | p1.add_cards(list_won) 129 | print("Player 1 won this round") 130 | round=round -1 131 | break 132 | 133 | elif(check_value(str(p1.deck[-1]))check_value(card2)): 134 | gameLog.insert(0.0,"Player 1 won this round\n" ) 135 | p1.add_cards(card2) 136 | elif(check_value(card1)0): 159 | if(check_value(str(p1.deck[-1]))>check_value(str(p2.deck[-1]))): 160 | #Add cards onto winners pile 161 | ctr=0 162 | list_won=[] 163 | #Pop cards from loser's deck 164 | while(ctr<5): 165 | ctr=ctr+1 166 | i=p2.draw() 167 | list_won.append(i) 168 | 169 | 170 | p1.add_cards(list_won) 171 | btnLog.insert(0.0,"Player 1 won this round\n") 172 | round=round -1 173 | break 174 | 175 | elif(check_value(str(p1.deck[-1])) y: 7 | greater = x 8 | else: 9 | greater = y 10 | 11 | while(True): 12 | if((greater % x == 0) and (greater % y == 0)): 13 | lcm = greater 14 | break 15 | greater += 1 16 | 17 | return lcm 18 | 19 | num1 = 54 20 | num2 = 24 21 | 22 | print("The L.C.M. is", compute_lcm(num1, num2)) 23 | -------------------------------------------------------------------------------- /Count_primes/Count_primes.py: -------------------------------------------------------------------------------- 1 | def count_primes2(num): 2 | primes = [2] 3 | 4 | x = 3 5 | if num < 2: 6 | return 0 7 | while x <= num: 8 | for y in primes: # use the primes list! 9 | if x%y == 0: 10 | x += 2 11 | break 12 | else: 13 | primes.append(x) 14 | x += 2 15 | print(primes) 16 | #added amount_primes variable 17 | amount_primes = len(primes) 18 | #lists how many prime numbers in range 19 | print("The amount of prime numbers between 0 and " + str(num) + " is " + str(amount_primes)) 20 | 21 | 22 | return len(primes) 23 | 24 | num= int(input("Enter limit: ")) 25 | count_primes2(num) -------------------------------------------------------------------------------- /Count_primes/Readme.md: -------------------------------------------------------------------------------- 1 | ### For...Else 2 | for loops also have an else clause which most of us are unfamiliar with. 3 | The else clause executes after the loop completes normally. This means that the loop did not encounter a break statement. 4 | -------------------------------------------------------------------------------- /Count_primes/for..elseclause.py: -------------------------------------------------------------------------------- 1 | for n in range(2, 10): 2 | for x in range(2, n): 3 | if n % x == 0: 4 | print( n, 'equals', x, '*', n/x) 5 | break 6 | else: 7 | # loop fell through without finding a factor 8 | print(n, 'is a prime number') -------------------------------------------------------------------------------- /Create Python Program to Find the Square Root.py: -------------------------------------------------------------------------------- 1 | # Python Program to calculate the square root 2 | 3 | # Note: change this value for a different result 4 | 5 | num = 8 6 | 7 | # To take the input from the user 8 | 9 | #num = float(input('Enter a number: ')) 10 | 11 | num_sqrt = num ** 0.5 12 | 13 | print('The square root of %0.3f is %0.3f'%(num ,num_sqrt)) 14 | 15 | -------------------------------------------------------------------------------- /DNA_sequence_analysis/README.md: -------------------------------------------------------------------------------- 1 | ## DNA Sequence Analysis 2 | ### Function_1: 3 | > Determines the number of differences in genomic sequence when comparing two individual sequences 4 | ### Function_2: 5 | > Encodes a seqence of genomic characters. 6 | ### Function_3: 7 | > Decodes a sequence of genomic characters. 8 | -------------------------------------------------------------------------------- /DNA_sequence_analysis/bioinformatics_genomic.py: -------------------------------------------------------------------------------- 1 | #note to Viewer: this is just a small collection of functions specific for bioinformatic genomic usage. 2 | #they are fun and help intertwine computer science and genetics! 3 | #hope you have fun! 4 | 5 | 6 | def hamming_distance(seq1, seq2): 7 | ''' 8 | Function will determine the number of differences in genomic sequence when comparing two individual sequences. 9 | 10 | Arg: Two separate sequences (str) 11 | Output: Number of differences (int) 12 | 13 | Example: hamming_distance("ATCTGGT","ATGAAGT") 14 | --> 3 15 | ''' 16 | 17 | tempo_result = zip(seq1, seq2) 18 | seq_counter = 0 19 | 20 | for i, j in tempo_result: 21 | if i != j: 22 | seq_counter += 1 23 | 24 | return seq_counter 25 | 26 | 27 | 28 | def seq_encode(seq): 29 | ''' 30 | Function to encode a seqence of genomic characters. 31 | 32 | Arg: Sequence of interest (str) 33 | Output: Encoded version of sequence (str) 34 | 35 | Example: seq_encode('CTTTCCCAAAG$$AAT') 36 | --> 'C3T3C3AG2$2AT' 37 | 38 | ''' 39 | #initialize an empty list. 40 | encoded_lst = [] 41 | count = 0 42 | 43 | #we need to start at the beginning of the string. 44 | for index, char in enumerate(seq): 45 | # print(char) 46 | # print(index) 47 | if index == 0: #if we're at the beginning of the string. 48 | current_char = seq[index] #set the current character to euqal whatever value is in that character. 49 | count = 1 50 | # print(current_char) 51 | if index != 0: #else if the character is NOT the first character, we need to check if it's the same as the previous char. 52 | current_char = seq[index] 53 | previous_char = seq[index - 1] 54 | if current_char == previous_char: #if true continue to count. 55 | count += 1 56 | # print(index) 57 | # print(current_char) 58 | # encoded_list.append(current_char) 59 | if current_char != previous_char: #if the next character is NOT the same character as the previous one. 60 | #we need to stop the loop and append to our encoded_list. 61 | #we don't want to include the number 1. 62 | if count == 1: 63 | encoded_lst.append(previous_char) 64 | else: 65 | encoded_lst.append(str(count) + previous_char) 66 | count = 1 67 | if index == len(seq) - 1: #this is to include the very last character in the string. 68 | #we don't want to include the number 1 here too. So need to exclude it. 69 | if count == 1: 70 | encoded_lst.append(current_char) 71 | else: 72 | encoded_lst.append(str(count) + current_char) 73 | 74 | encoded_result = "".join(encoded_lst) 75 | 76 | # return type(encoded_string) 77 | return encoded_result 78 | 79 | def seq_decode(seq): 80 | ''' 81 | Function to decode a sequence of genomic characters. 82 | 83 | Arg: Sequence of interest (str) 84 | Output: Decoded version of sequence (str) 85 | 86 | Example: seq_encode('C3T3C3AG2$2AT') 87 | --> 'CTTTCCCAAAG$$AAT' 88 | ''' 89 | 90 | decode_lst = [] #tempo holding list 91 | skip_char = False #don't want to skip the first char 92 | 93 | for index, char in enumerate(seq): 94 | 95 | if skip_char == True: 96 | skip_char = False #change back to False 97 | continue #skip the present char thru continue 98 | 99 | if skip_char == False: 100 | if char.isnumeric(): 101 | decode_lst.append(int(char)*seq[index + 1]) #this char is an integer 102 | skip_char = True #skip next char 103 | elif char.isalpha(): 104 | decode_lst.append(char) #just appending a str 105 | skip_char = False 106 | else: #including all symbols 107 | decode_lst.append(char) 108 | skip_char = False 109 | 110 | decoded_result = "".join(decode_lst) #combine all str values into one str 111 | return decoded_result 112 | 113 | 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /Djikshiktra_Algorithm.py: -------------------------------------------------------------------------------- 1 | 2 | class Graph(): 3 | 4 | def __init__(self, vertices): 5 | self.V = vertices 6 | self.graph = [[0 for column in range(vertices)] 7 | for row in range(vertices)] 8 | 9 | def printSolution(self, dist): 10 | print("Vertex \t Distance from Source") 11 | for node in range(self.V): 12 | print(node, "\t\t", dist[node]) 13 | 14 | 15 | def minDistance(self, dist, sptSet): 16 | 17 | min = 1e7 18 | 19 | for v in range(self.V): 20 | if dist[v] < min and sptSet[v] == False: 21 | min = dist[v] 22 | min_index = v 23 | 24 | return min_index 25 | 26 | def dijkstra(self, src): 27 | 28 | dist = [1e7] * self.V 29 | dist[src] = 0 30 | sptSet = [False] * self.V 31 | 32 | for cout in range(self.V): 33 | u = self.minDistance(dist, sptSet) 34 | sptSet[u] = True 35 | 36 | for v in range(self.V): 37 | if (self.graph[u][v] > 0 and 38 | sptSet[v] == False and 39 | dist[v] > dist[u] + self.graph[u][v]): 40 | dist[v] = dist[u] + self.graph[u][v] 41 | 42 | self.printSolution(dist) 43 | 44 | 45 | g = Graph(9) 46 | g.graph = [[0, 4, 0, 0, 0, 0, 0, 8, 0], 47 | [4, 0, 8, 0, 0, 0, 0, 11, 0], 48 | [0, 8, 0, 7, 0, 4, 0, 0, 2], 49 | [0, 0, 7, 0, 9, 14, 0, 0, 0], 50 | [0, 0, 0, 9, 0, 10, 0, 0, 0], 51 | [0, 0, 4, 14, 10, 0, 2, 0, 0], 52 | [0, 0, 0, 0, 0, 2, 0, 1, 6], 53 | [8, 11, 0, 0, 0, 0, 1, 0, 7], 54 | [0, 0, 2, 0, 0, 0, 6, 7, 0] 55 | ] 56 | 57 | g.dijkstra(0) 58 | 59 | -------------------------------------------------------------------------------- /Email-response-sender/email-response-sender/db.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aishanipach/Beginners-Python-Projects/c488f21f8224c1c0e0fa4fdbe5bb07ce0ec6012b/Email-response-sender/email-response-sender/db.sqlite3 -------------------------------------------------------------------------------- /Email-response-sender/email-response-sender/emailsender/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aishanipach/Beginners-Python-Projects/c488f21f8224c1c0e0fa4fdbe5bb07ce0ec6012b/Email-response-sender/email-response-sender/emailsender/__init__.py -------------------------------------------------------------------------------- /Email-response-sender/email-response-sender/emailsender/__pycache__/__init__.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aishanipach/Beginners-Python-Projects/c488f21f8224c1c0e0fa4fdbe5bb07ce0ec6012b/Email-response-sender/email-response-sender/emailsender/__pycache__/__init__.cpython-310.pyc -------------------------------------------------------------------------------- /Email-response-sender/email-response-sender/emailsender/__pycache__/settings.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aishanipach/Beginners-Python-Projects/c488f21f8224c1c0e0fa4fdbe5bb07ce0ec6012b/Email-response-sender/email-response-sender/emailsender/__pycache__/settings.cpython-310.pyc -------------------------------------------------------------------------------- /Email-response-sender/email-response-sender/emailsender/__pycache__/urls.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aishanipach/Beginners-Python-Projects/c488f21f8224c1c0e0fa4fdbe5bb07ce0ec6012b/Email-response-sender/email-response-sender/emailsender/__pycache__/urls.cpython-310.pyc -------------------------------------------------------------------------------- /Email-response-sender/email-response-sender/emailsender/__pycache__/wsgi.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aishanipach/Beginners-Python-Projects/c488f21f8224c1c0e0fa4fdbe5bb07ce0ec6012b/Email-response-sender/email-response-sender/emailsender/__pycache__/wsgi.cpython-310.pyc -------------------------------------------------------------------------------- /Email-response-sender/email-response-sender/emailsender/asgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | ASGI config for emailsender project. 3 | 4 | It exposes the ASGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/4.1/howto/deployment/asgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.asgi import get_asgi_application 13 | 14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'emailsender.settings') 15 | 16 | application = get_asgi_application() 17 | -------------------------------------------------------------------------------- /Email-response-sender/email-response-sender/emailsender/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for hi project. 3 | 4 | Generated by 'django-admin startproject' using Django 4.1. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/4.1/topics/settings/ 8 | 9 | For the full list of settings and their values, see 10 | https://docs.djangoproject.com/en/4.1/ref/settings/ 11 | """ 12 | 13 | import os 14 | from pathlib import Path 15 | from django.contrib.messages import constants as messages 16 | 17 | # Build paths inside the project like this: BASE_DIR / 'subdir'. 18 | BASE_DIR = Path(__file__).resolve().parent.parent 19 | 20 | 21 | # Quick-start development settings - unsuitable for production 22 | # See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/ 23 | 24 | # SECURITY WARNING: keep the secret key used in production secret! 25 | SECRET_KEY = 'django-insecure-it*pnx29=&no8@n=0q52w98m10vsv32ss#sf66vhzfeda7q8$)' 26 | 27 | # SECURITY WARNING: don't run with debug turned on in production! 28 | DEBUG = True 29 | 30 | ALLOWED_HOSTS = [] 31 | 32 | 33 | # Application definition 34 | 35 | INSTALLED_APPS = [ 36 | 'emailsenderapp.apps.EmailsenderappConfig', 37 | 'django.contrib.admin', 38 | 'django.contrib.auth', 39 | 'django.contrib.contenttypes', 40 | 'django.contrib.sessions', 41 | 'django.contrib.messages', 42 | 'django.contrib.staticfiles', 43 | ] 44 | 45 | MIDDLEWARE = [ 46 | 'django.middleware.security.SecurityMiddleware', 47 | 'django.contrib.sessions.middleware.SessionMiddleware', 48 | 'django.middleware.common.CommonMiddleware', 49 | 'django.middleware.csrf.CsrfViewMiddleware', 50 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 51 | 'django.contrib.messages.middleware.MessageMiddleware', 52 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 53 | ] 54 | 55 | ROOT_URLCONF = 'emailsender.urls' 56 | 57 | TEMPLATES = [ 58 | { 59 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 60 | 'DIRS': [ os.path.join(BASE_DIR,"templates")], 61 | 'APP_DIRS': True, 62 | 'OPTIONS': { 63 | 'context_processors': [ 64 | 'django.template.context_processors.debug', 65 | 'django.template.context_processors.request', 66 | 'django.contrib.auth.context_processors.auth', 67 | 'django.contrib.messages.context_processors.messages', 68 | ], 69 | }, 70 | }, 71 | ] 72 | 73 | WSGI_APPLICATION = 'emailsender.wsgi.application' 74 | 75 | 76 | # Database 77 | # https://docs.djangoproject.com/en/4.1/ref/settings/#databases 78 | 79 | DATABASES = { 80 | 'default': { 81 | 'ENGINE': 'django.db.backends.sqlite3', 82 | 'NAME': BASE_DIR / 'db.sqlite3', 83 | } 84 | } 85 | 86 | 87 | # Password validation 88 | # https://docs.djangoproject.com/en/4.1/ref/settings/#auth-password-validators 89 | 90 | AUTH_PASSWORD_VALIDATORS = [ 91 | { 92 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 93 | }, 94 | { 95 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 96 | }, 97 | { 98 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 99 | }, 100 | { 101 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 102 | }, 103 | ] 104 | 105 | 106 | # Internationalization 107 | # https://docs.djangoproject.com/en/4.1/topics/i18n/ 108 | 109 | LANGUAGE_CODE = 'en-us' 110 | 111 | TIME_ZONE = 'UTC' 112 | 113 | USE_I18N = True 114 | 115 | USE_TZ = True 116 | 117 | 118 | # Static files (CSS, JavaScript, Images) 119 | # https://docs.djangoproject.com/en/4.1/howto/static-files/ 120 | 121 | STATIC_URL = 'static/' 122 | 123 | # Default primary key field type 124 | # https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field 125 | 126 | DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' 127 | 128 | STATICFILES_DIRS = [ 129 | os.path.join(BASE_DIR,"static"), 130 | "/home/special.polls.com/polls/static", 131 | "/home/polls.com/polls/static", 132 | "/opt/webfiles/common", 133 | ] 134 | 135 | EMAIL_HOST='smtp.gmail.com' 136 | EMAIL_PORT=587 137 | EMAIL_HOST_USER='your email here' 138 | EMAIL_HOST_PASSWORD= 'password' 139 | EMAIL_USE_TLS = True 140 | -------------------------------------------------------------------------------- /Email-response-sender/email-response-sender/emailsender/urls.py: -------------------------------------------------------------------------------- 1 | """emailsender URL Configuration 2 | 3 | The `urlpatterns` list routes URLs to views. For more information please see: 4 | https://docs.djangoproject.com/en/4.1/topics/http/urls/ 5 | Examples: 6 | Function views 7 | 1. Add an import: from my_app import views 8 | 2. Add a URL to urlpatterns: path('', views.home, name='home') 9 | Class-based views 10 | 1. Add an import: from other_app.views import Home 11 | 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') 12 | Including another URLconf 13 | 1. Import the include() function: from django.urls import include, path 14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 15 | """ 16 | from django.contrib import admin 17 | from django.urls import path,include 18 | 19 | urlpatterns = [ 20 | path('admin/', admin.site.urls), 21 | path('',include('emailsenderapp.urls')) 22 | ] 23 | -------------------------------------------------------------------------------- /Email-response-sender/email-response-sender/emailsender/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for emailsender project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/4.1/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.wsgi import get_wsgi_application 13 | 14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'emailsender.settings') 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /Email-response-sender/email-response-sender/emailsenderapp/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aishanipach/Beginners-Python-Projects/c488f21f8224c1c0e0fa4fdbe5bb07ce0ec6012b/Email-response-sender/email-response-sender/emailsenderapp/__init__.py -------------------------------------------------------------------------------- /Email-response-sender/email-response-sender/emailsenderapp/__pycache__/__init__.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aishanipach/Beginners-Python-Projects/c488f21f8224c1c0e0fa4fdbe5bb07ce0ec6012b/Email-response-sender/email-response-sender/emailsenderapp/__pycache__/__init__.cpython-310.pyc -------------------------------------------------------------------------------- /Email-response-sender/email-response-sender/emailsenderapp/__pycache__/admin.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aishanipach/Beginners-Python-Projects/c488f21f8224c1c0e0fa4fdbe5bb07ce0ec6012b/Email-response-sender/email-response-sender/emailsenderapp/__pycache__/admin.cpython-310.pyc -------------------------------------------------------------------------------- /Email-response-sender/email-response-sender/emailsenderapp/__pycache__/apps.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aishanipach/Beginners-Python-Projects/c488f21f8224c1c0e0fa4fdbe5bb07ce0ec6012b/Email-response-sender/email-response-sender/emailsenderapp/__pycache__/apps.cpython-310.pyc -------------------------------------------------------------------------------- /Email-response-sender/email-response-sender/emailsenderapp/__pycache__/models.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aishanipach/Beginners-Python-Projects/c488f21f8224c1c0e0fa4fdbe5bb07ce0ec6012b/Email-response-sender/email-response-sender/emailsenderapp/__pycache__/models.cpython-310.pyc -------------------------------------------------------------------------------- /Email-response-sender/email-response-sender/emailsenderapp/__pycache__/urls.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aishanipach/Beginners-Python-Projects/c488f21f8224c1c0e0fa4fdbe5bb07ce0ec6012b/Email-response-sender/email-response-sender/emailsenderapp/__pycache__/urls.cpython-310.pyc -------------------------------------------------------------------------------- /Email-response-sender/email-response-sender/emailsenderapp/__pycache__/views.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aishanipach/Beginners-Python-Projects/c488f21f8224c1c0e0fa4fdbe5bb07ce0ec6012b/Email-response-sender/email-response-sender/emailsenderapp/__pycache__/views.cpython-310.pyc -------------------------------------------------------------------------------- /Email-response-sender/email-response-sender/emailsenderapp/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /Email-response-sender/email-response-sender/emailsenderapp/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class EmailsenderappConfig(AppConfig): 5 | default_auto_field = 'django.db.models.BigAutoField' 6 | name = 'emailsenderapp' 7 | -------------------------------------------------------------------------------- /Email-response-sender/email-response-sender/emailsenderapp/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aishanipach/Beginners-Python-Projects/c488f21f8224c1c0e0fa4fdbe5bb07ce0ec6012b/Email-response-sender/email-response-sender/emailsenderapp/migrations/__init__.py -------------------------------------------------------------------------------- /Email-response-sender/email-response-sender/emailsenderapp/migrations/__pycache__/__init__.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aishanipach/Beginners-Python-Projects/c488f21f8224c1c0e0fa4fdbe5bb07ce0ec6012b/Email-response-sender/email-response-sender/emailsenderapp/migrations/__pycache__/__init__.cpython-310.pyc -------------------------------------------------------------------------------- /Email-response-sender/email-response-sender/emailsenderapp/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | # Create your models here. 4 | -------------------------------------------------------------------------------- /Email-response-sender/email-response-sender/emailsenderapp/templates/query.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Queryform 12 | 13 | 14 |
15 |

Write Your Query Here

16 |
17 | {% csrf_token %} 18 |
19 |
20 | 21 | 22 |
23 | 24 |
25 |
26 |
27 | 28 | 29 |
30 |
31 | 32 | 36 |
37 |
38 | 39 | 40 |
41 |
42 |
43 | 44 | 45 |
46 |
47 |
48 | 49 | 52 |
53 |
54 | 55 |
56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /Email-response-sender/email-response-sender/emailsenderapp/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /Email-response-sender/email-response-sender/emailsenderapp/urls.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | from django.urls import path 3 | from emailsenderapp import views 4 | 5 | urlpatterns = [ 6 | path('admin/', admin.site.urls), 7 | path('query',views.query,name='query') 8 | ] -------------------------------------------------------------------------------- /Email-response-sender/email-response-sender/emailsenderapp/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render 2 | from django.core.mail import send_mail 3 | from emailsender.settings import EMAIL_HOST_USER 4 | 5 | # Create your views here. 6 | def query(request): 7 | if(request.method=="POST"): 8 | data=request.POST 9 | email=data.get("email") 10 | city=data.get("city") 11 | state=data.get("state") 12 | zip=data.get("zip") 13 | query=data.get("query") 14 | es=data.get("es") 15 | l=['email'] 16 | send_mail( 17 | 'query', 18 | f" email:{email}\n city:{city} \n state:{state} \n zip:{zip} \n query:{query} \n es:{es}", 19 | EMAIL_HOST_USER, 20 | l, 21 | fail_silently=False 22 | ) 23 | 24 | if(es=="on"): 25 | send_mail( 26 | 'query', 27 | f"this is your response \n email:{email}\n city:{city} \n state:{state} \n zip:{zip} \n query:{query}", 28 | EMAIL_HOST_USER, 29 | [email], 30 | fail_silently=False 31 | ) 32 | #print(es) 33 | return render(request,"query.html") 34 | 35 | -------------------------------------------------------------------------------- /Email-response-sender/email-response-sender/manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Django's command-line utility for administrative tasks.""" 3 | import os 4 | import sys 5 | 6 | 7 | def main(): 8 | """Run administrative tasks.""" 9 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'emailsender.settings') 10 | try: 11 | from django.core.management import execute_from_command_line 12 | except ImportError as exc: 13 | raise ImportError( 14 | "Couldn't import Django. Are you sure it's installed and " 15 | "available on your PYTHONPATH environment variable? Did you " 16 | "forget to activate a virtual environment?" 17 | ) from exc 18 | execute_from_command_line(sys.argv) 19 | 20 | 21 | if __name__ == '__main__': 22 | main() 23 | -------------------------------------------------------------------------------- /Gmail automation/Creating App Password: -------------------------------------------------------------------------------- 1 | Go to your ACCOUNT SETTINGS 2 | Search 'APP PASSWORD' 3 | Select App GMAIL 4 | Select Device OTHERS 5 | 6 | [It generates a password, copy that to use it as a password in the code] 7 | -------------------------------------------------------------------------------- /Gmail automation/Searchfilter_commands.txt: -------------------------------------------------------------------------------- 1 | 'ALL' 2 | 'BEFORE date' {Date format= 01-Nov-2020} 3 | 'ON date' 4 | 'SINCE date' 5 | 'FROM some_string' {FROM user@exam.com} 6 | 'TO some_string' 7 | 'CC/BCC some_string' {Can put size limit in imaplib. to change it use imaplib._MAXLINE='the limit in digits'} 8 | 'SUBJECT some_string' 9 | 'BODY some_string' 10 | 'TEXT "some_string_with_spaces"' {wrap the sting with spaces with double quotes} 11 | 'SEEN/UNSEEN' 12 | 'ANSWERED/UNANSWERED' 13 | 'DELETED/UNDELETED' 14 | -------------------------------------------------------------------------------- /Gmail automation/input_mail.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aishanipach/Beginners-Python-Projects/c488f21f8224c1c0e0fa4fdbe5bb07ce0ec6012b/Gmail automation/input_mail.PNG -------------------------------------------------------------------------------- /Gmail automation/my_first_mail.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aishanipach/Beginners-Python-Projects/c488f21f8224c1c0e0fa4fdbe5bb07ce0ec6012b/Gmail automation/my_first_mail.PNG -------------------------------------------------------------------------------- /Gmail automation/readme.md: -------------------------------------------------------------------------------- 1 | # Gmail Automation 2 | ## [1. Sending mail](https://github.com/Aishanipach/Beginners-Python-Programs/blob/main/Gmail%20automation/mailswithpy.py) 3 |

4 | 5 | 6 | ## [2. Receiving mail](https://github.com/Aishanipach/Beginners-Python-Programs/tree/main/Gmail%20automation) 7 |

8 | 9 | --- 10 | ### `smtplib` `getpass` 11 | -------------------------------------------------------------------------------- /Gmail automation/received_mail.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aishanipach/Beginners-Python-Projects/c488f21f8224c1c0e0fa4fdbe5bb07ce0ec6012b/Gmail automation/received_mail.PNG -------------------------------------------------------------------------------- /Gmail automation/receivefileswithpy.py: -------------------------------------------------------------------------------- 1 | import imaplib 2 | import getpass 3 | mail= imaplib.IMAP4_SSL("imap.gmail.com") 4 | 5 | em=getpass.getpass(prompt="Email: ") 6 | password =getpass.getpass(prompt="Enter password: ") 7 | mail.login(em,password) 8 | mail.select('inbox') 9 | typ, data= mail.search(None, 'FROM aishani.pachauri@gmail.com' ) 10 | print("\n{}".format(typ)) 11 | 12 | find_first_of_that_type= data[0][1] 13 | print(find_first_of_that_type) 14 | res, first_data= mail.uid('fetch',str(data[0][1]),"(RFC822)") #Second argument is protocol to call string 15 | raw=first_data[0][1] 16 | raw_email_string = raw.decode('utf-8') 17 | import email 18 | email_message = email.message_from_string(raw_email_string) 19 | for part in email_message.walk(): 20 | if part.get_content_type() == "text/plain": 21 | body = part.get_payload(decode=True) 22 | print(body) 23 | -------------------------------------------------------------------------------- /Gmail automation/sendmailswithpy.py: -------------------------------------------------------------------------------- 1 | #smtp server (simple mail transfer protocol) 2 | import smtplib 3 | import stdiomask #stdiomask is use for displaying a character instead of echoing the entered character. 4 | 5 | smtp_obj= smtplib.SMTP('smtp.gmail.com',587) #You can use 465 (ssl call) and skip starttls() call in that case 6 | smtp_obj.ehlo() 7 | smtp_obj.starttls() 8 | 9 | email= input("Email: ") 10 | password = stdiomask.getpass(prompt="Enter password: ", mask="*") # using stdiomask to display "*" instead of the entered password 11 | print(smtp_obj.login(email,password)) 12 | from_address= email 13 | to_address= email 14 | subject=input("Enter sub ") 15 | message=input("Enter body ") 16 | msg= "Subject: "+subject +'\n' +message 17 | 18 | smtp_obj.sendmail(from_address, to_address, msg) 19 | -------------------------------------------------------------------------------- /Heap_Sort.py: -------------------------------------------------------------------------------- 1 | 2 | def heapify(arr, n, i): 3 | largest = i 4 | l = 2 * i + 1 5 | r = 2 * i + 2 6 | 7 | if l < n and arr[i] < arr[l]: 8 | largest = l 9 | 10 | if r < n and arr[largest] < arr[r]: 11 | largest = r 12 | 13 | 14 | if largest != i: 15 | (arr[i], arr[largest]) = (arr[largest], arr[i]) # swap 16 | 17 | 18 | heapify(arr, n, largest) 19 | 20 | def heapSort(arr): 21 | n = len(arr) 22 | 23 | for i in range(n // 2 - 1, -1, -1): 24 | heapify(arr, n, i) 25 | 26 | for i in range(n - 1, 0, -1): 27 | (arr[i], arr[0]) = (arr[0], arr[i]) # swap 28 | heapify(arr, i, 0) 29 | 30 | arr = [12, 11, 13, 5, 6, 7, ] 31 | heapSort(arr) 32 | n = len(arr) 33 | print('Sorted array is') 34 | for i in range(n): 35 | print(arr[i]) 36 | 37 | -------------------------------------------------------------------------------- /Insertion_Sort.py: -------------------------------------------------------------------------------- 1 | 2 | def insertionSort(arr): 3 | 4 | for i in range(1, len(arr)): 5 | 6 | key = arr[i] 7 | j = i-1 8 | while j >=0 and key < arr[j] : 9 | arr[j+1] = arr[j] 10 | j -= 1 11 | arr[j+1] = key 12 | 13 | 14 | arr = [12, 11, 13, 5, 6] 15 | insertionSort(arr) 16 | lst = [] 17 | print("Sorted array is : ") 18 | for i in range(len(arr)): 19 | lst.append(arr[i]) 20 | print(lst) 21 | 22 | 23 | -------------------------------------------------------------------------------- /MatrixMultiplier.py: -------------------------------------------------------------------------------- 1 | # Define the matrices A and B 2 | A = [ 3 | [12, 7, 3], 4 | [4, 5, 6], 5 | [7, 8, 9] 6 | ] 7 | 8 | B = [ 9 | [5, 8, 1, 2], 10 | [6, 7, 3, 0], 11 | [4, 5, 9, 1] 12 | ] 13 | 14 | # Initialize the result matrix with zeros 15 | result = [[0 for _ in range(len(B[0]))] for _ in range(len(A))] 16 | 17 | # Perform matrix multiplication 18 | for i in range(len(A)): 19 | for j in range(len(B[0])): 20 | for k in range(len(B)): 21 | result[i][j] += A[i][k] * B[k][j] 22 | 23 | # Display the result 24 | for r in result: 25 | print(r) 26 | -------------------------------------------------------------------------------- /MergeSort.py: -------------------------------------------------------------------------------- 1 | def merge_sort(arr): 2 | if len(arr)>1: 3 | left_arr=arr[:(len(arr)//2)] 4 | right_arr=arr[len(arr)//2:] 5 | 6 | merge_sort(left_arr) 7 | merge_sort(right_arr) 8 | 9 | i=0 10 | j=0 11 | k=0 12 | while(i300 or head.xcor()<-300 or head.ycor()>260 or head.ycor()<-260: 108 | screen.bgcolor("red") 109 | time.sleep(1) 110 | head.goto(0,0) 111 | head.direction = "Stop" 112 | scores.append(score) 113 | Flag = False 114 | 115 | 116 | 117 | #Code for food and Head Collision. 118 | 119 | if head.distance(Food) < 20: 120 | Food.goto(random.randint(-270,270) , random.randint(-240,240)) 121 | score+=5 122 | pens.clear() 123 | pens.write("Score {0} \t Player {1}".format(score , name) , align="center" , font = ("Candara" , 24 , "bold")) 124 | #To increase the speed after every food eaten 125 | i+=0.02 126 | 127 | 128 | #Adding body 129 | new_body = turtle.Turtle() 130 | new_body.speed(0) 131 | new_body.shape("square") 132 | new_body.color("orange") 133 | new_body.penup() 134 | bodies.append(new_body) 135 | 136 | #increasing size 137 | if len(bodies)>0: 138 | x = head.xcor() 139 | y = head.ycor() 140 | bodies[0].goto(x, y) 141 | move() 142 | 143 | 144 | 145 | GameLoop() 146 | 147 | high_score = max(scores) 148 | for i in range(len(scores)): 149 | if scores[i]==high_score: 150 | winner = names[i] 151 | 152 | screen.clear() 153 | -------------------------------------------------------------------------------- /Snake Game using python/snake.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aishanipach/Beginners-Python-Projects/c488f21f8224c1c0e0fa4fdbe5bb07ce0ec6012b/Snake Game using python/snake.jpeg -------------------------------------------------------------------------------- /Strassen_Multiplication.py: -------------------------------------------------------------------------------- 1 | def multiply(A, B, C): 2 | for i in range(N): 3 | 4 | for j in range(N): 5 | 6 | C[i][j] = 0 7 | for k in range(N): 8 | C[i][j] += A[i][k] * B[k][j] 9 | 10 | print(i+j+k) 11 | -------------------------------------------------------------------------------- /Summerof'69.py: -------------------------------------------------------------------------------- 1 | """SUMMER OF '69: 2 | Return the sum of the numbers in the array, except ignore sections of numbers starting with a 6 and extending to the next 9 (every 6 will be followed by at least one 9). Return 0 for no numbers. 3 | (Also one of my fav songs from Bryan Adams!) 4 | 5 | summer_69([1, 3, 5]) --> 9 6 | summer_69([4, 5, 6, 7, 8, 9]) --> 9 7 | summer_69([2, 1, 6, 9, 11]) --> 14 8 | """ 9 | 10 | def summer_69(arr): 11 | total = 0 12 | add = True 13 | for num in arr: 14 | while add: 15 | if num != 6: 16 | total += num 17 | break 18 | else: 19 | add = False 20 | while not add: 21 | if num != 9: 22 | break 23 | else: 24 | add = True 25 | break 26 | return total 27 | 28 | a=list(input("Enter list: ")) 29 | summer_69(a) 30 | -------------------------------------------------------------------------------- /Threecupsmonty/Readme.md: -------------------------------------------------------------------------------- 1 | # Three Cups Monty 2 | So, I made this a two step game.

3 | Now, 4 | 5 | 1. If you guess the right answer out of three, you move on to the next round with five cups.
6 | 2. If not, you exit() 7 | 3. If you guess the right answer out of five too, you win! 8 | 9 |
10 | 11 | ## Understanding the algorithm: 12 | 13 | ![Image of the game flow](https://github.com/Aishanipach/Beginners-Python-Programs/blob/main/Threecupsmonty/three_cups_monty.PNG) 14 | 15 | -------------------------------------------------------------------------------- /Threecupsmonty/three_cups_monty.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aishanipach/Beginners-Python-Projects/c488f21f8224c1c0e0fa4fdbe5bb07ce0ec6012b/Threecupsmonty/three_cups_monty.PNG -------------------------------------------------------------------------------- /Threecupsmonty/three_cups_monty.py: -------------------------------------------------------------------------------- 1 | """THREE CUP MONTY""" 2 | import random 3 | 4 | def shuffle_list(my_list): 5 | random.shuffle(my_list) 6 | return(my_list) 7 | 8 | def checkguess(cup_list, guess): 9 | if(cup_list[guess]=='0'): 10 | print("You won!") 11 | return 1 12 | else: 13 | print("You lost :(") 14 | return -1 15 | 16 | def game_play1(): 17 | list1=[' ', '0',' '] 18 | cup_list1=shuffle_list(list1) 19 | choice='' 20 | while choice not in [0, 1, 2] : 21 | 22 | choice=int(input("Enter your guess(0,1 or 2): ")) 23 | 24 | result=checkguess(cup_list1,choice) 25 | return result 26 | 27 | 28 | def game_play2(): 29 | list2=[' ',' ','0',' ',' '] 30 | cup_list2=shuffle_list(list2) 31 | choice='' 32 | while choice not in [0, 1, 2, 3, 4] : 33 | 34 | choice=int(input("Enter your guess(0,1, 2,3 or 4): ")) 35 | 36 | checkguess(cup_list2,choice) 37 | 38 | 39 | res=game_play1() 40 | if res==1: 41 | game_play2() 42 | else: 43 | print("You should try again") -------------------------------------------------------------------------------- /TicTacToe/Finalprogram.py: -------------------------------------------------------------------------------- 1 | #from IPython.display import clear_output 2 | 3 | def display_board(board): 4 | # clear_output() (This only works in jupyter!) 5 | print("\n"*100) 6 | 7 | print(' | |') 8 | print(' ' + board[7] + ' | ' + board[8] + ' | ' + board[9]) 9 | print(' | |') 10 | print('-----------') 11 | print(' | |') 12 | print(' ' + board[4] + ' | ' + board[5] + ' | ' + board[6]) 13 | print(' | |') 14 | print('-----------') 15 | print(' | |') 16 | print(' ' + board[1] + ' | ' + board[2] + ' | ' + board[3]) 17 | print(' | |') 18 | 19 | test_board = ['#','X','O','X','O','X','O','X','O','X'] 20 | display_board(test_board) 21 | 22 | #------------------------------------------------------------------------------------------ 23 | 24 | def player_input(): 25 | marker = '' 26 | 27 | while not (marker == 'X' or marker == 'O'): 28 | marker = input('Player 1: Do you want to be X or O? ').upper() 29 | 30 | if marker == 'X': 31 | return ('X', 'O') 32 | else: 33 | return ('O', 'X') 34 | 35 | player_input() 36 | 37 | #--------------------------------------------------------------------------------------------- 38 | 39 | def place_marker(board, marker, position): 40 | board[position] = marker 41 | 42 | place_marker(test_board,'$',8) 43 | display_board(test_board) 44 | 45 | #--------------------------------------------------------------------------------------------- 46 | 47 | def win_check(board,mark): 48 | 49 | return ((board[7] == mark and board[8] == mark and board[9] == mark) or # across the top 50 | (board[4] == mark and board[5] == mark and board[6] == mark) or # across the middle 51 | (board[1] == mark and board[2] == mark and board[3] == mark) or # across the bottom 52 | (board[7] == mark and board[4] == mark and board[1] == mark) or # down the middle 53 | (board[8] == mark and board[5] == mark and board[2] == mark) or # down the middle 54 | (board[9] == mark and board[6] == mark and board[3] == mark) or # down the right side 55 | (board[7] == mark and board[5] == mark and board[3] == mark) or # diagonal 56 | (board[9] == mark and board[5] == mark and board[1] == mark)) # diagonal 57 | 58 | win_check(test_board,'X') 59 | 60 | #--------------------------------------------------------------------------------------------- 61 | 62 | import random 63 | 64 | def choose_first(): 65 | if random.randint(0, 1) == 0: 66 | return 'Player 2' 67 | else: 68 | return 'Player 1' 69 | 70 | #--------------------------------------------------------------------------------------------- 71 | 72 | def space_check(board, position): 73 | 74 | return board[position] == ' ' 75 | 76 | #--------------------------------------------------------------------------------------------- 77 | 78 | def full_board_check(board): 79 | for i in range(1,10): 80 | if space_check(board, i): 81 | return False 82 | return True 83 | 84 | #--------------------------------------------------------------------------------------------- 85 | 86 | def player_choice(board): 87 | position = 0 88 | 89 | while position not in [1,2,3,4,5,6,7,8,9] or not space_check(board, position): 90 | position = int(input('Choose your next position: (1-9) ')) 91 | 92 | return position 93 | 94 | #--------------------------------------------------------------------------------------------- 95 | 96 | def replay(): 97 | 98 | return input('Do you want to play again? Enter Yes or No: ').lower().startswith('y') 99 | 100 | print('Welcome to Tic Tac Toe!') 101 | 102 | while True: 103 | # Reset the board 104 | theBoard = [' '] * 10 105 | player1_marker, player2_marker = player_input() 106 | turn = choose_first() 107 | print(turn + ' will go first.') 108 | 109 | play_game = input('Are you ready to play? Enter Yes or No.') 110 | 111 | if play_game.lower()[0] == 'y': 112 | game_on = True 113 | else: 114 | game_on = False 115 | 116 | while game_on: 117 | if turn == 'Player 1': 118 | # Player1's turn. 119 | 120 | display_board(theBoard) 121 | position = player_choice(theBoard) 122 | place_marker(theBoard, player1_marker, position) 123 | 124 | if win_check(theBoard, player1_marker): 125 | display_board(theBoard) 126 | print('Congratulations! You have won the game!') 127 | game_on = False 128 | else: 129 | if full_board_check(theBoard): 130 | display_board(theBoard) 131 | print('The game is a draw!') 132 | break 133 | else: 134 | turn = 'Player 2' 135 | 136 | else: 137 | # Player2's turn. 138 | 139 | display_board(theBoard) 140 | position = player_choice(theBoard) 141 | place_marker(theBoard, player2_marker, position) 142 | 143 | if win_check(theBoard, player2_marker): 144 | display_board(theBoard) 145 | print('Player 2 has won!') 146 | game_on = False 147 | else: 148 | if full_board_check(theBoard): 149 | display_board(theBoard) 150 | print('The game is a draw!') 151 | break 152 | else: 153 | turn = 'Player 1' 154 | 155 | if not replay(): 156 | break 157 | 158 | -------------------------------------------------------------------------------- /TicTacToe/MyfirstTry.py: -------------------------------------------------------------------------------- 1 | def checkwin(recordboard,player): 2 | ans_set=[[0,1,2],[3,4,5],[6,7,8],[2,5,8],[1,4,7],[0,3,6],[0,4,8],[2,4,6]] 3 | checkindex1=[] 4 | 5 | 6 | for i in range(0,len(recordboard)-1): 7 | if(recordboard[i]==player): 8 | checkindex1.append(i) 9 | 10 | 11 | for l in ans_set: 12 | ctr=0 13 | for z in checkindex1: 14 | if(z in l): 15 | ctr+=1 16 | if(ctr==3): 17 | return("win") 18 | return(-1) 19 | 20 | 21 | 22 | 23 | #-------------------------------------------------------------- 24 | 25 | def tttboard(run,player, index ): 26 | recordboard=[0,1,2,3,4,5,6,7,8] 27 | #for first run 28 | 29 | if(run==0): 30 | k=0 31 | for j in range(0,3): 32 | if(j>0): 33 | print(" -----------------------------------------") 34 | for i in range(0,3): 35 | print("\t", end="") 36 | print("{}\t".format(k), end="") 37 | if(k not in [2,5,8]): 38 | print("|", end="") 39 | k+=1 40 | print() 41 | print("\n \n") 42 | return 0 43 | 44 | #Changing recordboard with X or O 45 | for l in range(0,(len(recordboard)-1)): 46 | if(index == recordboard[l]): 47 | recordboard[l]=player 48 | #checkwin 49 | ans=checkwin(recordboard,player) 50 | #Display board and continue 51 | if(ans==-1): 52 | print("ehh") 53 | return 0 54 | else: 55 | print("It's a win!!!") 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | #-------------------------------------------------------------- 69 | 70 | def Welcome(): 71 | ctr=-1 72 | print("Hello player! Welcome to TicTacToe game") 73 | tttboard(0,"a",0) 74 | 75 | while(ctr==-1): 76 | P1=str(input("\nWhat do you want (X or O)? ")) 77 | if(P1=="X"): 78 | P2="O" 79 | ctr=1 80 | elif(P1=="O"): 81 | P2="X" 82 | ctr=1 83 | else: 84 | print("Wrong input, choose again(X or O)") 85 | return(P1,P2) 86 | 87 | #-------------------------------------------------------------- 88 | def Gameplay(p1, p2): 89 | ctr=1 90 | index=-1 91 | while(ctr<10): 92 | while(index not in [0,1,2,3,4,5,6,7,8]): 93 | index=int(input("Choose a valid index ")) 94 | 95 | if(ctr%2==0): 96 | print(p2) 97 | tttboard(ctr,p2, index) 98 | index=-1 99 | ctr+=1 100 | else: 101 | print(p1) 102 | tttboard(ctr,p1,index) 103 | index=-1 104 | ctr+=1 105 | 106 | p1,p2=Welcome() 107 | Gameplay(p1,p2) 108 | -------------------------------------------------------------------------------- /TicTacToe/Readme.md: -------------------------------------------------------------------------------- 1 | # TICTACTOE GAME 2 | ### How does this work? 3 | -------------------------------------------------------------------------------- /Tkinter/Basic_gui.py: -------------------------------------------------------------------------------- 1 | #This is a reference code I used which covers most of the topics for basic GUI 2 | 3 | 4 | from tkinter import * 5 | 6 | root = Tk() #Makes the window 7 | root.wm_title("Window Title") #Makes the title that will appear in the top left 8 | root.config(bg = "#828481") 9 | 10 | #It displays color button, which once clicked show mentioned color on the screen 11 | def redCircle(): 12 | circleCanvas.create_oval(20, 20, 80, 80, width=0, fill='red') 13 | colorLog.insert(0.0, "Red\n") 14 | 15 | def yelCircle(): 16 | circleCanvas.create_oval(20, 20, 80, 80, width=0, fill='yellow') 17 | colorLog.insert(0.0, "Yellow\n") 18 | 19 | def grnCircle(): 20 | circleCanvas.create_oval(20, 20, 80, 80, width=0, fill='green') 21 | colorLog.insert(0.0, "Green\n") 22 | 23 | 24 | #Left Frame and its contents 25 | leftFrame = Frame(root, width=200, height = 600, bg="#C8F9C4", highlightthickness=2, highlightbackground="#111") 26 | leftFrame.grid(row=0, column=0, padx=10, pady=2, sticky=N+S) 27 | 28 | Inst = Label(leftFrame, text="Instructions:", anchor=W, bg="#C8F9C4") 29 | Inst.grid(row=0, column=0, padx=10, pady=2, sticky=W) 30 | 31 | instructions = "When one of the buttons on the is clicked, a circle\ 32 | of the selected color appears in the canvas above. Red will result in a red circle. The color that is\ 33 | selected will also appear in the output box below. This will track the various colors that\ 34 | have been chosen in the past." 35 | Instruct = Label(leftFrame, width=22, height=10, text=instructions, takefocus=0, wraplength=170, anchor=W, justify=LEFT, bg="#C8F9C4") 36 | Instruct.grid(row=1, column=0, padx=10, pady=2) 37 | 38 | imageEx = PhotoImage(file = 'image.png') 39 | Label(leftFrame, image=imageEx).grid(row=2, column=0, padx=10, pady=2) 40 | 41 | 42 | #Right Frame and its contents 43 | rightFrame = Frame(root, width=200, height = 600, bg="#C8F9C4", highlightthickness=2, highlightbackground="#111") 44 | rightFrame.grid(row=0, column=1, padx=10, pady=2, sticky=N+S) 45 | 46 | circleCanvas = Canvas(rightFrame, width=100, height=100, bg='white', highlightthickness=1, highlightbackground="#333") 47 | circleCanvas.grid(row=0, column=0, padx=10, pady=2) 48 | 49 | btnFrame = Frame(rightFrame, width=200, height = 200, bg="#C8F9C4") 50 | btnFrame.grid(row=1, column=0, padx=10, pady=2) 51 | 52 | colorLog = Text(rightFrame, width = 30, height = 10, takefocus=0, highlightthickness=1, highlightbackground="#333") 53 | colorLog.grid(row=2, column=0, padx=10, pady=2) 54 | 55 | redBtn = Button(btnFrame, text="Red", command=redCircle, bg="#EC6E6E") 56 | redBtn.grid(row=0, column=0, padx=10, pady=2) 57 | 58 | yellowBtn = Button(btnFrame, text="Yellow", command=yelCircle, bg="#ECE86E") 59 | yellowBtn.grid(row=0, column=1, padx=10, pady=2) 60 | 61 | greenBtn = Button(btnFrame, text="Green", command=grnCircle, bg="#6EEC77") 62 | greenBtn.grid(row=0, column=2, padx=10, pady=2) 63 | 64 | 65 | mainloop() 66 | -------------------------------------------------------------------------------- /Tkinter/Output.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aishanipach/Beginners-Python-Projects/c488f21f8224c1c0e0fa4fdbe5bb07ce0ec6012b/Tkinter/Output.PNG -------------------------------------------------------------------------------- /Tkinter/TV_Remote.py: -------------------------------------------------------------------------------- 1 | #A TV Remaote GUI ( turns TV on/off, sets Volume and change channels) 2 | from tkinter import * 3 | import tkinter.messagebox 4 | class TV: 5 | def __init__(self): 6 | self.channel=1 7 | self.vol=1 8 | self.on=False 9 | 10 | def turnON(self): 11 | if(self.on==False): 12 | self.on=True 13 | 14 | circleCanvas.create_oval(20, 20, 80, 80, width=0, fill='red') 15 | colorLog.insert(0.0, "TV is Turned ON\n") 16 | else: 17 | self.on=False 18 | circleCanvas.create_oval(20, 20, 80, 80, width=0, fill='grey') 19 | colorLog.insert(0.0, "TV is Turned OFF\n") 20 | 21 | 22 | 23 | 24 | def setChannel(self,c=-1): 25 | if(self.channel<10 and self.on==True): 26 | self.channel=c 27 | btnLog.insert(0.0, "Current Channel:{} \n" .format(self.channel)) 28 | elif(self.on==False): 29 | colorLog.insert(0.0, "Turn on the TV \n") 30 | else: 31 | colorLog.insert(0.0, "Wrong Input \n") 32 | 33 | def getVolume(self): 34 | return(self.vol) 35 | 36 | def setVolume(self,volume): 37 | if(self.on==True): 38 | rectangleCanvas.create_rectangle(20, 20,300,80, width=0, fill='white') 39 | self.vol=volume 40 | l=(30*volume) 41 | print(l) 42 | rectangleCanvas.create_rectangle(20, 20,l, l, width=0, fill='red') 43 | btnLog.insert(0.0, "volume set to {}\n".format(self.vol)) 44 | else: 45 | btnLog.insert(0.0, "Turn on the TV \n") 46 | 47 | def channelUp(self): 48 | if(self.channel<10 and self.on==True): 49 | self.channel+=1 50 | colorLog.insert(0.0, "Current Channel:{} \n" .format(self.channel)) 51 | elif(self.on==False): 52 | colorLog.insert(0.0, "Turn on the TV \n") 53 | else: 54 | colorLog.insert(0.0, "No further channels available \n") 55 | 56 | def channelDOWN(self): 57 | if(self.channel>0 and self.on==True): 58 | self.channel-=1 59 | colorLog.insert(0.0, "Current Channel:{} \n" .format(self.channel)) 60 | elif(self.on==False): 61 | colorLog.insert(0.0, "Turn on the TV \n") 62 | else: 63 | colorLog.insert(0.0, "No negative Channels \n") 64 | 65 | 66 | def VolumeUp(self): 67 | if(self.vol<5 and self.on==True): 68 | self.vol+=1 69 | colorLog.insert(0.0, "Current Volume:{} \n" .format(self.vol)) 70 | elif(self.on==False): 71 | colorLog.insert(0.0, "Turn on the TV \n") 72 | else: 73 | colorLog.insert(0.0, "Max Volume \n") 74 | 75 | def VolumeDown(self): 76 | if(self.vol>0 and self.on==True): 77 | self.vol-=1 78 | colorLog.insert(0.0, "Current Volume:{} \n" .format(self.vol)) 79 | elif(self.on==False): 80 | colorLog.insert(0.0, "Turn on the TV \n") 81 | else: 82 | colorLog.insert(0.0, "MUTE \n") 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | t1= TV() 91 | 92 | root = Tk() 93 | w = Label(root, text=" TV Remote!") 94 | k = Button(root,activebackground="black", text= "Hi") 95 | 96 | #Turn ON & Turn OFF, Volume, Channel UP &DOWN 97 | rightFrame = Frame(root, width=200, height = 600) 98 | rightFrame.grid(row=0, column=1, padx=10, pady=2) 99 | 100 | circleCanvas = Canvas(rightFrame, width=100, height=100, bg='white') 101 | circleCanvas.grid(row=0, column=0, padx=10, pady=2) 102 | 103 | btnFrame = Frame(rightFrame, width=200, height = 400) 104 | btnFrame.grid(row=1, column=0, padx=10, pady=2) 105 | colorLog = Text(rightFrame, width = 30, height = 20, takefocus=0) 106 | colorLog.grid(row=2, column=0, padx=10, pady=2) 107 | 108 | 109 | if(t1.on==False): 110 | circleCanvas.create_oval(20, 20, 80, 80, width=0, fill='grey') 111 | colorLog.grid(row=2, column=0, padx=10, pady=2) 112 | 113 | 114 | redBtn = Button(btnFrame, text="Turn On", command=t1.turnON) 115 | redBtn.grid(row=0, column=0, padx=10, pady=2) 116 | 117 | 118 | yellowBtn = Button(btnFrame, text="Channel UP", command=t1.channelUp) 119 | yellowBtn.grid(row=1, column=1, padx=10, pady=2) 120 | 121 | greenBtn = Button(btnFrame, text="Channel DOWN", command=t1.channelDOWN) 122 | greenBtn.grid(row=1, column=2, padx=10, pady=2) 123 | 124 | purpleBtn = Button(btnFrame, text="Volume UP", command=t1.VolumeUp) 125 | purpleBtn.grid(row=2, column=1, padx=10, pady=2) 126 | 127 | purpleBtn = Button(btnFrame, text="Volume DOWN", command=t1.VolumeDown) 128 | purpleBtn.grid(row=2, column=2, padx=10, pady=2) 129 | 130 | #Left frame 131 | leftFrame = Frame(root, width=400, height = 600) 132 | leftFrame.grid(row=0, column=0, padx=10, pady=2) 133 | btnLog = Text(leftFrame, width =20, height = 20, takefocus=0) 134 | btnLog.grid(row=1, column=0, padx=10, pady=2) 135 | btnFrame = Frame(leftFrame, width=200, height = 100) 136 | btnFrame.grid(row=2, column=0, padx=10, pady=2) 137 | rectangleCanvas = Canvas(leftFrame, width=150, height=30, bg='white') 138 | rectangleCanvas.grid(row=3, column=0, padx=10, pady=2) 139 | #Channel Number 140 | one = Button(btnFrame, text="1", command=lambda:t1.setChannel(1)) 141 | one.grid(row=0, column=0, padx=10, pady=2) 142 | 143 | two = Button(btnFrame, text="2", command=lambda:t1.setChannel(2)) 144 | two.grid(row=0, column=1, padx=10, pady=2) 145 | 146 | three = Button(btnFrame, text="3", command=lambda:t1.setChannel(3)) 147 | three.grid(row=0, column=2, padx=10, pady=2) 148 | 149 | four = Button(btnFrame, text="4", command=lambda:t1.setChannel(4)) 150 | four.grid(row=1, column=0, padx=10, pady=2) 151 | 152 | five = Button(btnFrame, text="5", command=lambda:t1.setChannel(5)) 153 | five.grid(row=1, column=1, padx=10, pady=2) 154 | 155 | six = Button(btnFrame, text="6", command=lambda:t1.setChannel(6)) 156 | six.grid(row=1, column=2, padx=10, pady=2) 157 | 158 | seven = Button(btnFrame, text="7", command=lambda:t1.setChannel(7)) 159 | seven.grid(row=2, column=0, padx=10, pady=2) 160 | 161 | eight = Button(btnFrame, text="8", command=lambda:t1.setChannel(8)) 162 | eight.grid(row=2, column=1, padx=10, pady=2) 163 | 164 | nine = Button(btnFrame, text="9", command=lambda:t1.setChannel(9)) 165 | nine.grid(row=2, column=2, padx=10, pady=2) 166 | #Set Volume 167 | vone = Button(btnFrame, text="Vol1", command=lambda:t1.setVolume(1)) 168 | vone.grid(row=4, column=0, padx=10, pady=2) 169 | 170 | vtwo = Button(btnFrame, text="Vol2", command=lambda:t1.setVolume(2)) 171 | vtwo.grid(row=4, column=1, padx=10, pady=2) 172 | 173 | vthree = Button(btnFrame, text="Vol3", command=lambda:t1.setVolume(3)) 174 | vthree.grid(row=4, column=2, padx=10, pady=2) 175 | 176 | vfour = Button(btnFrame, text="Vol4", command=lambda:t1.setVolume(4)) 177 | vfour.grid(row=4, column=3, padx=10, pady=2) 178 | 179 | vfive = Button(btnFrame, text="Vol5", command=lambda:t1.setVolume(5)) 180 | vfive.grid(row=4, column=4, padx=10, pady=2) 181 | 182 | 183 | root.mainloop() 184 | w.pack() 185 | k.pack() 186 | 187 | 188 | -------------------------------------------------------------------------------- /Tkinter/image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aishanipach/Beginners-Python-Projects/c488f21f8224c1c0e0fa4fdbe5bb07ce0ec6012b/Tkinter/image.png -------------------------------------------------------------------------------- /Tkinter/rangoli.py: -------------------------------------------------------------------------------- 1 | import turtle as t 2 | t.bgcolor('black') #background color as black 3 | 4 | t.pensize(2) 5 | # screen setup 6 | screen = t.Screen() 7 | screen.setup(width = 1.0, height = 1.0) 8 | t.speed(0) 9 | col = ['red','cyan','magenta','blue','green','yellow','white'] 10 | for i in range(6): 11 | for colors in col: 12 | t.color(colors) 13 | t.circle(100) 14 | t.left(10) 15 | 16 | t.hideturtle() 17 | t.done() -------------------------------------------------------------------------------- /Tkinter/readme.md: -------------------------------------------------------------------------------- 1 | This program is for a working TV Remote using Tkinter built-in Python library 2 | (On VS Code) 3 | ### GUI: 4 | ![Image of output](https://github.com/Aishanipach/Beginners-Python-Programs/blob/main/Tkinter/Output.PNG) 5 | 6 | -------------------------------------------------------------------------------- /Tkinter_recommendation_system/code.py: -------------------------------------------------------------------------------- 1 | import tkinter as tk 2 | from tkinter import * 3 | from tkinter import messagebox 4 | from tkinter import ttk 5 | 6 | def main1(): 7 | global MAIN_WINDOW 8 | MAIN_WINDOW=Tk() #after successful this main ui should appear 9 | 10 | MAIN_WINDOW.geometry("600x1000+300+100") 11 | va = IntVar() 12 | va.set(1) 13 | w=Label(MAIN_WINDOW, text = "What do you wish to buy today?")#,justify=LEFT 14 | w.pack(anchor=W) 15 | r1=Radiobutton(MAIN_WINDOW, text='Cosmetics', variable=va, value=1,justify=LEFT, command = Cosmetics) 16 | r2=Radiobutton(MAIN_WINDOW, text='Clothing', variable=va, value=2,justify=LEFT, command = Clothing) 17 | r1.pack() 18 | r2.pack() 19 | 20 | 21 | MAIN_WINDOW.mainloop() 22 | 23 | a=0 24 | b=0 25 | c=0 26 | 27 | def c1(): 28 | global a 29 | a=a+1 30 | 31 | def c2(): 32 | global b 33 | b=b+1 34 | 35 | def c3(): 36 | global c 37 | c=c+1 38 | 39 | # Function for cosmetics 40 | def Cosmetics(): 41 | l1=Label(MAIN_WINDOW, text = "Select desired product",justify=LEFT) 42 | l1.pack(anchor=W) 43 | v1 = IntVar() 44 | Radiobutton(MAIN_WINDOW, text='Shampoo and Conditioner',variable=v1,value=1, command = Shampoo).pack(anchor=W) 45 | Radiobutton(MAIN_WINDOW, text='Face wash',variable=v1,value=2, command = Facewash).pack(anchor=W) 46 | Radiobutton(MAIN_WINDOW, text='Soap',variable=v1,value=3, command = Soap).pack(anchor=W) 47 | 48 | #Function for clothing 49 | def Clothing(): 50 | l2=Label(MAIN_WINDOW, text = "Select desired product",justify=LEFT) 51 | l2.pack(anchor=W) 52 | v2 = IntVar() 53 | Radiobutton(MAIN_WINDOW, text='Shirt for men',variable=v2,value=1,command = Shirt_men).pack(anchor=W) 54 | Radiobutton(MAIN_WINDOW, text='Shirt for women',variable=v2,value=2, command = Shirt_women).pack(anchor=W) 55 | Radiobutton(MAIN_WINDOW, text='Denim Jeans',variable=v2,value=3, command = Denims).pack(anchor=W) 56 | 57 | 58 | #Function for shampoo !!! 59 | def Shampoo(): 60 | #1st 61 | LA=Label(MAIN_WINDOW, text = "Select the most appropriate answer:",justify=LEFT) 62 | l3=Label(MAIN_WINDOW, text = "1. What type of hair do u have?",justify=LEFT) 63 | l3.pack(anchor=W) 64 | v3 = IntVar() 65 | Radiobutton(MAIN_WINDOW, text='Oily',variable=v3,value=1,command=c1).pack(anchor=W) 66 | Radiobutton(MAIN_WINDOW, text='Normal',variable=v3,value=2,command=c2).pack(anchor=W) 67 | Radiobutton(MAIN_WINDOW, text='Dry',variable=v3,value=3,command=c3).pack(anchor=W) 68 | 69 | #2nd 70 | l4=Label(MAIN_WINDOW, text = "2. What type of hair do u have?",justify=LEFT) 71 | l4.pack(anchor=W) 72 | v3 = IntVar() 73 | Radiobutton(MAIN_WINDOW, text='Thick',variable=v3,value=1,command=c1).pack(anchor=W) 74 | Radiobutton(MAIN_WINDOW, text='Normal',variable=v3,value=2,command=c2).pack(anchor=W) 75 | Radiobutton(MAIN_WINDOW, text='Fine',variable=v3,value=3,command=c3).pack(anchor=W) 76 | 77 | 78 | #3rd 79 | l5=Label(MAIN_WINDOW, text = "3. Presently your hair is",justify=LEFT) 80 | l5.pack(anchor=W) 81 | v5 = IntVar() 82 | Radiobutton(MAIN_WINDOW, text='Natural',variable=v5,value=1,command=c1).pack(anchor=W) 83 | Radiobutton(MAIN_WINDOW, text='Coloured or Highlighted',variable=v5,value=2,command=c2).pack(anchor=W) 84 | Radiobutton(MAIN_WINDOW, text='Permed',variable=v5,value=3,command=c3).pack(anchor=W) 85 | 86 | #4th 87 | l6=Label(MAIN_WINDOW, text = "4. How frequently do you wash your hair?",justify=LEFT) 88 | l6.pack(anchor=W) 89 | v6 = IntVar() 90 | Radiobutton(MAIN_WINDOW, text='Once a week',variable=v6,value=1,command=c1).pack(anchor=W) 91 | Radiobutton(MAIN_WINDOW, text='Twice a week',variable=v6,value=2,command=c2).pack(anchor=W) 92 | Radiobutton(MAIN_WINDOW, text='Everyday',variable=v6,value=3,command=c3).pack(anchor=W) 93 | 94 | #5th 95 | l7=Label(MAIN_WINDOW, text = "5. How often do you use a heat tool?",justify=LEFT) 96 | l7.pack(anchor=W) 97 | v7 = IntVar() 98 | Radiobutton(MAIN_WINDOW, text='Never',variable=v7,value=1,command=c1).pack(anchor=W) 99 | Radiobutton(MAIN_WINDOW, text='Sometimes',variable=v7,value=2,command=c2).pack(anchor=W) 100 | Radiobutton(MAIN_WINDOW, text='Everyday',variable=v7,value=3,command=c3).pack(anchor=W) 101 | 102 | #6th 103 | l8=Label(MAIN_WINDOW, text = "6. How often do you use a hair product?",justify=LEFT) 104 | l8.pack(anchor=W) 105 | v8 = IntVar() 106 | Radiobutton(MAIN_WINDOW, text='Never',variable=v8,value=1,command=c1).pack(anchor=W) 107 | Radiobutton(MAIN_WINDOW, text='Sometimes',variable=v8,value=2,command=c2).pack(anchor=W) 108 | Radiobutton(MAIN_WINDOW, text='Everyday',variable=v8,value=3,command=c3).pack(anchor=W) 109 | 110 | #7th 111 | l9=Label(MAIN_WINDOW, text = "7. Do you have splitends?",justify=LEFT) 112 | l9.pack(anchor=W) 113 | v9 = IntVar() 114 | Radiobutton(MAIN_WINDOW, text='None',variable=v9,value=1,command=c1).pack(anchor=W) 115 | Radiobutton(MAIN_WINDOW, text='Few',variable=v9,value=2,command=c2).pack(anchor=W) 116 | Radiobutton(MAIN_WINDOW, text='Plenty',variable=v9,value=3,command=c3).pack(anchor=W) 117 | 118 | 119 | Button(MAIN_WINDOW, text="Submit", width=10, height=1, bg="white",command=Shampoo_pro).place(x=300,y=700) 120 | Button(MAIN_WINDOW, text="Buy", width=10, height=1, bg="white",command=Buy).place(x=400,y=700) 121 | 122 | def Shampoo_pro(): 123 | if (a>b and a>c): 124 | messagebox.showinfo("Your ideal Shampoo:","L'Oreal 6 Oil Nourish Shampoo") 125 | elif (b>c and b>a): 126 | messagebox.showinfo("Your ideal shampoo " ,"L'Oreal Hair Spa Nourishing Shampoo") 127 | elif (c>a and c>b): 128 | messagebox.showinfo("Your ideal shampoo" ,"Dove Intense Repair Shampoo") 129 | elif (a==b): 130 | messagebox.showinfo("Your ideal shampoo" ,"L'Oreal Hair Spa Nourishing Shampoo") 131 | elif (b==c): 132 | messagebox.showinfo("Your ideal shampoo","Dove Intense Repair Shampoo") 133 | elif (a==c): 134 | messagebox.showinfo("Your ideal shampoo" ,"L'Oreal Hair Spa Nourishing Shampoo") 135 | elif (a==b and b==c): 136 | messagebox.showinfo("Your ideal shampoo" ,"L'Oreal Hair Spa Nourishing Shampoo") 137 | 138 | 139 | 140 | #Function for facewash !!! 141 | def Facewash(): 142 | #1st 143 | LA=Label(MAIN_WINDOW, text = "Select the most appropriate answer:",justify=LEFT) 144 | l3=Label(MAIN_WINDOW, text = "1. What type of skin do u have?",justify=LEFT) 145 | l3.pack(anchor=W) 146 | v3 = IntVar() 147 | Radiobutton(MAIN_WINDOW, text='Oily',variable=v3,value=1,command=c1).pack(anchor=W) 148 | Radiobutton(MAIN_WINDOW, text='Normal',variable=v3,value=2,command=c2).pack(anchor=W) 149 | Radiobutton(MAIN_WINDOW, text='Dry',variable=v3,value=3,command=c3).pack(anchor=W) 150 | 151 | #2nd 152 | l4=Label(MAIN_WINDOW, text = "2. How often do you have skin problems(pimple,acne)?",justify=LEFT) 153 | l4.pack(anchor=W) 154 | v3 = IntVar() 155 | Radiobutton(MAIN_WINDOW, text='Frequently',variable=v3,value=1,command=c1).pack(anchor=W) 156 | Radiobutton(MAIN_WINDOW, text='Sometimes',variable=v3,value=2,command=c2).pack(anchor=W) 157 | Radiobutton(MAIN_WINDOW, text='Never',variable=v3,value=3,command=c3).pack(anchor=W) 158 | 159 | 160 | #3rd 161 | l5=Label(MAIN_WINDOW, text = "3. How does your skin react to 2 hours of sun exposure without sunscreen?",justify=LEFT) 162 | l5.pack(anchor=W) 163 | v5 = IntVar() 164 | Radiobutton(MAIN_WINDOW, text='Skin Burns',variable=v5,value=1,command=c1).pack(anchor=W) 165 | Radiobutton(MAIN_WINDOW, text='Minor Burns',variable=v5,value=2,command=c2).pack(anchor=W) 166 | Radiobutton(MAIN_WINDOW, text='Never Burns',variable=v5,value=3,command=c3).pack(anchor=W) 167 | 168 | #4th 169 | l6=Label(MAIN_WINDOW, text = "4. Does new skin care often make your skin itch,burn or irritate?",justify=LEFT) 170 | l6.pack(anchor=W) 171 | v6 = IntVar() 172 | Radiobutton(MAIN_WINDOW, text='Yes',variable=v6,value=1,command=c1).pack(anchor=W) 173 | Radiobutton(MAIN_WINDOW, text='Yes, sometimes',variable=v6,value=2,command=c2).pack(anchor=W) 174 | Radiobutton(MAIN_WINDOW, text='No',variable=v6,value=3,command=c3).pack(anchor=W) 175 | 176 | #5th 177 | l7=Label(MAIN_WINDOW, text = "5. How often do you wash your face?",justify=LEFT) 178 | l7.pack(anchor=W) 179 | v7 = IntVar() 180 | Radiobutton(MAIN_WINDOW, text='Once a day',variable=v7,value=1,command=c1).pack(anchor=W) 181 | Radiobutton(MAIN_WINDOW, text='Twice a day',variable=v7,value=2,command=c2).pack(anchor=W) 182 | Radiobutton(MAIN_WINDOW, text='More than twice a day',variable=v7,value=3,command=c3).pack(anchor=W) 183 | 184 | #6th 185 | l8=Label(MAIN_WINDOW, text = "6. How much makeup do you use on a daily basis?",justify=LEFT) 186 | l8.pack(anchor=W) 187 | v8 = IntVar() 188 | Radiobutton(MAIN_WINDOW, text='None',variable=v8,value=1,command=c1).pack(anchor=W) 189 | Radiobutton(MAIN_WINDOW, text='Little',variable=v8,value=2,command=c2).pack(anchor=W) 190 | Radiobutton(MAIN_WINDOW, text='Full Coverage',variable=v8,value=3,command=c3).pack(anchor=W) 191 | 192 | #7th 193 | l9=Label(MAIN_WINDOW, text = "7. How often is your skin sensitive?",justify=LEFT) 194 | l9.pack(anchor=W) 195 | v9 = IntVar() 196 | Radiobutton(MAIN_WINDOW, text='Never',variable=v9,value=1,command=c1).pack(anchor=W) 197 | Radiobutton(MAIN_WINDOW, text='Sometimes',variable=v9,value=2,command=c2).pack(anchor=W) 198 | Radiobutton(MAIN_WINDOW, text='All the time',variable=v9,value=3,command=c3).pack(anchor=W) 199 | 200 | 201 | Button(MAIN_WINDOW, text="Submit", width=10, height=1, bg="white",command=Facewash_pro).place(x=300,y=700) 202 | Button(MAIN_WINDOW, text="Buy", width=10, height=1, bg="white",command=Buy).place(x=400,y=700) 203 | 204 | def Facewash_pro(): 205 | if (a>b and a>c): 206 | messagebox.showinfo("Your ideal Facewash:","Himalaya Herbal Purifying Neem Face Wash") 207 | elif (b>c and b>a): 208 | messagebox.showinfo("Your ideal shampoo " ,"Garnier Skin Naturals Light Complete Facewash") 209 | elif (c>a and c>b): 210 | messagebox.showinfo("Your ideal shampoo" ,"Biotique Bio Honey Gel Facewash") 211 | elif (a==b): 212 | messagebox.showinfo("Your ideal shampoo" ,"Garnier Skin Naturals Light Complete Facewash") 213 | elif (b==c): 214 | messagebox.showinfo("Your ideal shampoo","Biotique Bio Honey Gel Facewash") 215 | elif (a==c): 216 | messagebox.showinfo("Your ideal shampoo" ,"Garnier Skin Naturals Light Complete Facewash") 217 | elif (a==b and b==c): 218 | messagebox.showinfo("Your ideal shampoo" ,"Garnier Skin Naturals Light Complete Facewash") 219 | 220 | 221 | 222 | #Function for soap !!! 223 | def Soap(): 224 | #1st 225 | LA=Label(MAIN_WINDOW, text = "Select the most appropriate answer:",justify=LEFT) 226 | l3=Label(MAIN_WINDOW, text = "1. What type of skin you have?",justify=LEFT) 227 | l3.pack(anchor=W) 228 | v3 = IntVar() 229 | Radiobutton(MAIN_WINDOW, text='Oily',variable=v3,value=1,command=c1).pack(anchor=W) 230 | Radiobutton(MAIN_WINDOW, text='Normal',variable=v3,value=2,command=c2).pack(anchor=W) 231 | Radiobutton(MAIN_WINDOW, text='Dry',variable=v3,value=3,command=c3).pack(anchor=W) 232 | 233 | #2nd 234 | l4=Label(MAIN_WINDOW, text = "2. Is your skin sensitive?",justify=LEFT) 235 | l4.pack(anchor=W) 236 | v3 = IntVar() 237 | Radiobutton(MAIN_WINDOW, text='No',variable=v3,value=1,command=c1).pack(anchor=W) 238 | Radiobutton(MAIN_WINDOW, text='Little',variable=v3,value=2,command=c2).pack(anchor=W) 239 | Radiobutton(MAIN_WINDOW, text='Very much',variable=v3,value=3,command=c3).pack(anchor=W) 240 | 241 | 242 | #3rd 243 | l5=Label(MAIN_WINDOW, text = "3. How often your skin react to change in skin products?",justify=LEFT) 244 | l5.pack(anchor=W) 245 | v5 = IntVar() 246 | Radiobutton(MAIN_WINDOW, text='Does not react',variable=v5,value=1,command=c1).pack(anchor=W) 247 | Radiobutton(MAIN_WINDOW, text='Sometimes',variable=v5,value=2,command=c2).pack(anchor=W) 248 | Radiobutton(MAIN_WINDOW, text='Never',variable=v5,value=3,command=c3).pack(anchor=W) 249 | 250 | #4th 251 | l6=Label(MAIN_WINDOW, text = "4. What fragrance do you like?",justify=LEFT) 252 | l6.pack(anchor=W) 253 | v6 = IntVar() 254 | Radiobutton(MAIN_WINDOW, text='Strawberry',variable=v6,value=1,command=c1).pack(anchor=W) 255 | Radiobutton(MAIN_WINDOW, text='Cocoa',variable=v6,value=2,command=c2).pack(anchor=W) 256 | Radiobutton(MAIN_WINDOW, text='Citrus',variable=v6,value=3,command=c3).pack(anchor=W) 257 | 258 | #5th 259 | l7=Label(MAIN_WINDOW, text = "5. How many bathing soaps do you buy per month?",justify=LEFT) 260 | l7.pack(anchor=W) 261 | v7 = IntVar() 262 | Radiobutton(MAIN_WINDOW, text='1-2',variable=v7,value=1,command=c1).pack(anchor=W) 263 | Radiobutton(MAIN_WINDOW, text='3-4',variable=v7,value=2,command=c2).pack(anchor=W) 264 | Radiobutton(MAIN_WINDOW, text='More',variable=v7,value=3,command=c3).pack(anchor=W) 265 | 266 | #6th 267 | l8=Label(MAIN_WINDOW, text = "6. How satisfied are you with your soap?",justify=LEFT) 268 | l8.pack(anchor=W) 269 | v8 = IntVar() 270 | Radiobutton(MAIN_WINDOW, text='Satisfied',variable=v8,value=1,command=c1).pack(anchor=W) 271 | Radiobutton(MAIN_WINDOW, text='Neither satisfied nor dissatisfied',variable=v8,value=2,command=c2).pack(anchor=W) 272 | Radiobutton(MAIN_WINDOW, text='Dissatisfied',variable=v8,value=3,command=c3).pack(anchor=W) 273 | 274 | #7th 275 | l9=Label(MAIN_WINDOW, text = "7. Do you prefer soap with colour and fragrance?",justify=LEFT) 276 | l9.pack(anchor=W) 277 | v9 = IntVar() 278 | Radiobutton(MAIN_WINDOW, text='Yes',variable=v9,value=1,command=c1).pack(anchor=W) 279 | Radiobutton(MAIN_WINDOW, text='Only fragrance',variable=v9,value=2,command=c2).pack(anchor=W) 280 | Radiobutton(MAIN_WINDOW, text='No',variable=v9,value=3,command=c3).pack(anchor=W) 281 | 282 | 283 | Button(MAIN_WINDOW, text="Submit", width=10, height=1, bg="white",command=Soap_pro).place(x=300,y=700) 284 | Button(MAIN_WINDOW, text="Buy", width=10, height=1, bg="white",command=Buy).place(x=400,y=700) 285 | 286 | def Soap_pro(): 287 | if (a>b and a>c): 288 | messagebox.showinfo("Your ideal Soap:","Dove Cream Beauty Bathing bar") 289 | elif (b>c and b>a): 290 | messagebox.showinfo("Your ideal Soap:" ,"Biotique Bio Almond Oil Nourishing Soap") 291 | elif (c>a and c>b): 292 | messagebox.showinfo("Your ideal Soap:" ,"Pears Pure and Gentle") 293 | elif (a==b): 294 | messagebox.showinfo("Your ideal Soap:" ,"Biotique Bio Almond Oil Nourishing Soap") 295 | elif (b==c): 296 | messagebox.showinfo("Your ideal Soap:","Pears Pure and Gentle") 297 | elif (a==c): 298 | messagebox.showinfo("Your ideal Soap:" ,"Biotique Bio Almond Oil Nourishing Soap") 299 | elif (a==b and b==c): 300 | messagebox.showinfo("Your ideal Soap:" ,"Biotique Bio Almond Oil Nourishing Soap") 301 | 302 | 303 | 304 | #Function for shirt (men) !!! 305 | def Shirt_men(): 306 | #1st 307 | LA=Label(MAIN_WINDOW, text = "Select the most appropriate answer:",justify=LEFT) 308 | l3=Label(MAIN_WINDOW, text = "1. What is your size?",justify=LEFT) 309 | l3.pack(anchor=W) 310 | v3 = IntVar() 311 | Radiobutton(MAIN_WINDOW, text='Small',variable=v3,value=1,command=c1).pack(anchor=W) 312 | Radiobutton(MAIN_WINDOW, text='Medium',variable=v3,value=2,command=c2).pack(anchor=W) 313 | Radiobutton(MAIN_WINDOW, text='Large',variable=v3,value=3,command=c3).pack(anchor=W) 314 | 315 | #2nd 316 | l4=Label(MAIN_WINDOW, text = "2. What type of collar?",justify=LEFT) 317 | l4.pack(anchor=W) 318 | v3 = IntVar() 319 | Radiobutton(MAIN_WINDOW, text='Classic',variable=v3,value=1,command=c1).pack(anchor=W) 320 | Radiobutton(MAIN_WINDOW, text='Button',variable=v3,value=2,command=c2).pack(anchor=W) 321 | Radiobutton(MAIN_WINDOW, text='Mandarian',variable=v3,value=3,command=c3).pack(anchor=W) 322 | 323 | 324 | #3rd 325 | l5=Label(MAIN_WINDOW, text = "3. What kind of shirt do you want?",justify=LEFT) 326 | l5.pack(anchor=W) 327 | v5 = IntVar() 328 | Radiobutton(MAIN_WINDOW, text='Western',variable=v5,value=1,command=c1).pack(anchor=W) 329 | Radiobutton(MAIN_WINDOW, text='Casual',variable=v5,value=2,command=c2).pack(anchor=W) 330 | Radiobutton(MAIN_WINDOW, text='Formal',variable=v5,value=3,command=c3).pack(anchor=W) 331 | 332 | #4th 333 | l6=Label(MAIN_WINDOW, text = "4. What kind of sleeve do you prefer?",justify=LEFT) 334 | l6.pack(anchor=W) 335 | v6 = IntVar() 336 | Radiobutton(MAIN_WINDOW, text='Long',variable=v6,value=1,command=c1).pack(anchor=W) 337 | Radiobutton(MAIN_WINDOW, text='Short',variable=v6,value=2,command=c2).pack(anchor=W) 338 | Radiobutton(MAIN_WINDOW, text='Sleeveless',variable=v6,value=3,command=c3).pack(anchor=W) 339 | 340 | #5th 341 | l7=Label(MAIN_WINDOW, text = "5. What kind of fabric do you prefer?",justify=LEFT) 342 | l7.pack(anchor=W) 343 | v7 = IntVar() 344 | Radiobutton(MAIN_WINDOW, text='Linen',variable=v7,value=1,command=c1).pack(anchor=W) 345 | Radiobutton(MAIN_WINDOW, text='Cotton',variable=v7,value=2,command=c2).pack(anchor=W) 346 | Radiobutton(MAIN_WINDOW, text='Silk',variable=v7,value=3,command=c3).pack(anchor=W) 347 | 348 | #6th 349 | l8=Label(MAIN_WINDOW, text = "6. Select the type of fitting",justify=LEFT) 350 | l8.pack(anchor=W) 351 | v8 = IntVar() 352 | Radiobutton(MAIN_WINDOW, text='Skinny fit',variable=v8,value=1,command=c1).pack(anchor=W) 353 | Radiobutton(MAIN_WINDOW, text='Classic Fit',variable=v8,value=2,command=c2).pack(anchor=W) 354 | Radiobutton(MAIN_WINDOW, text='Modern Fit',variable=v8,value=3,command=c3).pack(anchor=W) 355 | 356 | #7th 357 | l9=Label(MAIN_WINDOW, text = "7. For what type of occasion do you need this shirt?",justify=LEFT) 358 | l9.pack(anchor=W) 359 | v9 = IntVar() 360 | Radiobutton(MAIN_WINDOW, text='Formal funcgtion',variable=v9,value=1,command=c1).pack(anchor=W) 361 | Radiobutton(MAIN_WINDOW, text='Party wear',variable=v9,value=2,command=c2).pack(anchor=W) 362 | Radiobutton(MAIN_WINDOW, text='Social gathering',variable=v9,value=3,command=c3).pack(anchor=W) 363 | 364 | 365 | Button(MAIN_WINDOW, text="Submit", width=10, height=1, bg="white",command=Shirt_Men_pro).place(x=300,y=700) 366 | Button(MAIN_WINDOW, text="Buy", width=10, height=1, bg="white",command=Buy).place(x=400,y=700) 367 | 368 | def Shirt_Men_pro(): 369 | if (a>b and a>c): 370 | messagebox.showinfo("Your ideal Shirt:","Peter England Navy Blue Solid Shirt") 371 | elif (b>c and b>a): 372 | messagebox.showinfo("Your ideal Shirt:" ,"GAP Olive Solid Shirt") 373 | elif (c>a and c>b): 374 | messagebox.showinfo("Your ideal Shirt:" ,"Peter England Black Solid Shirt") 375 | elif (a==b): 376 | messagebox.showinfo("Your ideal Shirt:" ,"GAP Olive Solid Shirt") 377 | elif (b==c): 378 | messagebox.showinfo("Your ideal Shirt:","Peter England Black Solid Shirt") 379 | elif (a==c): 380 | messagebox.showinfo("Your ideal Shirt:" ,"GAP Olive Solid Shirt") 381 | elif (a==b and b==c): 382 | messagebox.showinfo("Your ideal Shirt:" ,"GAP Olive Solid Shirt") 383 | 384 | 385 | 386 | #Function for shirt (women) !!! 387 | def Shirt_women(): 388 | #1st 389 | LA=Label(MAIN_WINDOW, text = "Select the most appropriate answer:",justify=LEFT) 390 | l3=Label(MAIN_WINDOW, text = "1. What is your size?",justify=LEFT) 391 | l3.pack(anchor=W) 392 | v3 = IntVar() 393 | Radiobutton(MAIN_WINDOW, text='Small',variable=v3,value=1,command=c1).pack(anchor=W) 394 | Radiobutton(MAIN_WINDOW, text='Medium',variable=v3,value=2,command=c2).pack(anchor=W) 395 | Radiobutton(MAIN_WINDOW, text='Large',variable=v3,value=3,command=c3).pack(anchor=W) 396 | 397 | #2nd 398 | l4=Label(MAIN_WINDOW, text = "2. What type of neck do you prefer?",justify=LEFT) 399 | l4.pack(anchor=W) 400 | v3 = IntVar() 401 | Radiobutton(MAIN_WINDOW, text='V-neck',variable=v3,value=1,command=c1).pack(anchor=W) 402 | Radiobutton(MAIN_WINDOW, text='Turtleneck',variable=v3,value=2,command=c2).pack(anchor=W) 403 | Radiobutton(MAIN_WINDOW, text='Low neck',variable=v3,value=3,command=c3).pack(anchor=W) 404 | 405 | 406 | #3rd 407 | l5=Label(MAIN_WINDOW, text = "3. What kind of shirt do you want?",justify=LEFT) 408 | l5.pack(anchor=W) 409 | v5 = IntVar() 410 | Radiobutton(MAIN_WINDOW, text='Western',variable=v5,value=1,command=c1).pack(anchor=W) 411 | Radiobutton(MAIN_WINDOW, text='Casual',variable=v5,value=2,command=c2).pack(anchor=W) 412 | Radiobutton(MAIN_WINDOW, text='Formal',variable=v5,value=3,command=c3).pack(anchor=W) 413 | 414 | #4th 415 | l6=Label(MAIN_WINDOW, text = "4. What kind of sleeve do you prefer?",justify=LEFT) 416 | l6.pack(anchor=W) 417 | v6 = IntVar() 418 | Radiobutton(MAIN_WINDOW, text='Long',variable=v6,value=1,command=c1).pack(anchor=W) 419 | Radiobutton(MAIN_WINDOW, text='Short',variable=v6,value=2,command=c2).pack(anchor=W) 420 | Radiobutton(MAIN_WINDOW, text='Sleeveless',variable=v6,value=3,command=c3).pack(anchor=W) 421 | 422 | #5th 423 | l7=Label(MAIN_WINDOW, text = "5. What kind of fabric do you prefer?",justify=LEFT) 424 | l7.pack(anchor=W) 425 | v7 = IntVar() 426 | Radiobutton(MAIN_WINDOW, text='Linen',variable=v7,value=1,command=c1).pack(anchor=W) 427 | Radiobutton(MAIN_WINDOW, text='Cotton',variable=v7,value=2,command=c2).pack(anchor=W) 428 | Radiobutton(MAIN_WINDOW, text='Silk',variable=v7,value=3,command=c3).pack(anchor=W) 429 | 430 | #6th 431 | l8=Label(MAIN_WINDOW, text = "6. Select the type of fitting",justify=LEFT) 432 | l8.pack(anchor=W) 433 | v8 = IntVar() 434 | Radiobutton(MAIN_WINDOW, text='Skinny fit',variable=v8,value=1,command=c1).pack(anchor=W) 435 | Radiobutton(MAIN_WINDOW, text='Classic Fit',variable=v8,value=2,command=c2).pack(anchor=W) 436 | Radiobutton(MAIN_WINDOW, text='Modern Fit',variable=v8,value=3,command=c3).pack(anchor=W) 437 | 438 | #7th 439 | l9=Label(MAIN_WINDOW, text = "7. For what type of occasion do you need this shirt?",justify=LEFT) 440 | l9.pack(anchor=W) 441 | v9 = IntVar() 442 | Radiobutton(MAIN_WINDOW, text='Formal funcgtion',variable=v9,value=1,command=c1).pack(anchor=W) 443 | Radiobutton(MAIN_WINDOW, text='Party wear',variable=v9,value=2,command=c2).pack(anchor=W) 444 | Radiobutton(MAIN_WINDOW, text='Social gathering',variable=v9,value=3,command=c3).pack(anchor=W) 445 | 446 | 447 | Button(MAIN_WINDOW, text="Submit", width=10, height=1, bg="white",command=Shirt_Women_pro).place(x=300,y=700) 448 | Button(MAIN_WINDOW, text="Buy", width=10, height=1, bg="white",command=Buy).place(x=400,y=700) 449 | 450 | def Shirt_Women_pro(): 451 | if (a>b and a>c): 452 | messagebox.showinfo("Your ideal Shirt:","GAP Blue Fitted Boyfriend Shirt") 453 | elif (b>c and b>a): 454 | messagebox.showinfo("Your ideal Shirt:" ,"H&M Olive Solid Shirt") 455 | elif (c>a and c>b): 456 | messagebox.showinfo("Your ideal Shirt:" ,"Vero Moda Black Solid Top") 457 | elif (a==b): 458 | messagebox.showinfo("Your ideal Shirt:" ,"H&M Olive Solid Shirt") 459 | elif (b==c): 460 | messagebox.showinfo("Your ideal Shirt:","Vero Moda Black Solid Top") 461 | elif (a==c): 462 | messagebox.showinfo("Your ideal Shirt:" ,"H&M Olive Solid Shirt") 463 | elif (a==b and b==c): 464 | messagebox.showinfo("Your ideal Shirt:" ,"H&M Olive Solid Shirt") 465 | 466 | 467 | 468 | #Function for denims !!! 469 | def Denims(): 470 | #1st 471 | LA=Label(MAIN_WINDOW, text = "Select the most appropriate answer:",justify=LEFT) 472 | l3=Label(MAIN_WINDOW, text = "1. What is your size?",justify=LEFT) 473 | l3.pack(anchor=W) 474 | v3 = IntVar() 475 | Radiobutton(MAIN_WINDOW, text='Small',variable=v3,value=1,command=c1).pack(anchor=W) 476 | Radiobutton(MAIN_WINDOW, text='Medium',variable=v3,value=2,command=c2).pack(anchor=W) 477 | Radiobutton(MAIN_WINDOW, text='Large',variable=v3,value=3,command=c3).pack(anchor=W) 478 | 479 | #2nd 480 | l4=Label(MAIN_WINDOW, text = "2. What kind of fitting do you prefer?",justify=LEFT) 481 | l4.pack(anchor=W) 482 | v3 = IntVar() 483 | Radiobutton(MAIN_WINDOW, text='Skinny',variable=v3,value=1,command=c1).pack(anchor=W) 484 | Radiobutton(MAIN_WINDOW, text='Bootcut',variable=v3,value=2,command=c2).pack(anchor=W) 485 | Radiobutton(MAIN_WINDOW, text='Pegged',variable=v3,value=3,command=c3).pack(anchor=W) 486 | 487 | 488 | #3rd 489 | l5=Label(MAIN_WINDOW, text = "3. How often do you wear jeans?",justify=LEFT) 490 | l5.pack(anchor=W) 491 | v5 = IntVar() 492 | Radiobutton(MAIN_WINDOW, text='More than once a week',variable=v5,value=1,command=c1).pack(anchor=W) 493 | Radiobutton(MAIN_WINDOW, text='Once a week',variable=v5,value=2,command=c2).pack(anchor=W) 494 | Radiobutton(MAIN_WINDOW, text='Once a month',variable=v5,value=3,command=c3).pack(anchor=W) 495 | 496 | #4th 497 | l6=Label(MAIN_WINDOW, text = "4. What colour do you prefer?",justify=LEFT) 498 | l6.pack(anchor=W) 499 | v6 = IntVar() 500 | Radiobutton(MAIN_WINDOW, text='Blue',variable=v6,value=1,command=c1).pack(anchor=W) 501 | Radiobutton(MAIN_WINDOW, text='White',variable=v6,value=2,command=c2).pack(anchor=W) 502 | Radiobutton(MAIN_WINDOW, text='Black',variable=v6,value=3,command=c3).pack(anchor=W) 503 | 504 | #5th 505 | l7=Label(MAIN_WINDOW, text = "5. How often do you buy jeans?",justify=LEFT) 506 | l7.pack(anchor=W) 507 | v7 = IntVar() 508 | Radiobutton(MAIN_WINDOW, text='Whenever I like',variable=v7,value=1,command=c1).pack(anchor=W) 509 | Radiobutton(MAIN_WINDOW, text='Every few months',variable=v7,value=2,command=c2).pack(anchor=W) 510 | Radiobutton(MAIN_WINDOW, text='When my current pair cannot be worn anymore',variable=v7,value=3,command=c3).pack(anchor=W) 511 | 512 | #6th 513 | l8=Label(MAIN_WINDOW, text = "6. What type of jeans do you buy?",justify=LEFT) 514 | l8.pack(anchor=W) 515 | v8 = IntVar() 516 | Radiobutton(MAIN_WINDOW, text='Cheap',variable=v8,value=1,command=c1).pack(anchor=W) 517 | Radiobutton(MAIN_WINDOW, text='Moderate',variable=v8,value=2,command=c2).pack(anchor=W) 518 | Radiobutton(MAIN_WINDOW, text='Expensive',variable=v8,value=3,command=c3).pack(anchor=W) 519 | 520 | #7th 521 | l9=Label(MAIN_WINDOW, text = "7. Which is your favourite brand?",justify=LEFT) 522 | l9.pack(anchor=W) 523 | v9 = IntVar() 524 | Radiobutton(MAIN_WINDOW, text='Levis',variable=v9,value=1,command=c1).pack(anchor=W) 525 | Radiobutton(MAIN_WINDOW, text='Mufti',variable=v9,value=2,command=c2).pack(anchor=W) 526 | Radiobutton(MAIN_WINDOW, text='H&M',variable=v9,value=3,command=c3).pack(anchor=W) 527 | 528 | 529 | Button(MAIN_WINDOW, text="Submit", width=10, height=1, bg="white",command=Denims_pro).place(x=300,y=700) 530 | Button(MAIN_WINDOW, text="Buy", width=10, height=1, bg="white",command=Buy).place(x=400,y=700) 531 | 532 | def Denims_pro(): 533 | if (a>b and a>c): 534 | messagebox.showinfo("Your ideal Jeans:","Levis Blue Highrise Jeans") 535 | elif (b>c and b>a): 536 | messagebox.showinfo("Your ideal Jeans:" ,"H&M White Biker Jeans") 537 | elif (c>a and c>b): 538 | messagebox.showinfo("Your ideal Jeans:" ,"Mufti Black Slimfit Jeans") 539 | elif (a==b): 540 | messagebox.showinfo("Your ideal Jeans:" ,"Tommy Hilfiger Slimfit Jeans") 541 | elif (b==c): 542 | messagebox.showinfo("Your ideal Jeans:","Calvin Klein Slimfit Jeans") 543 | elif (a==c): 544 | messagebox.showinfo("Your ideal Jeans:" ,"Tommy Hilfiger Ripped Jeans") 545 | elif (a==b and b==c): 546 | messagebox.showinfo("Your ideal Jeans:" ,"H&M distressed Jeans") 547 | 548 | 549 | def Buy(): 550 | print("Visit this link to buy your product: https://www.amazon.in/") 551 | 552 | 553 | #Function for login screen 554 | def login(): 555 | uname=username.get() 556 | pwd=password.get() 557 | if uname=='' or pwd=='': 558 | message.set("Fill the empty field!!!") 559 | else: 560 | if uname=="Chandler" and pwd=="Monica": 561 | message.set("Login success") 562 | login_screen.destroy() 563 | main1() 564 | else: 565 | message.set("Wrong username or password!!!") 566 | global login_screen 567 | login_screen = Tk() 568 | #Setting title of screen 569 | login_screen.title("Login Form") 570 | #setting height and width of screen 571 | login_screen.geometry("300x250") 572 | #declaring variable 573 | global message 574 | global username 575 | global password 576 | username = StringVar() 577 | password = StringVar() 578 | message=StringVar() 579 | #Creating layout of login form 580 | Label(login_screen,width="300", text="Please enter details below", bg="deep sky blue",fg="white").pack() 581 | #Username Label 582 | Label(login_screen, text="Username * ").place(x=20,y=40) 583 | #Username textbox 584 | Entry(login_screen, textvariable=username).place(x=90,y=42) 585 | #Password Label 586 | Label(login_screen, text="Password * ").place(x=20,y=80) 587 | #Password textbox 588 | Entry(login_screen, textvariable=password ,show="*").place(x=90,y=82) 589 | #Label for displaying login status[success/failed] 590 | Label(login_screen, text="",textvariable=message).place(x=95,y=100) 591 | #Login button 592 | Button(login_screen, text="Login", width=10, height=1, bg="white",command=login).place(x=105,y=130) 593 | login_screen.mainloop() 594 | #calling function Loginform -------------------------------------------------------------------------------- /Tkinter_recommendation_system/readme.md: -------------------------------------------------------------------------------- 1 | # Customized Product Recommendation System 2 | A python based product recommendation system which uses Tkinter package as a GUI method 3 | Functionalities of this recommendation system: 4 | * It asks the user a number of questions based on the product they want to buy 5 | * Based on the options selected by the user, they are recommended products that are best suited for them 6 | -------------------------------------------------------------------------------- /Web scraping/Get_img.py: -------------------------------------------------------------------------------- 1 | import requests 2 | import bs4 3 | 4 | resultt= requests.get("https://en.wikipedia.org/wiki/Grace_Hopper") 5 | sou=bs4.BeautifulSoup(resultt.text, "lxml") 6 | img_src="" 7 | y=0 8 | for x in (sou.select('.thumbimage')): 9 | y=y+1 10 | if y==2: #selects the third listed image on the page 11 | img_src=x['src'] 12 | print(img_src) 13 | break 14 | 15 | image_l=requests.get('https:'+img_src) 16 | #print(image_l.content) #to display contents of image's binary file 17 | 18 | f=open("Mynewimage.jpg", 'wb') 19 | f.write(image_l.content) 20 | f.close() 21 | 22 | #This program saves the image from a single webpage in the folder where your python file exists 23 | -------------------------------------------------------------------------------- /Web scraping/Rating_filter.py: -------------------------------------------------------------------------------- 1 | import requests 2 | import bs4 3 | ex_url="http://books.toscrape.com/catalogue/page-{}.html" #dummy website for web scraping 4 | x=1 5 | while (x<20): #20 is the number of pages on the website 6 | cur_page=ex_url.format(x) 7 | res= requests.get(cur_page) 8 | soup=bs4.BeautifulSoup(res.text,"lxml") 9 | prod=soup.select('.product_pod') 10 | ctr=0 11 | for user in (prod): 12 | 13 | if(user.select('.star-rating.Three')==[]): #three- starred items 14 | pass 15 | else: 16 | print(user.select('a')[1]['title']) #print the name of the product 17 | x=x+1 18 | -------------------------------------------------------------------------------- /Web scraping/Readme.md: -------------------------------------------------------------------------------- 1 | # Web-Scraping 2 | (BASIC PROJECTS) 3 | ## [Rating Filter](https://github.com/Aishanipach/Beginners-Python-Programs/blob/main/Web%20scraping/Rating_filter.py) 4 | 5 | It's a filter to find the items that have certain rating by the website. 6 | 7 | 8 | ## [Get Image](https://github.com/Aishanipach/Beginners-Python-Programs/blob/main/Web%20scraping/Get_img.py) 9 | 10 | It's a program to download specific images from a webpage 11 | 12 | 13 | --- 14 | ### `requests` `bs4 (Beautifulsoup)` 15 | -------------------------------------------------------------------------------- /Web scraping/Syntax.txt: -------------------------------------------------------------------------------- 1 | #Libraries 2 | import requests 3 | import bs4 (BeautifulSoup) 4 | 5 | #Syntax for specific tags 6 | soup.select('div') #for a div tag 7 | soup.select('#some_id') #to get elements with this id 8 | soup.select('.some_class') #elements containing this class 9 | soup.select('div span') #any element named span under a div 10 | soup.select(' div > span') #with any element named span directly under a div w/o anything in b/w 11 | -------------------------------------------------------------------------------- /diamond_symbol.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | for i in range (0,n): 3 | print(" "*(n-i),"#"*i + str("#"*(i-1))) 4 | for i in range(n,0,-1): 5 | print(" "*(n-i),"#"*i + str("#"*(i-1))) 6 | -------------------------------------------------------------------------------- /fibonacci_series.py: -------------------------------------------------------------------------------- 1 | # Program to display the Fibonacci sequence up to n-th term 2 | 3 | nterms = int(input("How many terms? ")) 4 | 5 | # first two terms 6 | n1, n2 = 0, 1 7 | count = 0 8 | 9 | # check if the number of terms is valid 10 | if nterms <= 0: 11 | print("Please enter a positive integer") 12 | 13 | # if there is only one term, return n1 14 | elif nterms == 1: 15 | print("Fibonacci sequence upto",nterms,":") 16 | print(n1) 17 | 18 | # generate fibonacci sequence 19 | else: 20 | print("Fibonacci sequence:") 21 | while count < nterms: 22 | print(n1) 23 | nth = n1 + n2 24 | # update values 25 | n1 = n2 26 | n2 = nth 27 | count += 1 28 | -------------------------------------------------------------------------------- /functionMaxMinMedian.py: -------------------------------------------------------------------------------- 1 | def bth(a, b, c, d, e): 2 | return max(a, b, c, d, e) 3 | 4 | def sml(a, b, c, d, e): 5 | return min(a, b, c, d, e) 6 | 7 | def aritmetic_median(a, b, c, d, e): 8 | return (a+b+c+d+e)/5 9 | 10 | def main(): 11 | n1 = int(input(" ")) 12 | n2 = int(input(" ")) 13 | n3 = int(input(" ")) 14 | n4 = int(input(" ")) 15 | n5 = int(input(" ")) 16 | 17 | mx = bth(n1, n2, n3, n4, n5) 18 | mnr = sml(n1, n2, n3, n4, n5) 19 | median = aritmetic_median(n1, n2, n3, n4, n5) 20 | 21 | print(f'biggest number {mx}, smallest number {mnr}, aritimetic median: {median}.') 22 | 23 | if __name__== '__main__': 24 | main() -------------------------------------------------------------------------------- /gui_calculator.py: -------------------------------------------------------------------------------- 1 | from tkinter import * 2 | 3 | a="" 4 | 5 | def press(n): 6 | global a 7 | a+=str(n) 8 | equation.set(a) 9 | 10 | def equalpress(): 11 | try: 12 | global a 13 | t=str(eval(a)) 14 | equation.set(t) 15 | a="" 16 | except: 17 | equation.set("Error") 18 | a="" 19 | 20 | def clear(): 21 | global a 22 | a="" 23 | equation.set("") 24 | 25 | if __name__=="__main__": 26 | gui=Tk() 27 | gui.configure(background="black") 28 | gui.title("Calculator") 29 | gui.geometry("260x150") 30 | equation=StringVar() 31 | a_field=Entry(gui,textvariable=equation) 32 | a_field.grid(columnspan=4,ipadx=70) 33 | equation.set 34 | 35 | button1=Button(gui,text="1",fg="black",bg="white",command=lambda:press(1),height=1,width=7) 36 | button1.grid(row=2,column=0) 37 | 38 | button2=Button(gui,text="2",fg="black",bg="white",command=lambda:press(2),height=1,width=7) 39 | button2.grid(row=2,column=1) 40 | 41 | button3=Button(gui,text="3",fg="black",bg="white",command=lambda:press(3),height=1,width=7) 42 | button3.grid(row=2,column=2) 43 | 44 | button4=Button(gui,text="4",fg="black",bg="white",command=lambda:press(4),height=1,width=7) 45 | button4.grid(row=3,column=0) 46 | 47 | button5=Button(gui,text="5",fg="black",bg="white",command=lambda:press(5),height=1,width=7) 48 | button5.grid(row=3,column=1) 49 | 50 | button6=Button(gui,text="6",fg="black",bg="white",command=lambda:press(6),height=1,width=7) 51 | button6.grid(row=3,column=2) 52 | 53 | button7=Button(gui,text="7",fg="black",bg="white",command=lambda:press(7),height=1,width=7) 54 | button7.grid(row=4,column=0) 55 | 56 | button8=Button(gui,text="8",fg="black",bg="white",command=lambda:press(8),height=1,width=7) 57 | button8.grid(row=4,column=1) 58 | 59 | button9=Button(gui,text="9",fg="black",bg="white",command=lambda:press(9),height=1,width=7) 60 | button9.grid(row=4,column=2) 61 | 62 | button0=Button(gui,text="0",fg="black",bg="white",command=lambda:press(0),height=1,width=7) 63 | button0.grid(row=5,column=0) 64 | 65 | plus=Button(gui,text="+",fg="black",bg="white",command=lambda:press("+"),height=1,width=7) 66 | plus.grid(row=2,column=3) 67 | 68 | minus=Button(gui,text="-",fg="black",bg="white",command=lambda:press("-"),height=1,width=7) 69 | minus.grid(row=3,column=3) 70 | 71 | multiply=Button(gui,text="*",fg="black",bg="white",command=lambda:press("*"),height=1,width=7) 72 | multiply.grid(row=4,column=3) 73 | 74 | divide=Button(gui,text="/",fg="black",bg="white",command=lambda:press("/"),height=1,width=7) 75 | divide.grid(row=5,column=3) 76 | 77 | equal=Button(gui,text="=",fg="black",bg="white",command=equalpress,height=1,width=7) 78 | equal.grid(row=5,column=2) 79 | 80 | clear=Button(gui,text="C",fg="black",bg="white",command=clear,height=1,width=7) 81 | clear.grid(row=5,column=1) 82 | 83 | decimal=Button(gui,text=".",fg="black",bg="white",command=lambda:press("."),height=1,width=7) 84 | decimal.grid(row=6,column=0) 85 | 86 | gui.mainloop() 87 | -------------------------------------------------------------------------------- /prime_numbers_in_input_range.py: -------------------------------------------------------------------------------- 1 | x = int(input()) 2 | y = int(input()) 3 | list1 = [] 4 | if x>y: 5 | x,y = y,x 6 | 7 | for i in range (x,y+1): 8 | for j in range(2,i//2): 9 | if i%j == 0: 10 | break 11 | else: 12 | list1.append(i) 13 | print(list1) 14 | -------------------------------------------------------------------------------- /quick_sort.py: -------------------------------------------------------------------------------- 1 | # function to find the partition position 2 | def partition(arr, lb, hb): 3 | 4 | # choose the rbtmost element as pivot 5 | pivot = arr[hb] 6 | 7 | # pointer for greater element 8 | i = lb - 1 9 | 10 | # traverse through all elements 11 | # compare each element with pivot 12 | for j in range(lb, hb): 13 | if arr[j] <= pivot: 14 | # if element smaller than pivot is found 15 | # swap it with the greater element pointed by i 16 | i = i + 1 17 | 18 | # swapping element at i with element at j 19 | (arr[i], arr[j]) = (arr[j], arr[i]) 20 | 21 | # swap the pivot element with the greater element specified by i 22 | (arr[i + 1], arr[hb]) = (arr[hb], arr[i + 1]) 23 | 24 | # return the position from where partition is done 25 | return i + 1 26 | 27 | def quickSort(arr,lb,ub): 28 | if (lb < ub): 29 | loc = partition(arr,lb,ub) 30 | quickSort(arr,lb,loc-1) 31 | quickSort(arr,loc+1,ub) 32 | 33 | data = [8, 7, 2, 1, 0, 9, 6] 34 | print("Unsorted Array: ") 35 | print(data) 36 | 37 | size = len(data) 38 | 39 | quickSort(data, 0, size - 1) 40 | 41 | print('Sorted Array in Ascending Order:') 42 | print(data) 43 | 44 | #Time complexity: O(n*log n) 45 | #Space complexity: O(log n) -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # First-Python-Program - CONTRIBUTE FOR HACKTOBERFEST! ✔ 2 | ### `Visual Studio Code` `Hacktoberfest'22` 3 | ## Introduction 4 | I have listed some of the interesting python related topics and programs that I came across and would be fun for those who are learning python. Feel free to add basic python scripts that helped you learn python. Remember that making comments in the projects is helpful for learning. 5 | 6 | ## How to use 7 | - Add your own project in the repository: 8 | - create an individual subfolder named with the projects title 9 | - add project in folder 10 | - make README file explaining project functionality 11 | - add username into README file 12 | - Add helpful comments in higher level projects 13 | - Add test cases for testing new changes 14 | - Fork the project and work with the code to learn 15 | 16 | ## How to Fork and Contribute to the Main 💻👨‍💻 17 | - Fork the given project- [How?](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork) 18 | - Make a folder named after your program 19 | - Add your program file 20 | - Edit **README.md**- Index Section and add your program name as follows: 21 | [Name of the Program](url)- [your full name](github-url) 22 | - in **README.md** write about the purpose of the project and concepts or data structures used 23 | - Start the repo & you are done! 24 | 25 | ## Index 📑: 26 | 1. [Count Primes](https://github.com/Aishanipach/Beginners-Python-Programs/tree/main/Count_primes) 27 | 2. [Three Cup Monty(extended)](https://github.com/Aishanipach/Beginners-Python-Programs/tree/main/Threecupsmonty) 28 | 3. [TicTacToe](https://github.com/Aishanipach/Beginners-Python-Programs/tree/main/TicTacToe) 29 | 4. [Summer of '69](https://github.com/Aishanipach/Beginners-Python-Programs/blob/main/Summerof'69.py) 30 | 5. [Tkinter](https://github.com/Aishanipach/Beginners-Python-Programs/tree/main/Tkinter) 31 | 6. [Card game project](https://github.com/Aishanipach/Beginners-Python-Programs/tree/main/Card_game_project) 32 | 7. [Web Scraping](https://github.com/Aishanipach/Beginners-Python-Programs/tree/main/Web%20scraping) 33 | 8. [Gmail Automation](https://github.com/Aishanipach/Beginners-Python-Programs/tree/main/Gmail%20automation) 34 | 9. [GUI Calculator](https://github.com/1-Rishabh-Jain-1/Beginners-Python-Projects/blob/main/gui_calculator.py) 35 | 10. [Higher Lower Game](https://github.com/TheTriangulam/Beginners-Python-Projects/tree/main/Num_guess_by_Comp)- [Devivaraprasad Rathikindi](https://github.com/TheTriangulam) 36 | 11. [Tkinter Recommendation System](https://github.com/varshaah2407/Beginners-Python-Projects/tree/main/Tkinter_recommendation_system) - [Varshaah Shashidhar](https://github.com/varshaah2407) 37 | 12. [prime numbers in a range](https://github.com/AG-444/Beginners-Python-Projects_AP/blob/main/prime_numbers_in_input_range.py) - [Aditya Garg](https://github.com/AG-444) 38 | 13. [Swap elements in an array](https://github.com/AG-444/Beginners-Python-Projects_AP/blob/main/swap_elements_in_array.py) - [Aditya Garg](https://github.com/AG-444) 39 | 14. [sum of elements of an array](https://github.com/AG-444/Beginners-Python-Projects_AP/blob/main/sum_of_elements_of_an_array.py) - [Aditya Garg](https://github.com/AG-444) 40 | 15. [print_diamond_shape](https://github.com/AG-444/Beginners-Python-Projects_AP/blob/main/diamond_symbol.py) - [Aditya Garg](https://github.com/AG-444) 41 | 16. [email response sender](https://github.com/arnavvgupta/email-response-sender) - [Arnav Gupta](https://github.com/arnavvgupta) 42 | 17. [Quick Sort](https://github.com/varshaah2407/Beginners-Python-Projects/blob/main/quick_sort.py) - [Varshaah Shashidhar](https://github.com/varshaah2407) 43 | 18. [aritmetic median, biggest number and lowest number](https://github.com/arnavvgupta/functionMaxMinMedian.py) 44 | 19. [Insertion Sort](https://github.com/musaibbatghar/Beginners-Python-Projects/blob/main/Insertion_Sort.py) - [Musaib Batghar](https://github.com/musaibbatghar) 45 | 20. [Snake game](https://github.com/Aishanipach/Beginners-Python-Projects/compare/main...meanshkumar:Beginners-Python-Projects:main?expand=1)- [Ansh Kumar](https://github.com/meanshkumar) 46 | 21. [Merge_Sort](https://github.com/proPrateekSahu/Beginners-Python-Projects/blob/main/MergeSort.py) - [Prateek Kumar Sahu](https://github.com/proPrateekSahu) 47 | 22. [Binary_Search](https://github.com/proPrateekSahu/Beginners-Python-Projects/blob/main/BinarySearch) - [Prateek Kumar Sahu](https://github.com/proPrateekSahu) 48 | 49 | 23. [Fibonacci_Series](https://github.com/Skillz619/Beginners-Python-Projects/blob/main/fibonacci_series.py) - [Shreekar Kolanu](https://github.com/Skillz619) 50 | 24. [Binary_Search](https://github.com/proPrateekSahu/Beginners-Python-Projects/blob/main/BinarySearch) - [Prateek Kumar Sahu](https://github.com/proPrateekSahu) 51 | 25. [TowerOfHoni](https://github.com/proPrateekSahu/Beginners-Python-Projects/blob/main/towerOfHoni.py) - [Prateek Kumar Sahu](https://github.com/proPrateekSahu) 52 | 26. [Matrix_Multiplier](https://github.com/proPrateekSahu/Beginners-Python-Projects/blob/main/MatrixMultiplier.py) - [Prateek Kumar Sahu](https://github.com/proPrateekSahu) 53 | 27. [Create Code To Find LCM](https://github.com/abhaypratapsinghkanpur/Beginners-Python-Projects/blob/main/Code%20To%20Find%20LCM) - [Abhay Pratap Singh](https://github.com/abhaypratapsinghkanpur) 54 | 28. [Create Python Program to Find the Square Root.py](https://github.com/abhaypratapsinghkanpur/Beginners-Python-Projects/blob/main/Create%20Python%20Program%20to%20Find%20the%20Square%20Root.py) - [Abhay Pratap Singh](https://github.com/abhaypratapsinghkanpur) 55 | 29. [Caeser Cipher](https://github.com/Damsith-LK/Beginners-Python-Projects/blob/main/Caeser%20Cipher.py) - [Damsith Wijekoon](https://github.com/Damsith-LK) 56 | 30. [DNA Sequence Analysis](https://github.com/Aishanipach/Beginners-Python-Programs/tree/main/DNA_Sequence_Analysis) - [Amelia Lauth](https://github.com/alauth22) 57 | -------------------------------------------------------------------------------- /snake_game.py: -------------------------------------------------------------------------------- 1 | from random import randrange 2 | from freegames import square,vector 3 | 4 | food=vector(0,0) 5 | snake=[vector(10,0)] 6 | aim=vector(0,-10) 7 | 8 | def change(x,y): 9 | aim.x=x 10 | aim.y=y 11 | 12 | def inside(head): 13 | return -200 < head.x < 190 and -200 < head.y < 190 14 | 15 | def move(): 16 | head=snake[-1].copy() 17 | head.move(aim) 18 | if not inside(head) or head in snake: 19 | square(head.x,head.y,9,"red") 20 | update() 21 | return 22 | snake.append() 23 | 24 | if head==food: 25 | print("snake",len(snake)) 26 | food.x=randrange(-15,15)*10 27 | food.y=randrange(-15,15)*10 28 | else: 29 | snake.pop(0) 30 | clear() 31 | 32 | for body in snake: 33 | square(body.x,body.y,9,"green") 34 | 35 | square(food.x,food,y,9,"red") 36 | update() 37 | ontimer(move,100) 38 | 39 | hideturtle() 40 | tracer(false) 41 | listen() 42 | onkey(lambda:changes(10,0),"Right") 43 | onkey(lambda:changes(-10,0),"Left") 44 | onkey(lambda:changes(0,10),"Up") 45 | onkey(lambda:changes(0,-10),"Down") 46 | 47 | move() 48 | done() 49 | -------------------------------------------------------------------------------- /snakegame.py: -------------------------------------------------------------------------------- 1 | from random import randrange 2 | from turtle import * 3 | 4 | from freegames import square, vector 5 | 6 | food = vector(0, 0) 7 | snake = [vector(10, 0)] 8 | aim = vector(0, -10) 9 | 10 | 11 | def change(x, y): 12 | """Change snake direction.""" 13 | aim.x = x 14 | aim.y = y 15 | 16 | 17 | def inside(head): 18 | """Return True if head inside boundaries.""" 19 | return -200 < head.x < 190 and -200 < head.y < 190 20 | 21 | 22 | def move(): 23 | """Move snake forward one segment.""" 24 | head = snake[-1].copy() 25 | head.move(aim) 26 | 27 | if not inside(head) or head in snake: 28 | square(head.x, head.y, 9, 'red') 29 | update() 30 | return 31 | 32 | snake.append(head) 33 | 34 | if head == food: 35 | print('Snake:', len(snake)) 36 | food.x = randrange(-15, 15) * 10 37 | food.y = randrange(-15, 15) * 10 38 | else: 39 | snake.pop(0) 40 | 41 | clear() 42 | 43 | for body in snake: 44 | square(body.x, body.y, 9, 'black') 45 | 46 | square(food.x, food.y, 9, 'green') 47 | update() 48 | ontimer(move, 100) 49 | 50 | 51 | setup(420, 420, 370, 0) 52 | hideturtle() 53 | tracer(False) 54 | listen() 55 | onkey(lambda: change(10, 0), 'Right') 56 | onkey(lambda: change(-10, 0), 'Left') 57 | onkey(lambda: change(0, 10), 'Up') 58 | onkey(lambda: change(0, -10), 'Down') 59 | move() 60 | done() 61 | -------------------------------------------------------------------------------- /space_shoote.py: -------------------------------------------------------------------------------- 1 | import pygame 2 | import os 3 | import time 4 | import random 5 | pygame.font.init() 6 | 7 | WIDTH, HEIGHT = 750, 750 8 | WIN = pygame.display.set_mode((WIDTH, HEIGHT)) 9 | pygame.display.set_caption("Space Shooter Tutorial") 10 | 11 | # Load images 12 | RED_SPACE_SHIP = pygame.image.load(os.path.join("assets", "pixel_ship_red_small.png")) 13 | GREEN_SPACE_SHIP = pygame.image.load(os.path.join("assets", "pixel_ship_green_small.png")) 14 | BLUE_SPACE_SHIP = pygame.image.load(os.path.join("assets", "pixel_ship_blue_small.png")) 15 | 16 | # Player player 17 | YELLOW_SPACE_SHIP = pygame.image.load(os.path.join("assets", "pixel_ship_yellow.png")) 18 | 19 | # Lasers 20 | RED_LASER = pygame.image.load(os.path.join("assets", "pixel_laser_red.png")) 21 | GREEN_LASER = pygame.image.load(os.path.join("assets", "pixel_laser_green.png")) 22 | BLUE_LASER = pygame.image.load(os.path.join("assets", "pixel_laser_blue.png")) 23 | YELLOW_LASER = pygame.image.load(os.path.join("assets", "pixel_laser_yellow.png")) 24 | 25 | # Background 26 | BG = pygame.transform.scale(pygame.image.load(os.path.join("assets", "background-black.png")), (WIDTH, HEIGHT)) 27 | 28 | class Laser: 29 | def __init__(self, x, y, img): 30 | self.x = x 31 | self.y = y 32 | self.img = img 33 | self.mask = pygame.mask.from_surface(self.img) 34 | 35 | def draw(self, window): 36 | window.blit(self.img, (self.x, self.y)) 37 | 38 | def move(self, vel): 39 | self.y += vel 40 | 41 | def off_screen(self, height): 42 | return not(self.y <= height and self.y >= 0) 43 | 44 | def collision(self, obj): 45 | return collide(self, obj) 46 | 47 | 48 | class Ship: 49 | COOLDOWN = 30 50 | 51 | def __init__(self, x, y, health=100): 52 | self.x = x 53 | self.y = y 54 | self.health = health 55 | self.ship_img = None 56 | self.laser_img = None 57 | self.lasers = [] 58 | self.cool_down_counter = 0 59 | 60 | def draw(self, window): 61 | window.blit(self.ship_img, (self.x, self.y)) 62 | for laser in self.lasers: 63 | laser.draw(window) 64 | 65 | def move_lasers(self, vel, obj): 66 | self.cooldown() 67 | for laser in self.lasers: 68 | laser.move(vel) 69 | if laser.off_screen(HEIGHT): 70 | self.lasers.remove(laser) 71 | elif laser.collision(obj): 72 | obj.health -= 10 73 | self.lasers.remove(laser) 74 | 75 | def cooldown(self): 76 | if self.cool_down_counter >= self.COOLDOWN: 77 | self.cool_down_counter = 0 78 | elif self.cool_down_counter > 0: 79 | self.cool_down_counter += 1 80 | 81 | def shoot(self): 82 | if self.cool_down_counter == 0: 83 | laser = Laser(self.x, self.y, self.laser_img) 84 | self.lasers.append(laser) 85 | self.cool_down_counter = 1 86 | 87 | def get_width(self): 88 | return self.ship_img.get_width() 89 | 90 | def get_height(self): 91 | return self.ship_img.get_height() 92 | 93 | 94 | class Player(Ship): 95 | def __init__(self, x, y, health=100): 96 | super().__init__(x, y, health) 97 | self.ship_img = YELLOW_SPACE_SHIP 98 | self.laser_img = YELLOW_LASER 99 | self.mask = pygame.mask.from_surface(self.ship_img) 100 | self.max_health = health 101 | 102 | def move_lasers(self, vel, objs): 103 | self.cooldown() 104 | for laser in self.lasers: 105 | laser.move(vel) 106 | if laser.off_screen(HEIGHT): 107 | self.lasers.remove(laser) 108 | else: 109 | for obj in objs: 110 | if laser.collision(obj): 111 | objs.remove(obj) 112 | if laser in self.lasers: 113 | self.lasers.remove(laser) 114 | 115 | def draw(self, window): 116 | super().draw(window) 117 | self.healthbar(window) 118 | 119 | def healthbar(self, window): 120 | pygame.draw.rect(window, (255,0,0), (self.x, self.y + self.ship_img.get_height() + 10, self.ship_img.get_width(), 10)) 121 | pygame.draw.rect(window, (0,255,0), (self.x, self.y + self.ship_img.get_height() + 10, self.ship_img.get_width() * (self.health/self.max_health), 10)) 122 | 123 | 124 | class Enemy(Ship): 125 | COLOR_MAP = { 126 | "red": (RED_SPACE_SHIP, RED_LASER), 127 | "green": (GREEN_SPACE_SHIP, GREEN_LASER), 128 | "blue": (BLUE_SPACE_SHIP, BLUE_LASER) 129 | } 130 | 131 | def __init__(self, x, y, color, health=100): 132 | super().__init__(x, y, health) 133 | self.ship_img, self.laser_img = self.COLOR_MAP[color] 134 | self.mask = pygame.mask.from_surface(self.ship_img) 135 | 136 | def move(self, vel): 137 | self.y += vel 138 | 139 | def shoot(self): 140 | if self.cool_down_counter == 0: 141 | laser = Laser(self.x-20, self.y, self.laser_img) 142 | self.lasers.append(laser) 143 | self.cool_down_counter = 1 144 | 145 | 146 | def collide(obj1, obj2): 147 | offset_x = obj2.x - obj1.x 148 | offset_y = obj2.y - obj1.y 149 | return obj1.mask.overlap(obj2.mask, (offset_x, offset_y)) != None 150 | 151 | def main(): 152 | run = True 153 | FPS = 60 154 | level = 0 155 | lives = 5 156 | main_font = pygame.font.SysFont("comicsans", 50) 157 | lost_font = pygame.font.SysFont("comicsans", 60) 158 | 159 | enemies = [] 160 | wave_length = 5 161 | enemy_vel = 1 162 | 163 | player_vel = 5 164 | laser_vel = 5 165 | 166 | player = Player(300, 630) 167 | 168 | clock = pygame.time.Clock() 169 | 170 | lost = False 171 | lost_count = 0 172 | 173 | def redraw_window(): 174 | WIN.blit(BG, (0,0)) 175 | # draw text 176 | lives_label = main_font.render(f"Lives: {lives}", 1, (255,255,255)) 177 | level_label = main_font.render(f"Level: {level}", 1, (255,255,255)) 178 | 179 | WIN.blit(lives_label, (10, 10)) 180 | WIN.blit(level_label, (WIDTH - level_label.get_width() - 10, 10)) 181 | 182 | for enemy in enemies: 183 | enemy.draw(WIN) 184 | 185 | player.draw(WIN) 186 | 187 | if lost: 188 | lost_label = lost_font.render("You Lost!!", 1, (255,255,255)) 189 | WIN.blit(lost_label, (WIDTH/2 - lost_label.get_width()/2, 350)) 190 | 191 | pygame.display.update() 192 | 193 | while run: 194 | clock.tick(FPS) 195 | redraw_window() 196 | 197 | if lives <= 0 or player.health <= 0: 198 | lost = True 199 | lost_count += 1 200 | 201 | if lost: 202 | if lost_count > FPS * 3: 203 | run = False 204 | else: 205 | continue 206 | 207 | if len(enemies) == 0: 208 | level += 1 209 | wave_length += 5 210 | for i in range(wave_length): 211 | enemy = Enemy(random.randrange(50, WIDTH-100), random.randrange(-1500, -100), random.choice(["red", "blue", "green"])) 212 | enemies.append(enemy) 213 | 214 | for event in pygame.event.get(): 215 | if event.type == pygame.QUIT: 216 | quit() 217 | 218 | keys = pygame.key.get_pressed() 219 | if keys[pygame.K_a] and player.x - player_vel > 0: # left 220 | player.x -= player_vel 221 | if keys[pygame.K_d] and player.x + player_vel + player.get_width() < WIDTH: # right 222 | player.x += player_vel 223 | if keys[pygame.K_w] and player.y - player_vel > 0: # up 224 | player.y -= player_vel 225 | if keys[pygame.K_s] and player.y + player_vel + player.get_height() + 15 < HEIGHT: # down 226 | player.y += player_vel 227 | if keys[pygame.K_SPACE]: 228 | player.shoot() 229 | 230 | for enemy in enemies[:]: 231 | enemy.move(enemy_vel) 232 | enemy.move_lasers(laser_vel, player) 233 | 234 | if random.randrange(0, 2*60) == 1: 235 | enemy.shoot() 236 | 237 | if collide(enemy, player): 238 | player.health -= 10 239 | enemies.remove(enemy) 240 | elif enemy.y + enemy.get_height() > HEIGHT: 241 | lives -= 1 242 | enemies.remove(enemy) 243 | 244 | player.move_lasers(-laser_vel, enemies) 245 | 246 | def main_menu(): 247 | title_font = pygame.font.SysFont("comicsans", 70) 248 | run = True 249 | while run: 250 | WIN.blit(BG, (0,0)) 251 | title_label = title_font.render("Press the mouse to begin...", 1, (255,255,255)) 252 | WIN.blit(title_label, (WIDTH/2 - title_label.get_width()/2, 350)) 253 | pygame.display.update() 254 | for event in pygame.event.get(): 255 | if event.type == pygame.QUIT: 256 | run = False 257 | if event.type == pygame.MOUSEBUTTONDOWN: 258 | main() 259 | pygame.quit() 260 | 261 | 262 | main_menu() 263 | -------------------------------------------------------------------------------- /space_shooter.py: -------------------------------------------------------------------------------- 1 | import pygame 2 | import os 3 | import time 4 | import random 5 | pygame.font.init() 6 | 7 | WIDTH, HEIGHT = 750, 750 8 | WIN = pygame.display.set_mode((WIDTH, HEIGHT)) 9 | pygame.display.set_caption("Space Shooter Tutorial") 10 | 11 | # Load images 12 | RED_SPACE_SHIP = pygame.image.load(os.path.join("assets", "pixel_ship_red_small.png")) 13 | GREEN_SPACE_SHIP = pygame.image.load(os.path.join("assets", "pixel_ship_green_small.png")) 14 | BLUE_SPACE_SHIP = pygame.image.load(os.path.join("assets", "pixel_ship_blue_small.png")) 15 | 16 | # Player player 17 | YELLOW_SPACE_SHIP = pygame.image.load(os.path.join("assets", "pixel_ship_yellow.png")) 18 | 19 | # Lasers 20 | RED_LASER = pygame.image.load(os.path.join("assets", "pixel_laser_red.png")) 21 | GREEN_LASER = pygame.image.load(os.path.join("assets", "pixel_laser_green.png")) 22 | BLUE_LASER = pygame.image.load(os.path.join("assets", "pixel_laser_blue.png")) 23 | YELLOW_LASER = pygame.image.load(os.path.join("assets", "pixel_laser_yellow.png")) 24 | 25 | # Background 26 | BG = pygame.transform.scale(pygame.image.load(os.path.join("assets", "background-black.png")), (WIDTH, HEIGHT)) 27 | 28 | class Laser: 29 | def __init__(self, x, y, img): 30 | self.x = x 31 | self.y = y 32 | self.img = img 33 | self.mask = pygame.mask.from_surface(self.img) 34 | 35 | def draw(self, window): 36 | window.blit(self.img, (self.x, self.y)) 37 | 38 | def move(self, vel): 39 | self.y += vel 40 | 41 | def off_screen(self, height): 42 | return not(self.y <= height and self.y >= 0) 43 | 44 | def collision(self, obj): 45 | return collide(self, obj) 46 | 47 | 48 | class Ship: 49 | COOLDOWN = 30 50 | 51 | def __init__(self, x, y, health=100): 52 | self.x = x 53 | self.y = y 54 | self.health = health 55 | self.ship_img = None 56 | self.laser_img = None 57 | self.lasers = [] 58 | self.cool_down_counter = 0 59 | 60 | def draw(self, window): 61 | window.blit(self.ship_img, (self.x, self.y)) 62 | for laser in self.lasers: 63 | laser.draw(window) 64 | 65 | def move_lasers(self, vel, obj): 66 | self.cooldown() 67 | for laser in self.lasers: 68 | laser.move(vel) 69 | if laser.off_screen(HEIGHT): 70 | self.lasers.remove(laser) 71 | elif laser.collision(obj): 72 | obj.health -= 10 73 | self.lasers.remove(laser) 74 | 75 | def cooldown(self): 76 | if self.cool_down_counter >= self.COOLDOWN: 77 | self.cool_down_counter = 0 78 | elif self.cool_down_counter > 0: 79 | self.cool_down_counter += 1 80 | 81 | def shoot(self): 82 | if self.cool_down_counter == 0: 83 | laser = Laser(self.x, self.y, self.laser_img) 84 | self.lasers.append(laser) 85 | self.cool_down_counter = 1 86 | 87 | def get_width(self): 88 | return self.ship_img.get_width() 89 | 90 | def get_height(self): 91 | return self.ship_img.get_height() 92 | 93 | 94 | class Player(Ship): 95 | def __init__(self, x, y, health=100): 96 | super().__init__(x, y, health) 97 | self.ship_img = YELLOW_SPACE_SHIP 98 | self.laser_img = YELLOW_LASER 99 | self.mask = pygame.mask.from_surface(self.ship_img) 100 | self.max_health = health 101 | 102 | def move_lasers(self, vel, objs): 103 | self.cooldown() 104 | for laser in self.lasers: 105 | laser.move(vel) 106 | if laser.off_screen(HEIGHT): 107 | self.lasers.remove(laser) 108 | else: 109 | for obj in objs: 110 | if laser.collision(obj): 111 | objs.remove(obj) 112 | if laser in self.lasers: 113 | self.lasers.remove(laser) 114 | 115 | def draw(self, window): 116 | super().draw(window) 117 | self.healthbar(window) 118 | 119 | def healthbar(self, window): 120 | pygame.draw.rect(window, (255,0,0), (self.x, self.y + self.ship_img.get_height() + 10, self.ship_img.get_width(), 10)) 121 | pygame.draw.rect(window, (0,255,0), (self.x, self.y + self.ship_img.get_height() + 10, self.ship_img.get_width() * (self.health/self.max_health), 10)) 122 | 123 | 124 | class Enemy(Ship): 125 | COLOR_MAP = { 126 | "red": (RED_SPACE_SHIP, RED_LASER), 127 | "green": (GREEN_SPACE_SHIP, GREEN_LASER), 128 | "blue": (BLUE_SPACE_SHIP, BLUE_LASER) 129 | } 130 | 131 | def __init__(self, x, y, color, health=100): 132 | super().__init__(x, y, health) 133 | self.ship_img, self.laser_img = self.COLOR_MAP[color] 134 | self.mask = pygame.mask.from_surface(self.ship_img) 135 | 136 | def move(self, vel): 137 | self.y += vel 138 | 139 | def shoot(self): 140 | if self.cool_down_counter == 0: 141 | laser = Laser(self.x-20, self.y, self.laser_img) 142 | self.lasers.append(laser) 143 | self.cool_down_counter = 1 144 | 145 | 146 | def collide(obj1, obj2): 147 | offset_x = obj2.x - obj1.x 148 | offset_y = obj2.y - obj1.y 149 | return obj1.mask.overlap(obj2.mask, (offset_x, offset_y)) != None 150 | 151 | def main(): 152 | run = True 153 | FPS = 60 154 | level = 0 155 | lives = 5 156 | main_font = pygame.font.SysFont("comicsans", 50) 157 | lost_font = pygame.font.SysFont("comicsans", 60) 158 | 159 | enemies = [] 160 | wave_length = 5 161 | enemy_vel = 1 162 | 163 | player_vel = 5 164 | laser_vel = 5 165 | 166 | player = Player(300, 630) 167 | 168 | clock = pygame.time.Clock() 169 | 170 | lost = False 171 | lost_count = 0 172 | 173 | def redraw_window(): 174 | WIN.blit(BG, (0,0)) 175 | # draw text 176 | lives_label = main_font.render(f"Lives: {lives}", 1, (255,255,255)) 177 | level_label = main_font.render(f"Level: {level}", 1, (255,255,255)) 178 | 179 | WIN.blit(lives_label, (10, 10)) 180 | WIN.blit(level_label, (WIDTH - level_label.get_width() - 10, 10)) 181 | 182 | for enemy in enemies: 183 | enemy.draw(WIN) 184 | 185 | player.draw(WIN) 186 | 187 | if lost: 188 | lost_label = lost_font.render("You Lost!!", 1, (255,255,255)) 189 | WIN.blit(lost_label, (WIDTH/2 - lost_label.get_width()/2, 350)) 190 | 191 | pygame.display.update() 192 | 193 | while run: 194 | clock.tick(FPS) 195 | redraw_window() 196 | 197 | if lives <= 0 or player.health <= 0: 198 | lost = True 199 | lost_count += 1 200 | 201 | if lost: 202 | if lost_count > FPS * 3: 203 | run = False 204 | else: 205 | continue 206 | 207 | if len(enemies) == 0: 208 | level += 1 209 | wave_length += 5 210 | for i in range(wave_length): 211 | enemy = Enemy(random.randrange(50, WIDTH-100), random.randrange(-1500, -100), random.choice(["red", "blue", "green"])) 212 | enemies.append(enemy) 213 | 214 | for event in pygame.event.get(): 215 | if event.type == pygame.QUIT: 216 | quit() 217 | 218 | keys = pygame.key.get_pressed() 219 | if keys[pygame.K_a] and player.x - player_vel > 0: # left 220 | player.x -= player_vel 221 | if keys[pygame.K_d] and player.x + player_vel + player.get_width() < WIDTH: # right 222 | player.x += player_vel 223 | if keys[pygame.K_w] and player.y - player_vel > 0: # up 224 | player.y -= player_vel 225 | if keys[pygame.K_s] and player.y + player_vel + player.get_height() + 15 < HEIGHT: # down 226 | player.y += player_vel 227 | if keys[pygame.K_SPACE]: 228 | player.shoot() 229 | 230 | for enemy in enemies[:]: 231 | enemy.move(enemy_vel) 232 | enemy.move_lasers(laser_vel, player) 233 | 234 | if random.randrange(0, 2*60) == 1: 235 | enemy.shoot() 236 | 237 | if collide(enemy, player): 238 | player.health -= 10 239 | enemies.remove(enemy) 240 | elif enemy.y + enemy.get_height() > HEIGHT: 241 | lives -= 1 242 | enemies.remove(enemy) 243 | 244 | player.move_lasers(-laser_vel, enemies) 245 | 246 | def main_menu(): 247 | title_font = pygame.font.SysFont("comicsans", 70) 248 | run = True 249 | while run: 250 | WIN.blit(BG, (0,0)) 251 | title_label = title_font.render("Press the mouse to begin...", 1, (255,255,255)) 252 | WIN.blit(title_label, (WIDTH/2 - title_label.get_width()/2, 350)) 253 | pygame.display.update() 254 | for event in pygame.event.get(): 255 | if event.type == pygame.QUIT: 256 | run = False 257 | if event.type == pygame.MOUSEBUTTONDOWN: 258 | main() 259 | pygame.quit() 260 | 261 | 262 | main_menu() -------------------------------------------------------------------------------- /sum_of_elements_of_an_array.py: -------------------------------------------------------------------------------- 1 | list1 = [] 2 | i = 0 3 | a = 0 4 | #ask user to enter a numbers like 12 35 56 13 5 | user_Input=input("enter numbers") 6 | #useing map function to short the code and remove the loop 7 | list1= list(map(int, user_Input.split())) 8 | 9 | print("array is:", list1) 10 | #using inbuilt function of list to add the elemnts 11 | a=sum(list1) 12 | print("Sum of all the elements of the array is:",a) 13 | -------------------------------------------------------------------------------- /swap_elements_in_array.py: -------------------------------------------------------------------------------- 1 | #ask user to enter a numbers like 12 35 56 13 2 | user_Input=input("enter numbers") 3 | #useing map function to short the code and remove the loop 4 | list1= list(map(int, user_Input.split())) 5 | #swap elements of list 6 | print(list1) 7 | print("select two positions to be swapped") 8 | n = int(input("first position: ")) 9 | m = int(input("Second position: ")) 10 | 11 | if n <= len(list1) and m <= len(list1): 12 | list1[n-1],list1[m-1] = list1[m-1], list1[n-1] 13 | print(list1) 14 | else: 15 | print("INVALID POSITIONS") 16 | -------------------------------------------------------------------------------- /tempCodeRunnerFile.py: -------------------------------------------------------------------------------- 1 | rr,lb,ub): 2 | if (lb < ub): 3 | loc = partition(arr,lb,ub) 4 | Quicksort(arr,lb,loc-1) 5 | Quicksort(arr,loc+1,ub) -------------------------------------------------------------------------------- /towerOfHoni.py: -------------------------------------------------------------------------------- 1 | # Recursive Code 2 | 3 | def TowerOfHanoi(n , source, destination, auxiliary): 4 | if n==1: 5 | print ("Move disk 1 from source",source,"to destination",destination) 6 | return 7 | TowerOfHanoi(n-1, source, auxiliary, destination) 8 | print ("Move disk",n,"from source",source,"to destination",destination) 9 | TowerOfHanoi(n-1, auxiliary, destination, source) 10 | 11 | #Test Input 12 | n = 4 13 | TowerOfHanoi(n,'A','B','C') 14 | # Consider A B and C as the names of rods 15 | 16 | --------------------------------------------------------------------------------