├── .gitignore ├── ATM.py ├── Calculating Gpa.py ├── Calculator.pyw ├── Check Prime Number.py ├── Course Selection.py ├── Currency Converter.py ├── Duration Adder.py ├── Encyription.py ├── Family Game.py ├── Guess Game Reverse.py ├── Guess Game.py ├── Hadi Game.py ├── Hangman Game.py ├── Luhn Algorithm.py ├── Magic 8 Ball.py ├── Match.py ├── Math Questions Contest.py ├── Password Generator.py ├── README.md ├── Remember the Number.py ├── Rock Paper Scissors.py ├── Tic Tac Toe.py ├── YoutubeVideoDownloader.pyw └── try.py /.gitignore: -------------------------------------------------------------------------------- 1 | try.py -------------------------------------------------------------------------------- /ATM.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | users = {"Ahmed":"1234","Zeynep":"4321","Alberto":"4422"} 3 | admins = {"Ibrahim":"1122"} 4 | usact = {"Ahmed":{"balance":2000,"deposits":[],"withdrawal":[],"transfer":[]},"Zeynep":{"balance":3500,"deposits":[],"withdrawal":[],"transfer":[]},"Alberto":{"balance":1750,"deposits":[],"withdrawal":[],"transfer":[]}} 5 | def main(): 6 | print(" --- Welcome to Sehir Bank ---\n" 7 | " -------------------\n" 8 | " / Istanbul \ \n" 9 | " |"+ str(datetime.datetime.now()).split(".")[0] + "|\n" 10 | " \ /\n" 11 | " -------------------\n") 12 | print("1. Login\n2. Exit") 13 | while True: 14 | ask = input("Which one do you choose?:") 15 | if ask == "1": 16 | print("What do you want to login as:\n" 17 | "1. Admin\n" 18 | "2. User\n" 19 | "3. Go Back") 20 | while True: 21 | ans = input("Which one do you choose?:") 22 | if ans == "1": 23 | while True: 24 | admus = input("Admin Name:") 25 | admpass = input("Admin Password:") 26 | if admus not in admins: 27 | print("Invalid user name. Please enter again.") 28 | elif admpass != admins[admus]: 29 | print("Wrong Password. Please enter again") 30 | else: 31 | print("Welcome Ibrahim") 32 | admin(users,usact) 33 | elif ans == "2": 34 | login(users) 35 | elif ans == "3": 36 | main() 37 | else: 38 | print("Invalid entry. Please enter again") 39 | elif ask == "2": 40 | exit() 41 | else: 42 | print("Invalid entry. Please enter again") 43 | def login(users): 44 | while True: 45 | usname = input("Please enter your username:") 46 | passwrd = input("Please enter your password") 47 | if usname not in users: 48 | print("Invalid username. Please enter again") 49 | elif passwrd != users[usname]: 50 | print("Invalid password. Please enter again") 51 | else: 52 | print(usname + " Welcome to Sehir Bank." ) 53 | break 54 | menu(users,usact,usname,passwrd) 55 | def menu(users,usact,usname,passwrd): 56 | print("Please enter the number of the service\n" 57 | "1. Withdraw Money\n" 58 | "2. Deposit Money\n" 59 | "3. Transfer Money\n" 60 | "4. My Account Information\n" 61 | "5. Logout") 62 | while True: 63 | ask = input("Please choose a service") 64 | if ask == "1": 65 | while True: 66 | wtd = input("Please enter the amount you want to withdraw:") 67 | if int(wtd) <= usact[usname]["balance"]: 68 | usact[usname]["balance"] -= int(wtd) 69 | usact[usname]["withdrawal"].append((wtd,str(datetime.datetime.now()).split(".")[0])) 70 | print(wtd + "TL withdrawn from your account\n" 71 | "Going back to main menu...") 72 | menu(users,usact,usname,passwrd) 73 | else: 74 | print("You dont have that much money.") 75 | menu(users,usact,usname,passwrd) 76 | elif ask == "2": 77 | while True: 78 | dep = input("Please enter the amount you want to deposit:") 79 | usact[usname]["balance"] += int(dep) 80 | usact[usname]["deposits"].append((dep,str(datetime.datetime.now()).split(".")[0])) 81 | print(dep + "TL added to your account\n" 82 | "Going back to main menu...") 83 | menu(users,usact,usname,passwrd) 84 | elif ask == "3": 85 | transfer(users,usact,usname,passwrd) 86 | elif ask == "4": 87 | print("--------- Sehir Bank ----------\n" 88 | "----- "+str(datetime.datetime.now()).split(".")[0]+" -----\n" 89 | "-------------------------------") 90 | print("Your Name: "+usname) 91 | print("your Password: "+passwrd) 92 | print("Your Balance Amount (TL): "+str(usact[usname]["balance"])) 93 | print("-------------------------------\n" 94 | "User Activities Report:\n\n\n" 95 | "Your Withdrawals:\n") 96 | for i in usact[usname]["withdrawal"]: 97 | print(" "+i[1] +" "+i[0]) 98 | print("\n\nYour Deposits:\n") 99 | for i in usact[usname]["deposits"]: 100 | print(" "+i[1]+" "+i[0]) 101 | print("\n\nYour Transfers:\n") 102 | for i in usact[usname]["transfer"]: 103 | print(" "+i[2]+" Transferred to "+i[1]+" "+i[0]) 104 | print("\n\n-------------------------------\n" 105 | "Going back to main menu...") 106 | menu(users,usact,usname,passwrd) 107 | elif ask == "5": 108 | print("You are loggin out. Thank you for choosing Sehir Bank. Whish to see you again") 109 | main() 110 | else: 111 | print("Invalid service. Please enter again") 112 | def transfer(users,usact,usname,passwrd): 113 | print("Warning: If you want to abort the transfer please enter abort") 114 | while True: 115 | trans = input("Please enter the name of the user you want transfer money to:") 116 | if trans == "abort": 117 | print("Going back to main menu...") 118 | menu(users, usact, usname,passwrd) 119 | elif trans == usname: 120 | print("Transfering to user with the name " + trans + " is not possible!\n" 121 | "User does not exist!") 122 | elif trans not in users: 123 | print("Transfering to user with the name " + trans + " is not possible!\n" 124 | "User does not exist!") 125 | else: 126 | amount = input("Please enter the amount you want to transfer:") 127 | if int(amount) <= usact[usname]["balance"]: 128 | usact[usname]["balance"] -= int(amount) 129 | usact[usname]["transfer"].append((amount,trans,str(datetime.datetime.now()).split(".")[0])) 130 | print("Money transferred succesfully\n" 131 | "Going back to the menu...") 132 | menu(users, usact, usname,passwrd) 133 | else: 134 | print("Sorry you dont have the entered amount \n\n" 135 | "1. Go back to manin menu\n" 136 | "2. Transfer again") 137 | while True: 138 | sub = input("Which one do you choose?:") 139 | if sub == "1": 140 | menu(users,usact,usname,passwrd) 141 | elif sub == "2": 142 | transfer(users,usact,usname) 143 | else: 144 | print("Invalid entry. Please enter again") 145 | def admin(users,usact): 146 | print("--- Admin Menu ---\n" 147 | "Please enter a number of the setting operations supported:\n" 148 | "1. Add User\n" 149 | "2. Remove User\n" 150 | "3. Display all Users\n" 151 | "4. Exit Admin Menu") 152 | while True: 153 | select = input("Which operation do you choose?:") 154 | if select == "1": 155 | print("Access Granted") 156 | nwus = input("Enter the new user name:") 157 | nwps = input("Enter the new user password") 158 | users[nwus] = nwps 159 | usact[nwus] = {"balance":5000,"deposits":[],"withdrawal":[],"transfer":[]} 160 | print(nwus+" was added as an user") 161 | admin(users,usact) 162 | elif select == "2": 163 | print("Access Granted") 164 | remove = input("Enter the username:") 165 | if remove not in users: 166 | print(remove+" does not exist as an user to Sehir Bank.") 167 | admin(users,usact) 168 | else: 169 | users.pop(remove) 170 | usact.pop(remove) 171 | print(remove+" was removed as an user to Sehir Bank") 172 | admin(users,usact) 173 | elif select == "3": 174 | c = 1 175 | for i in users: 176 | print(str(c)+". "+i+" "+users[i]) 177 | c += 1 178 | print("-----------------") 179 | admin(users,usact) 180 | elif select == "4": 181 | main() 182 | else: 183 | print("Invalid entry. Please enter again.") 184 | main() -------------------------------------------------------------------------------- /Calculating Gpa.py: -------------------------------------------------------------------------------- 1 | yes_no = ["yes","no","y","n"] 2 | numbers = list() 3 | info = dict() 4 | for i in range(12): 5 | numbers.append(str(i)) 6 | print ("Hmmm i think you are in trouble if you are using this but i think i can help you. Lets calculate your GPA.") 7 | letter_grade = {"A+":4.1,"A":4.0,"A-":3.7,"B+":3.3,"B":3.0,"B-":2.7,"C+":2.3,"C":2.0,"C-":1.7,"D+":1.3,"D":1.0,"D-":0.5,"F":0.0,"IA":0.0} 8 | def General(): 9 | total = 0 10 | totalCredit = 0 11 | while True: 12 | lesson_number = input("how many lessons have you enrolled?:") 13 | if lesson_number not in numbers: 14 | print("please enter an integer.") 15 | else: 16 | break 17 | for i in range(int(lesson_number)): 18 | name = input("what is your {}lesson's name?:".format(str(i+1)+".")) 19 | while True: 20 | credit = input("what is the credit for {}?:".format(name)) 21 | if credit not in numbers: 22 | print("Please enter an integer.") 23 | else: 24 | break 25 | while True: 26 | grade = input("What is the grade that you got?:").upper() 27 | if grade not in letter_grade: 28 | print("Please enter a valid letter grade.") 29 | else: 30 | break 31 | info[name] = [int(credit),grade] 32 | print(info) 33 | for i in info: 34 | total += (info[i][0]*letter_grade[info[i][1]]) 35 | totalCredit += info[i][0] 36 | gpa = total / totalCredit 37 | gpa = float("{:.2f}".format(gpa)) 38 | print(gpa) 39 | while True: 40 | ask = input("Do you want to keep chancing your grade (y or n)?:").lower() 41 | if ask not in yes_no: 42 | print("Please answer the question either yes or no.") 43 | else: 44 | Modified(info) 45 | 46 | def Modified(info): 47 | total = 0 48 | tc = 0 49 | for i in info: 50 | while True: 51 | grade = input("What is the grade that you got from {}?:".format(i)).upper() 52 | if grade not in letter_grade: 53 | print("Please enter a valid letter grade") 54 | else: 55 | info[i][1] = grade 56 | break 57 | print(info) 58 | for i in info: 59 | total += (info[i][0]*letter_grade[info[i][1]]) 60 | tc += info[i][0] 61 | gpa = total/tc 62 | gpa = float("{:.2f}".format(gpa)) 63 | print(gpa) 64 | while True: 65 | ask = input("Do you want to keep chancing your grade (y or n)?:").lower() 66 | if ask not in yes_no: 67 | print("Please answer the question either yes or no.") 68 | elif ask == "n": 69 | exit() 70 | else: 71 | Modified(info) 72 | 73 | General() -------------------------------------------------------------------------------- /Calculator.pyw: -------------------------------------------------------------------------------- 1 | from tkinter import * 2 | 3 | class GUI: 4 | 5 | def __init__(self,parent): 6 | self.parent = parent 7 | self.initUI() 8 | self.process = "" 9 | self.operations = ["+","-","×","/"] 10 | 11 | def initUI(self): 12 | self.display = Label(height = 3, width = 42, bg = "white", anchor = CENTER) 13 | self.display.place(x = 5, y = 7) 14 | self.ce_button = Button(text = "CE", width = 7,command = self.clear) 15 | self.ce_button.place(x = 5, y = 70) 16 | self.c_button = Button(text = "C", width = 7, command = self.clear) 17 | self.c_button.place(x = 85, y = 70) 18 | self.delete_button = Button(text = "⇽", width = 7, command = self.delete) 19 | self.delete_button.place(x = 165, y = 70) 20 | self.divide_button = Button(text = "÷", width = 7, command = self.divide) 21 | self.divide_button.place(x = 245, y = 70) 22 | self.seven_button = Button(text = "7", width = 7, command = self.seven) 23 | self.seven_button.place(x = 5, y = 110) 24 | self.eight_button = Button(text = "8", width = 7, command = self.eight) 25 | self.eight_button.place(x = 85, y = 110) 26 | self.nine_button = Button(text = "9", width = 7, command = self.nine) 27 | self.nine_button.place(x = 165, y = 110) 28 | self.multiply_button = Button(text = "×", width = 7, command = self.multiply) 29 | self.multiply_button.place(x = 245, y = 110) 30 | self.four_button = Button(text = "4", width = 7, command = self.four) 31 | self.four_button.place(x = 5, y = 150) 32 | self.five_button = Button(text = "5", width = 7, command = self.five) 33 | self.five_button.place(x = 85, y = 150) 34 | self.six_button = Button(text = "6", width = 7, command = self.six) 35 | self.six_button.place(x = 165, y = 150) 36 | self.minus_button = Button(text = "–", width = 7, command = self.minus) 37 | self.minus_button.place(x = 245, y = 150) 38 | self.one_button = Button(text = "1", width = 7, command = self.one) 39 | self.one_button.place(x = 5, y = 190) 40 | self.two_button = Button(text = "2", width = 7, command = self.two) 41 | self.two_button.place(x = 85, y = 190) 42 | self.three_button = Button(text = "3", width = 7, command = self.three) 43 | self.three_button.place(x = 165, y = 190) 44 | self.plus_button = Button(text = "+", width = 7, command = self.plus) 45 | self.plus_button.place(x = 245, y =190) 46 | self.change_button = Button(text = "±", width = 7, command = self.change) 47 | self.change_button.place(x = 5, y = 230) 48 | self.zero_button = Button(text = "0", width = 7, command = self.zero) 49 | self.zero_button.place(x = 85, y = 230) 50 | self.coma_button = Button(text = ".", width = 7, command = self.coma) 51 | self.coma_button.place(x = 165, y = 230) 52 | self.equal_button = Button(text = "=", width = 7, command = self.equal) 53 | self.equal_button.place(x = 245, y = 230) 54 | 55 | def zero(self): 56 | self.process += "0" 57 | self.display.config(text = self.process) 58 | 59 | def one(self): 60 | self.process += "1" 61 | self.display.config(text = self.process) 62 | 63 | def two(self): 64 | self.process += "2" 65 | self.display.config(text = self.process) 66 | 67 | def three(self): 68 | self.process += "3" 69 | self.display.config(text = self.process) 70 | 71 | def four(self): 72 | self.process += "4" 73 | self.display.config(text = self.process) 74 | 75 | def five(self): 76 | self.process += "5" 77 | self.display.config(text = self.process) 78 | 79 | def six(self): 80 | self.process += "6" 81 | self.display.config(text = self.process) 82 | 83 | def seven(self): 84 | self.process += "7" 85 | self.display.config(text = self.process) 86 | 87 | def eight(self): 88 | self.process += "8" 89 | self.display.config(text = self.process) 90 | 91 | def nine(self): 92 | self.process += "9" 93 | self.display.config(text = self.process) 94 | 95 | def plus(self): 96 | self.process += "+" 97 | self.display.config(text = self.process) 98 | 99 | def minus(self): 100 | self.process += "-" 101 | self.display.config(text = self.process) 102 | 103 | def clear(self): 104 | self.process = "" 105 | self.display.config(text = 0) 106 | 107 | def ce(self): 108 | pass 109 | 110 | def divide(self): 111 | self.process += "/" 112 | self.display.config(text = self.process) 113 | 114 | def multiply(self): 115 | self.process += "×" 116 | self.display.config(text = self.process) 117 | 118 | def coma(self): 119 | self.process += "." 120 | self.display.config(text = self.process) 121 | 122 | def delete(self): 123 | self.pro = list(self.process) 124 | self.pro.pop(-1) 125 | self.process = "".join(self.pro) 126 | self.display.config(text = self.process) 127 | 128 | def change(self): 129 | try: 130 | self.changed = int(self.process) * (-1) 131 | self.process = str(self.changed) 132 | self.display.config(text=self.process) 133 | 134 | except ValueError as hata: 135 | self.display.config(text = "Syntax Error") 136 | self.process = "" 137 | else: 138 | pass 139 | 140 | def equal(self): 141 | self.pro = list(self.process) 142 | for i in range(len(self.pro)): 143 | if self.pro[i] == "×": 144 | self.pro[i] = "*" 145 | self.process = "".join(self.pro) 146 | self.process = str(eval((self.process))) 147 | if "." in self.process: 148 | self.pro = self.process.split(".") 149 | if self.pro[1] == "0": 150 | self.process = self.pro[0] 151 | self.display.config(text = self.process) 152 | 153 | def main(): 154 | root = Tk() 155 | root.title("Calculator") 156 | root.geometry("310x290") 157 | app = GUI(root) 158 | root.mainloop() 159 | 160 | main() 161 | -------------------------------------------------------------------------------- /Check Prime Number.py: -------------------------------------------------------------------------------- 1 | numbers = list() 2 | for i in range(1000000): 3 | numbers.append(str(i)) 4 | def is_prime(): 5 | dividers = list() 6 | while True: 7 | number = input("Which number would you like to check?:") 8 | if int(number)<2: 9 | print("The numbers that are smaller than 2 can not be considered. ") 10 | elif number not in numbers: 11 | print("Yavru, eighter your number is too big or not a number. Please enter a valid number") 12 | else: 13 | break 14 | for i in range(2,int(number)): 15 | if int(number) % i == 0: 16 | dividers.append(i) 17 | else: 18 | pass 19 | if len(dividers) != 0: 20 | print("{} is not a prime number. It can be divided by {}".format(number,dividers)) 21 | else: 22 | print("{} is a prime number.".format(number)) 23 | yesno() 24 | def yesno(): 25 | while True: 26 | answer = input("Would you like to try another number?:").lower() 27 | if answer == "yes" or answer == "y": 28 | is_prime() 29 | elif answer == "no" or answer == "n": 30 | print("It was a pleasure to serve you. Have a nice day.") 31 | exit() 32 | else: 33 | print("Your answer should be yer or no. Please enter a valid answer") 34 | is_prime() -------------------------------------------------------------------------------- /Course Selection.py: -------------------------------------------------------------------------------- 1 | users = {"admin":["sehir123"], "Ahmet": ["123", 900, {"mathematics": 3, "physics": 4}], "Ayse": ["456", 400, {"physics": 4, "programming": 3}]} 2 | 3 | courses = {"physics": 4, "mathematics": 3, "programming": 3} 4 | 5 | 6 | def login(): 7 | print("****Welcome to Course Management System****\nPlease provide login information\n") 8 | 9 | while True: 10 | global userId 11 | userId = input("Username: ") 12 | userPassword = input("Password: ") 13 | 14 | if userId not in users: print("Invalid id. Please try again\n") 15 | elif userPassword != users[userId][0]: print("Your password doesnt match with your id. Please try again\n") 16 | else: break 17 | 18 | if userId == "admin": adminMenu() 19 | else: studentMenu() 20 | 21 | 22 | def adminMenu(): 23 | print("\nWelcome Admin! What do you want to do?\n" 24 | "1-List courses\n" 25 | "2-Create a course\n" 26 | "3-Delete a course\n" 27 | "4-Show students registered to a course\n" 28 | "5-Users Budget Menu\n" 29 | "6-List Users\n" 30 | "7-Create User\n" 31 | "8-Delete User\n" 32 | "9-Exit\n") 33 | 34 | choices = ["1","2","3","4","5","6","7","8","9"] 35 | 36 | while True: 37 | adminChoice = input("Your choice: ") 38 | if adminChoice not in choices: print("Invalid option number. Please enter a valid number.\n") 39 | else: break 40 | 41 | if adminChoice == "1": 42 | print("*** Offered Courses ***\nCourse Name Credit") 43 | for i, j in enumerate(courses, start=1): 44 | print(str(i)+"-"+j+(25-len(j))*" "+str(courses[j])) 45 | adminMenu() 46 | 47 | elif adminChoice == "2": 48 | newCourseName = input("What is the name of the course that you want to add?: ") 49 | newCredit = input("How many credits this course has?: ") 50 | print(newCourseName+" will be added "+newCredit+" credits.\n") 51 | 52 | while True: 53 | anser = input("Are you sure?: ").upper() 54 | if anser == "Y": 55 | print(newCourseName+" has been added to courses with "+newCredit+" credits.\n") 56 | courses[newCourseName] = newCredit 57 | break 58 | elif anser == "N": 59 | print("Ok. Nothing happened.\n") 60 | break 61 | else: print("Your answer only can be Y or N.\n") 62 | adminMenu() 63 | 64 | elif adminChoice == "3": 65 | print("Course Name Credit") 66 | for i, j in enumerate(courses, start=1): 67 | print(str(i)+"-"+j+(25-len(j))*" "+str(courses[j])) 68 | 69 | while True: 70 | delCourseName = int(input("Which course do you want to delete?: ")) 71 | if delCourseName <= 0 and delCourseName > len(courses): print("Invalid course number. Please enter again\n") 72 | else: break 73 | 74 | deletedCourseName = list(courses.keys())[delCourseName-1] 75 | courses.pop(deletedCourseName) 76 | for i in users: 77 | if i == "admin": continue 78 | elif deletedCourseName in users[i][2]: 79 | users[i][1] += users[i][2][deletedCourseName] * 100 80 | users[i][2].pop(deletedCourseName) 81 | 82 | print(deletedCourseName+" has been deleted and money has been transfered back to students accounts\n") 83 | 84 | elif adminChoice == "4": 85 | showeCourseName = input("Which course do you want to show?: ") 86 | courseTakers = list() 87 | 88 | if showeCourseName not in courses: 89 | print("This course doesn't exist, please provide a valid input\n") 90 | else: 91 | print("Course Name: "+showeCourseName+"\nStudents taking mathematics:") 92 | for i in users: 93 | if i == "admin": continue 94 | elif showeCourseName in users[i][2]: courseTakers.append(i) 95 | 96 | if len(courseTakers) != 0: 97 | for i, j in enumerate(courseTakers, start=1): 98 | print(str(i)+"-"+j) 99 | else: 100 | print("No one is taking this course") 101 | adminMenu() 102 | 103 | elif adminChoice == "5": 104 | print("User Money") 105 | for i,j in enumerate(users): 106 | if j == "admin": continue 107 | print(str(i)+"-"+j+(13-len(j))*" "+str(users[j][1])) 108 | print("What do you want to do?\n" 109 | "1-Add money to user\n" 110 | "2-Subtract money from user\n" 111 | "3-Back to admin menu\n") 112 | 113 | while True: 114 | choose = int(input("Your choice: ")) 115 | if choose != 1 and choose != 2 and choose !=3: print("Invalid option. Please enter again") 116 | else: break 117 | 118 | if choose == 1: 119 | print("Which user do you want add money to their account?") 120 | for i, j in enumerate(users): 121 | if j == "admin": continue 122 | print(str(i)+"-"+j) 123 | 124 | while True: 125 | addMoneyName = int(input("Your choice?: ")) 126 | if addMoneyName<1 and addMoneyName>len(users): print("Invalid option. please enter again") 127 | else: break 128 | 129 | addMoneyName = list(users)[addMoneyName] 130 | 131 | much = int(input("How much money do you want to add?: ")) 132 | print(str(much)+" will be added to "+addMoneyName) 133 | 134 | while True: 135 | sure = input("Are you sure?: ").upper() 136 | if sure == "Y": 137 | users[addMoneyName][1] += much 138 | print(str(much) + " added to " + addMoneyName) 139 | break 140 | elif sure == "N": 141 | print("Ok. Nothing happened") 142 | break 143 | else: print("Invalid option. Please enter again.") 144 | 145 | adminMenu() 146 | 147 | elif choose == 2: 148 | print("Which user do you want subtract money from their account?") 149 | for i, j in enumerate(users): 150 | if j == "admin": continue 151 | print(str(i) + "-" + j) 152 | 153 | while True: 154 | addMoneyName = int(input("Your choice?: ")) 155 | if addMoneyName < 1 and addMoneyName > len(users): 156 | print("Invalid option. please enter again") 157 | else: 158 | break 159 | 160 | addMoneyName = list(users)[addMoneyName] 161 | 162 | much = int(input("How much money do you want to subtract?: ")) 163 | print(str(much) + " will be subtracted from " + addMoneyName) 164 | 165 | while True: 166 | sure = input("Are you sure?: ").upper() 167 | if sure == "Y": 168 | users[addMoneyName][1] -= much 169 | print(str(much) + " subtracted from " + addMoneyName) 170 | break 171 | elif sure == "N": 172 | print("Ok. Nothing happened") 173 | break 174 | else: 175 | print("Invalid option. Please enter again.") 176 | adminMenu() 177 | 178 | elif choose == 3: 179 | adminMenu() 180 | 181 | elif adminChoice == "6": 182 | print("Current Users:") 183 | for i,j in enumerate(users): 184 | if j == "admin": continue 185 | print(str(i)+"-"+j) 186 | adminMenu() 187 | 188 | elif adminChoice == "7": 189 | newUser = input("What is the name of user that you want to create? ") 190 | newPassword = input("What is the password for account?") 191 | newBudget = int(input("How much money do you want user to have?")) 192 | users[newUser] = [newPassword, newBudget, dict()] 193 | print("The new user has been added successfully!") 194 | 195 | adminMenu() 196 | 197 | elif adminChoice == "8": 198 | print("Current Users:") 199 | for i, j in enumerate(users): 200 | if j == "admin": continue 201 | print(str(i) + "-" + j) 202 | 203 | while True: 204 | delete = input("What is the name of user that you want to delete?") 205 | 206 | if delete not in users: print("User doesn't exist. Please enter another user name.") 207 | elif delete != "admin": 208 | users.pop(delete) 209 | print("User succesfully deleted.\n") 210 | break 211 | 212 | adminMenu() 213 | 214 | elif adminChoice == "9": 215 | login() 216 | 217 | def studentMenu(): 218 | print("\nWelcome "+userId+" What do you want to do?\n" 219 | "1-Add courses to my courses\n" 220 | "2-Delete a course from my courses\n" 221 | "3-Show my courses\n" 222 | "4-Budget Menu\n" 223 | "5-Exit\n") 224 | 225 | options = ["1","2","3","4","5"] 226 | 227 | while True: 228 | choice = input("Your choice: ") 229 | if choice not in options: print("Invalid option. Please enter again.\n") 230 | else: break 231 | 232 | if choice == "1": 233 | print("*** Offered Courses ***\nCourse Name Credit") 234 | for i, j in enumerate(courses, start=1): 235 | print(str(i) + "-" + j + (25 - len(j)) * " " + str(courses[j])) 236 | 237 | while True: 238 | courseSelect = int(input("Which course do you want to take (Enter 0 to go to main menu)?")) 239 | if courseSelect == 0: studentMenu() 240 | elif courseSelect <= 0 and courseSelect > len(courses): print("Invalid course number. Please enter again\n") 241 | else: 242 | selectedCourseName = list(courses.keys())[courseSelect - 1] 243 | if selectedCourseName in users[userId][2]: print("This course is already in your profile\n") 244 | elif users[userId][1] < courses[selectedCourseName] * 100: print("You dont have enough money to enroll in this class\n") 245 | else: 246 | users[userId][2][selectedCourseName] = courses[selectedCourseName] 247 | users[userId][1] -= courses[selectedCourseName] * 100 248 | print("\n"+selectedCourseName+" has been successfully added to your courses.") 249 | break 250 | 251 | studentMenu() 252 | 253 | elif choice == "2": 254 | print("Course Name Credit") 255 | for i, j in enumerate(users[userId][2], start=1): 256 | print(str(i) + "-" + j + (25 - len(j)) * " " + str(courses[j])) 257 | 258 | while True: 259 | number = int(input("Which course do you want to remove?: ")) 260 | if number <= 0 and number > len(users[userId][2]): print("Invalid course number. Please enter again\n") 261 | else: break 262 | 263 | courseName = list(users[userId][2].keys())[number-1] 264 | refund = courses[courseName]*100 265 | print("\nYou have chosen: "+courseName+"\n"+str(refund)+"$ will be returned to your account\n") 266 | 267 | while True: 268 | anser = input("Are you sure you want to remove this course?: ").upper() 269 | if anser == "Y": 270 | users[userId][2].pop(courseName) 271 | users[userId][1] += refund 272 | print("Course has been deleted from your profile\n") 273 | break 274 | 275 | elif anser == "N": 276 | print("Ok. Nothing happened.\n") 277 | break 278 | 279 | else: 280 | print("Your answer only can be Y or N.\n") 281 | studentMenu() 282 | 283 | elif choice == "3": 284 | print("Your courses\nCourse Name Credit") 285 | for i, j in enumerate(users[userId][2], start=1): 286 | print(str(i) + "-" + j + (25 - len(j)) * " " + str(users[userId][2][j])) 287 | 288 | studentMenu() 289 | 290 | elif choice == "4": 291 | print("#### BUDGET MENU #####\nYour budget is: "+str(users[userId][1])+"$\n\n") 292 | print("What do you want to do?\n" 293 | "1-Add Money\n" 294 | "2-Go to main menu\n") 295 | 296 | while True: 297 | answer = int(input("Your choice: ")) 298 | if answer != 1 and answer != 2: print("Invalid option. Please enter again") 299 | else: break 300 | 301 | if answer == 1: 302 | amount = int(input("Amount of money: ")) 303 | users[userId][1] += amount 304 | print("Your budget has been updated.\n") 305 | 306 | studentMenu() 307 | 308 | elif answer == 2: 309 | studentMenu() 310 | 311 | elif choice == "5": 312 | login() 313 | 314 | login() 315 | -------------------------------------------------------------------------------- /Currency Converter.py: -------------------------------------------------------------------------------- 1 | money = {"$": {"€": 0.9, "£": 0.77, "₺": 5.94, "﷼": 3.75}, "£": {"€": 1.17, "$": 1.30, "₺": 7.72, "﷼": 4.88},"€": {"$": 1.11, "£": 0.85, "₺": 6.58, "﷼": 4.16}, "₺": {"€": 0.15, "£": 0.13, "$": 0.17, "﷼": 0.63},"﷼": {"€": 0.24, "£": 0.2, "₺": 1.58, "$": 0.27}} 2 | symbol = {"dolar": "$", "euro": "€", "pound": "£", "tl": "₺", "riyal" : "﷼"} 3 | def currency(): 4 | while True: 5 | fromType = input("Which currency you want to covert from?: ") 6 | print("") 7 | try: fromType = symbol[fromType] 8 | except KeyError: print("Invalid currency. Please enter again\n") 9 | else: break 10 | while True: 11 | toType = input("Which currency you want to covert to?: ") 12 | print("") 13 | try: toType = symbol[toType] 14 | except KeyError: print("Invalid currency. Please enter again\n") 15 | else: break 16 | while True: 17 | try: number = float(input("How much you want to covert: ")) 18 | except ValueError as hata1: print("\nYou need to enter a number. Please try again\n") 19 | else: break 20 | converted = number * money[fromType][toType] 21 | converted = float("{:.2f}".format(converted)) 22 | print(f"\n{converted}\n") 23 | while True: 24 | ans = input("Do you want to make another operation? (y or n): ").upper() 25 | if ans == "Y": currency() 26 | elif ans == "N": exit() 27 | else: print("Your answer should be y or n. Please enter again\n") 28 | currency() -------------------------------------------------------------------------------- /Duration Adder.py: -------------------------------------------------------------------------------- 1 | dur = list() 2 | while True: 3 | ask = input("How many durations you want to add?:") 4 | if ask.isdigit() == False: 5 | print ("The duration must be integer not string. Please enter again.") 6 | else: 7 | break 8 | for i in range(int(ask)): 9 | while True: 10 | durations = input("{}. video's duration:".format(i+1)) 11 | seg = durations.split(".") 12 | for i in range(len(seg)): 13 | if seg[i].isdigit() == False: 14 | print("The duration must be integer not string. Please enter again.") 15 | elif len(seg) >3: 16 | print ("Invalid input. Please enter again") 17 | else: 18 | pass 19 | break 20 | dur.append(durations) 21 | def Counter(dur): 22 | sec = list() 23 | min = list() 24 | hour = list() 25 | for i in dur: 26 | seg = i.split(".") 27 | if len(seg) == 3: 28 | hour.append(int(seg[0])) 29 | min.append(int(seg[1])) 30 | sec.append(int(seg[2])) 31 | if len(seg) == 2: 32 | min.append(int(seg[0])) 33 | sec.append(int(seg[1])) 34 | if len(seg) == 1: 35 | min.append(int(seg[0])) 36 | quotient_sec = sum(sec)//60 37 | second = sum(sec)%60 38 | quotient_min = (sum(min)+quotient_sec)//60 39 | minute = (sum(min)+quotient_sec)%60 40 | hour = (sum(hour)+quotient_min) 41 | print ("\n{}.{}.{}\n".format(hour,minute,second)) 42 | input("Press enter to exit") 43 | Counter(dur) 44 | -------------------------------------------------------------------------------- /Encyription.py: -------------------------------------------------------------------------------- 1 | class Encyription: 2 | def __init__(self): 3 | self.message = input("What is your message?:") 4 | while True: 5 | self.key = input("Whick key do you want to use (int only)?:") 6 | if self.key.lstrip("-").isdigit() == False: 7 | print("Your key must be an integer. Please enter again.") 8 | else: 9 | self.key = int(self.key) 10 | self.working = list(self.message) 11 | break 12 | self.main() 13 | 14 | def main(self): 15 | self.cypher = ["a","b","c","ç","d","e","f","g","ğ","h","ı","i","j","k","l","m","n","o","ö","p","q","r","s","ş", 16 | "t","u","ü","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"," ",",",".","?",":","!", 17 | "&","*","''","+"] 18 | for i in range(len(self.working)): 19 | self.index = self.cypher.index(self.working[i]) + self.key 20 | self.index = self.index % 52 21 | self.working[i] = self.cypher[self.index] 22 | self.encripted = "".join(self.working) 23 | print(self.encripted) 24 | input("Press enter to exit") 25 | Encyription() -------------------------------------------------------------------------------- /Family Game.py: -------------------------------------------------------------------------------- 1 | import random 2 | yes_no = ["yes","no","y","n"] 3 | numbers = list() 4 | for i in range(10000,100000): 5 | control = dict() 6 | for j in str(i): 7 | if j not in control: 8 | control[j] = 1 9 | else: 10 | control[j] += 1 11 | if len(control.values()) == 5: 12 | numbers.append(str(i)) 13 | def Game(): 14 | t = 1 15 | players = list() 16 | print("\nWelcome to the Akbulut Dynasty's fun family game.\n") 17 | print("Please enter gamers names.\n") 18 | while True: 19 | name1 = input("First player's name is?:") 20 | if name1 == "": 21 | print("\nPlease enter a valid name.\n") 22 | else: 23 | break 24 | print("") 25 | while True: 26 | name2 = input("Second player's name is?:") 27 | if name2 == "": 28 | print("\nPlease enter a valid name.\n") 29 | elif name2 == name1: 30 | print("\n{} is already taken. Please enter another name\n".format(name1)) 31 | else: 32 | break 33 | players.append(name1) 34 | players.append(name2) 35 | print("\nNow i'll decide who is gonna start first.\n") 36 | decision = random.choice(players) 37 | if decision == name1: 38 | first = name1 39 | second = name2 40 | else: 41 | first = name2 42 | second = name1 43 | print("{} is the first player\n".format(first)) 44 | print("{}, please enter your number but remember your number must be a positive 5 digit non repeting number.\n".format(first)) 45 | while True: 46 | first_nb = input("Your number is?:") 47 | if first_nb not in numbers: 48 | print("\nYour number should be a 5 digit positive number and should not repeat. Please enter another valid number.\n") 49 | else: 50 | break 51 | print("*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n") 52 | print("{}, please enter your number but remember your number must be a positive 5 digit non repeating number.\n".format(second)) 53 | while True: 54 | second_nb = input("Your number is?:") 55 | if second_nb not in numbers: 56 | print("\nYour number should be a 5 digit positive number and should not repeat. Please enter another valid number.\n") 57 | else: 58 | break 59 | print("*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n") 60 | while True: 61 | if t%2 == 1: 62 | plus = list() 63 | minus = list() 64 | print("It is {}'s turn. Try to guess {}'s number\n".format(first,second)) 65 | while True: 66 | guess = input("Your guess is:") 67 | if guess not in numbers: 68 | print("\nYour number should be a 5 digit positive number and should not repeat. Please enter another valid number.\n") 69 | else: 70 | if guess == second_nb: 71 | print("\n################################## {} Wins !!! ##################################\n".format(first)) 72 | Again() 73 | for i in range(5): 74 | if guess[i] == second_nb[i]: 75 | plus.append(guess[i]) 76 | for i in guess: 77 | for j in second_nb: 78 | if i in j and i not in plus: 79 | minus.append(int(i)) 80 | print("+{}, -{}\n".format(len(plus),len(minus))) 81 | break 82 | t += 1 83 | if t%2 == 0: 84 | plus = list() 85 | minus = list() 86 | print("It is {}'s turn. Try to guess {}'s number\n".format(second, first)) 87 | while True: 88 | guess = input("Your guess is:") 89 | if guess not in numbers: 90 | print("\nYour number should be a 5 digit positive number and should not repeat. Please enter another valid number.\n") 91 | else: 92 | if guess == first_nb: 93 | print("\n################################## {} Wins !!! ##################################\n".format(second)) 94 | Again() 95 | for i in range(5): 96 | if guess[i] == first_nb[i]: 97 | plus.append(guess[i]) 98 | for i in guess: 99 | for j in first_nb: 100 | if i in j and i not in plus: 101 | minus.append(int(i)) 102 | print("+{}, -{}\n".format(len(plus), len(minus))) 103 | break 104 | t += 1 105 | def Again(): 106 | while True: 107 | answer = input("Do you want to play again?:").lower() 108 | if answer not in yes_no: 109 | print("\nYour answer should be either yes or no\n") 110 | elif answer == "yes" or answer == "y": 111 | Game() 112 | else: 113 | print("\nIt was nice to play with you i hope we will meet again soon. Good bye.\n") 114 | exit() 115 | Game() -------------------------------------------------------------------------------- /Guess Game Reverse.py: -------------------------------------------------------------------------------- 1 | print("I will try to guess your number. Here we go") 2 | 3 | guess = 50 4 | false_guess = 0 5 | 6 | while false_guess!=7: 7 | ans = input(f"Is it {guess}?: ") 8 | 9 | if ans=="yes": 10 | print (f"Americaaaaa fuck yeah\n{false_guess} turns it took to guess") 11 | break 12 | 13 | elif "upper" in ans: #inc guess 14 | 15 | if "close" in ans: #inc 1< guess <10 16 | 17 | if "too" in ans: 18 | guess += 1 19 | else: 20 | guess += 5 21 | 22 | elif "far" in ans: 23 | 24 | if "too" in ans: 25 | guess += 15 26 | else: 27 | guess += 10 28 | 29 | elif "lower" in ans: 30 | 31 | if "close" in ans: 32 | 33 | if "too" in ans: 34 | guess -= 1 35 | else: 36 | guess -= 5 37 | 38 | elif "far" in ans: 39 | 40 | if "close" in ans: 41 | 42 | if "too" in ans: 43 | guess -= 15 44 | else: 45 | guess -= 10 46 | 47 | else: 48 | print("Invalid Entry. Please try again") 49 | continue 50 | 51 | false_guess += 1 52 | print(f"{7 - false_guess} turns left") -------------------------------------------------------------------------------- /Guess Game.py: -------------------------------------------------------------------------------- 1 | import random 2 | interval=["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24", 3 | "25","26","27","28","29","30","31","32","33","34","35","36","37","38","39","40","41","42","43","44","45","46", 4 | "47","48","49","50","51","52","53","54","55","56","57","58","60","61","62","63","64","65","66","67","68","69", 5 | "70","71","72","73","74","75","76","77","78","79","80","81","82","83","84","85","86","87","88","89","90","91", 6 | "92","93","94","95","96","97","98","99"] 7 | print ("!!!Welcome to the most exquisite game of all time :)!!!") 8 | name = input("Please enter your name:") 9 | while True: 10 | if name=="": 11 | print ("Name cant be blank. Please type your name.") 12 | name = input("Please enter your name:") 13 | else: 14 | break 15 | print ("Welcome" + " " + name + ". " + "You're in a virtual reality guess game. Here how this game works. ") 16 | print ("I kept a number in my mind which in between 0 and 100. You'll try to figure out the number by guessing. You have 7 guesses total.") 17 | print ("When you make your guess i'll tell you if you are far away or close. ") 18 | print ("Lets begin. Good Luck :)") 19 | def again(): 20 | while True: 21 | choice = input("You wanna play again?:") 22 | if choice == "yes": 23 | Guess() 24 | elif choice == "no": 25 | print ("Ok. It was nice seing you. I hope we'll meet again. Stay safe by then") 26 | break 27 | else: 28 | print ("I dont know what that is. Please type yes or no") 29 | def Guess(): 30 | number = random.randint(1,100) 31 | answer = input("Your guess is:") 32 | guess=7 33 | while guess<8 and guess>1: 34 | while True: 35 | if answer not in interval: 36 | print ("Your entry is not valid. Please type a number between 0 and 100") 37 | answer = input("Your guess is:") 38 | else: 39 | break 40 | if answer==str(number): 41 | 42 | print("woooow are you a kahin :)") 43 | again() 44 | elif answer>str(number): 45 | 46 | print("You went too far try a smaller number") 47 | guess -= 1 48 | 49 | print("Now you're left with" + " " + str(guess) + " " + "number of guesses. Choose wisely.") 50 | answer = input("Your guess is:") 51 | else: 52 | 53 | print("Is this your best guess? Try bigger numbers") 54 | guess -= 1 55 | print("Now you're left with" + " " + str(guess) + " " + "number of guesses. Choose wisely.") 56 | answer = input("Your guess is:") 57 | if guess==1: 58 | print 59 | print("HAHAHAHAHA. It was" + " " + str(number) + ".") 60 | again() 61 | Guess() -------------------------------------------------------------------------------- /Hadi Game.py: -------------------------------------------------------------------------------- 1 | import random 2 | questions = {"Q1": {"Question": "What color are Zebras?", "ans1": ["White with black stripes", "True"], 3 | "ans2": ["Black with white stripes", "False"], "ans3": ["Black with red stripes", "False"]}, 4 | "Q2": {"Question": "Where was the old Campus of Sehir University?", "ans1": ["Altunizade", "True"], 5 | "ans2": ["Levent", "False"], "ans3": ["Maltepe", "False"]}} 6 | users = {"5577": ["abbas", 5.4], "5551": ["omer", 6.4], "5466": ["betul", 3.2]} 7 | 8 | new_users = {"abbas":["5577",5.4],"omer":["5551",6.4],"betul":["5466",3.2]} 9 | 10 | prize = 10000 11 | 12 | def main_menu(prize,questions,users): 13 | 14 | print "--- Welcome to Sehir Hadi :) ---" 15 | 16 | PhoneNb = raw_input("Please type your phone number in order to sign in:") 17 | 18 | while True: 19 | 20 | if PhoneNb =="**": 21 | admin_menu(prize,questions,users) 22 | break 23 | 24 | if PhoneNb not in users: 25 | print "Checking ",PhoneNb," ...." 26 | print PhoneNb," is not a valid phone number, please try again!" 27 | PhoneNb = raw_input("Please type your phone number in order to sign in:") 28 | 29 | else: 30 | print "Checking ",PhoneNb," ...." 31 | print "Welcome ",users[PhoneNb][0] 32 | 33 | Logic(prize,new_users,PhoneNb,users) 34 | break 35 | 36 | def admin_menu(prize,questions,users):# this is the main menu function that plays the content of the sub menu. 37 | k = 3 38 | new_question = 3 39 | arr = ["1","2","3","4","5","6"] 40 | print "Welcome Sehir Hadi Admin Section, please choose one of the following options:" 41 | print "1 - Set prize for the next competition." 42 | print "2 - Display questions for the next competition." 43 | print "3 - Add new question to the next competition." 44 | print "4 - Delete a question from the next competition." 45 | print "5 - See users data." 46 | print "6 - Log out." 47 | 48 | 49 | menu_choice = raw_input("Please choose a menu number:") 50 | 51 | while True: 52 | if menu_choice not in arr: 53 | print "Invalid menu number. Please choose a menu number: " 54 | menu_choice = raw_input("Please choose a menu number:") 55 | else: 56 | break 57 | 58 | if menu_choice == "1": # to setting prize the menu 59 | prize_value = raw_input("Please type the total prize of the next competition:") 60 | print "Setting prize...\n" \ 61 | "Going back to Admin Menu..." 62 | prize = prize_value 63 | admin_menu(prize,questions,users) 64 | 65 | if menu_choice == "2": # to see the question. 66 | for item in questions: 67 | print "--- ",item," : ",questions[item]["Question"]," ---" 68 | print "ans 1. ",questions[item]["ans1"][0]," >",questions[item]["ans1"][1] 69 | print "ans 2. ",questions[item]["ans2"][0]," >",questions[item]["ans2"][1] 70 | print "ans 3. ",questions[item]["ans3"][0]," >",questions[item]["ans3"][1] 71 | print "Going back to admin menu" 72 | admin_menu(prize,questions,users) 73 | 74 | if menu_choice == "3": # to add a new question. 75 | question_number = "Q" + str(len(questions) + 1) 76 | temporary = {question_number: {"Question": raw_input("Please type the question:"), 77 | "ans1": [raw_input("Please type the CORRECT answer:"), "True"], 78 | "ans2": [raw_input("Please type an incorrect answer:"), "False"], 79 | "ans3": [raw_input("Please type an incorrect answer:"), "False"]}} 80 | questions.update(temporary) 81 | print "Adding to the questions database....." 82 | print "Done..." 83 | print "Going back to admin menu" 84 | admin_menu(prize, questions, users) 85 | 86 | if menu_choice == "4": #to delete question 87 | array = list() 88 | 89 | for i in range(len(questions)): 90 | array.append(str(i+1)) 91 | 92 | for i in questions: 93 | print i+". "+questions[i]["Question"] 94 | 95 | to_be_deleted = raw_input("Please type the number of the question to be deleted:") 96 | 97 | while True: 98 | if to_be_deleted not in array: 99 | print "Invalid choice. Please type the number of the question to be deleted:" 100 | to_be_deleted = raw_input("Please type the number of the question to be deleted:") 101 | else: 102 | index = "Q"+str(to_be_deleted) 103 | questions.pop(index) 104 | print questions 105 | print index+" has been deleted successfully!!" 106 | print "Going back to the Admin menu.." 107 | admin_menu(prize,questions,users) 108 | 109 | if menu_choice == "5": # to see the users' datas. 110 | for i in users: 111 | print users[i][0]+", Balance:"+str(users[i][1])+", Phone Number:"+i 112 | 113 | print "Going back to the Admin menu.." 114 | admin_menu(prize,questions,users) 115 | 116 | if menu_choice == "6": # this is the beginning function of the game , starting game 117 | main_menu(prize,questions,users) 118 | 119 | def Logic(prize,new_users,PhoneNb,users): 120 | 121 | use = list() # taken random players 122 | 123 | user1 = users[PhoneNb][0] # main player 124 | 125 | users.pop(PhoneNb) 126 | 127 | for i in users: 128 | 129 | use.append(users[i][0]) 130 | 131 | user2 = random.choice(use) # a random player 132 | 133 | use.remove(user2) 134 | 135 | user3 = random.choice(use) # another random player 136 | 137 | #user status exist for the eliminated players 138 | 139 | user1_status = 1 140 | 141 | user2_status = 1 142 | 143 | user3_status = 1 144 | 145 | chrs = ["1","2","3"] # chrs exist fot the to choose a answer randomly by the players 146 | 147 | print "The Game Is Starting. Please Fasten Your Seat Belt :)." 148 | 149 | for item in questions: 150 | 151 | print "************************* Total Players: " + str(len(new_users)) 152 | 153 | total_ans = {"ans1": 0, "ans2": 0, "ans3": 0} 154 | 155 | if user2_status == 1: 156 | 157 | user2_choice = random.choice(chrs) 158 | 159 | answer = "ans" + user2_choice 160 | 161 | total_ans[answer]+=1 162 | 163 | if questions[item][answer][1] == "True": 164 | pass 165 | else: 166 | user2_status = 0 167 | new_users.pop(user2) 168 | 169 | if user3_status == 1: 170 | 171 | user3_choice = random.choice(chrs) 172 | 173 | answer = "ans" + user3_choice 174 | 175 | total_ans[answer]+=1 176 | 177 | if questions[item][answer][1] == "True": 178 | pass 179 | else: 180 | user3_status = 0 181 | new_users.pop(user3) 182 | 183 | if user1_status == 1: 184 | 185 | print "--- ", item, " : ", questions[item]["Question"], " ---" 186 | print "ans 1. ", questions[item]["ans1"][0] 187 | print "ans 2. ", questions[item]["ans2"][0] 188 | print "ans 3. ", questions[item]["ans3"][0] 189 | answ = raw_input("Your answer:") 190 | ques = "ans"+answ 191 | 192 | total_ans[ques]+=1 193 | 194 | if questions[item][ques][1] == "True": 195 | print "Correct" 196 | pass 197 | else: 198 | print "Incorrect" 199 | user1_status = 0 200 | new_users.pop(user1) 201 | 202 | print "Evaluating the responses of the other competitors...." 203 | print "ans 1. ", questions[item]["ans1"][0]+"... total answers:"+str(total_ans["ans1"]) 204 | print "ans 2. ", questions[item]["ans2"][0]+"... total answers:"+str(total_ans["ans2"]) 205 | print "ans 3. ", questions[item]["ans3"][0]+"... total answers:"+str(total_ans["ans3"]) 206 | 207 | else: 208 | 209 | print "--- ", item, " : ", questions[item]["Question"], " ---" 210 | print "ans 1. ", questions[item]["ans1"][0]+"... total answers:"+str(total_ans["ans1"]) 211 | print "ans 2. ", questions[item]["ans2"][0]+"... total answers:"+str(total_ans["ans2"]) 212 | print "ans 3. ", questions[item]["ans3"][0]+"... total answers:"+str(total_ans["ans3"]) 213 | 214 | print "Evaluating the responses of the other competitors...." 215 | print "ans 1. ", questions[item]["ans1"][0] + "... total answers:" + str(total_ans["ans1"]) 216 | print "ans 2. ", questions[item]["ans2"][0] + "... total answers:" + str(total_ans["ans2"]) 217 | print "ans 3. ", questions[item]["ans3"][0] + "... total answers:" + str(total_ans["ans3"]) 218 | 219 | 220 | print "-- Total Winners:"+str(len(new_users)) 221 | 222 | print "-- Total distributed prize:"+str(prize) 223 | 224 | for i in new_users: 225 | 226 | print i+" -->"+ str(int(prize)/len(new_users))+" - Current Balance:"+ str(new_users[i][1]+prize/len(new_users)) 227 | 228 | 229 | print "See you later :)" 230 | 231 | main_menu(prize,questions,users) 232 | 233 | 234 | 235 | 236 | main_menu(prize,questions,users) 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | -------------------------------------------------------------------------------- /Hangman Game.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | HANGMAN = [ 4 | """ 5 | ----- 6 | | | 7 | | 8 | | 9 | | 10 | | 11 | | 12 | | 13 | | 14 | -------- 15 | """, 16 | """ 17 | ----- 18 | | | 19 | | 0 20 | | 21 | | 22 | | 23 | | 24 | | 25 | | 26 | -------- 27 | """, 28 | """ 29 | ----- 30 | | | 31 | | 0 32 | | -+- 33 | | 34 | | 35 | | 36 | | 37 | | 38 | -------- 39 | """, 40 | """ 41 | ----- 42 | | | 43 | | 0 44 | | /-+- 45 | | 46 | | 47 | | 48 | | 49 | | 50 | -------- 51 | """, 52 | """ 53 | ----- 54 | | | 55 | | 0 56 | | /-+-\ 57 | | 58 | | 59 | | 60 | | 61 | | 62 | -------- 63 | """, 64 | """ 65 | ----- 66 | | | 67 | | 0 68 | | /-+-\ 69 | | | 70 | | 71 | | 72 | | 73 | | 74 | -------- 75 | """, 76 | """ 77 | ----- 78 | | | 79 | | 0 80 | | /-+-\ 81 | | | 82 | | | 83 | | 84 | | 85 | | 86 | -------- 87 | """, 88 | """ 89 | ----- 90 | | | 91 | | 0 92 | | /-+-\ 93 | | | 94 | | | 95 | | | 96 | | 97 | | 98 | -------- 99 | """, 100 | """ 101 | ----- 102 | | | 103 | | 0 104 | | /-+-\ 105 | | | 106 | | | 107 | | | 108 | | | 109 | | 110 | -------- 111 | """, 112 | """ 113 | ----- 114 | | | 115 | | 0 116 | | /-+-\ 117 | | | 118 | | | 119 | | | | 120 | | | 121 | | 122 | -------- 123 | """, 124 | """ 125 | ----- 126 | | | 127 | | 0 128 | | /-+-\ 129 | | | 130 | | | 131 | | | | 132 | | | | 133 | | 134 | -------- 135 | """] 136 | 137 | 138 | def game(): 139 | false_guess = 0 140 | 141 | true = list() 142 | false = list() 143 | 144 | print("Welcome to the AkGame's high tech hangman game :) \n") 145 | sentence = input("Please enter a name: ").strip() 146 | print( 147 | "*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n") 148 | 149 | empty = list(sentence.replace(" ", "/")) 150 | 151 | for char in range(len(empty)): 152 | if empty[char] != "/": 153 | empty[char] = "-" 154 | 155 | state = "continue" 156 | 157 | while state == "continue": 158 | 159 | print(" ","".join(empty), end="\n\n") 160 | 161 | guess = input("Enter your guess: ").strip() 162 | 163 | 164 | if guess == sentence: 165 | print("\nYou won the game. Congratulations\n") 166 | state = "end" 167 | 168 | elif false_guess == 11: 169 | print("\nYou lost :(. Sorry\n") 170 | state = "end" 171 | 172 | elif "/" in sentence or sentence == "": 173 | print("\nYour guess must consist of alpha numerical characters\n") 174 | 175 | elif guess in true: 176 | print(f"\nYou already said {guess} and i displayed it\n") 177 | 178 | elif guess in false: 179 | print(f"\nYou already said {guess} and it was false\n") 180 | 181 | elif guess in sentence: 182 | 183 | for i in range(len(sentence)): 184 | if guess == sentence[i]: 185 | empty[i] = guess 186 | 187 | true.append(guess) 188 | 189 | if "-" not in empty: 190 | print("\nYou won the game. Congratulations\n") 191 | state = "end" 192 | 193 | else: 194 | print(HANGMAN[false_guess]) 195 | false_guess += 1 196 | false.append(guess) 197 | 198 | again() 199 | 200 | 201 | def again(): 202 | while True: 203 | answer = input("Do you want to play again? (y or n):") 204 | 205 | if answer == "y": 206 | os.system("cls" if os.name == "nt" else "clear") 207 | game() 208 | 209 | elif answer == "n": 210 | exit() 211 | 212 | else: 213 | print("please type either y or n") 214 | 215 | 216 | if __name__ == '__main__': 217 | game() -------------------------------------------------------------------------------- /Luhn Algorithm.py: -------------------------------------------------------------------------------- 1 | def Verify(): 2 | print("\nWelcome If you want to verify your credit card number, You are in the right place\n") 3 | while True: 4 | number = input("Please enter your credit card number:") 5 | if number.isdigit() == False: 6 | print("\nYour number should be integer. Please enter a 16 digit integer.\n") 7 | elif len(number) != 16: 8 | print("\nYour number should be 16 digit. Please enter a 16 digit integer.\n") 9 | else: 10 | Execution(number) 11 | break 12 | def Execution(number): 13 | hulu = list() 14 | for i in range(len(number)): 15 | hulu.append(int(number[-(i+1)])) 16 | for ind,value in enumerate(hulu): 17 | if ind % 2 == 1: 18 | value = value * 2 19 | if len(str(value))!=1: 20 | check = list() 21 | for i in str(value): 22 | check.append(int(i)) 23 | value = sum(check) 24 | hulu[ind] = value 25 | else: 26 | hulu[ind] = value 27 | else: 28 | pass 29 | if sum(hulu) % 10 == 0: 30 | print("\nYour credit card number checks out. It is ready to use :).\n") 31 | Again() 32 | else: 33 | print("\nYour credit card number is fake. Please alert the authorities immidiatly.\n") 34 | Again() 35 | def Again(): 36 | yes_no = ["yes", "no", "y", "n"] 37 | while True: 38 | answer = input("Do you want to check another card?:").lower() 39 | if answer not in yes_no: 40 | print("\nYour answer should be either yes or no\n") 41 | elif answer == "yes" or answer == "y": 42 | Verify() 43 | else: 44 | print("\nIt was nice to play with you i hope we will meet again soon. Good bye.\n") 45 | exit() 46 | Verify() -------------------------------------------------------------------------------- /Magic 8 Ball.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | question = None 4 | while question != "": 5 | 6 | question = input("Ask the magic 8 ball a question (press enter to quit):\n") 7 | 8 | answers = random.randint(1, 8) 9 | 10 | if answers == 1: 11 | print ("It is certain") 12 | 13 | elif answers == 2: 14 | print ("Outlook good") 15 | 16 | elif answers == 3: 17 | print ("You may rely on it") 18 | 19 | elif answers == 4: 20 | print ("Ask again later") 21 | 22 | elif answers == 5: 23 | print ("Concentrate and ask again") 24 | 25 | elif answers == 6: 26 | print ("Reply hazy, try again") 27 | 28 | elif answers == 7: 29 | print ("My reply is no") 30 | 31 | elif answers == 8: 32 | print ("My sources say no") -------------------------------------------------------------------------------- /Match.py: -------------------------------------------------------------------------------- 1 | import random 2 | import copy 3 | 4 | names = [] 5 | 6 | def main(): 7 | 8 | while True: 9 | number = input("Please enter the amounth of people: ") 10 | if number.isdigit() == False: 11 | print("Please enter a number not something else") 12 | elif int(number) % 2 != 0: 13 | print("You cant enter odd number of people. Please enter an even number") 14 | else: 15 | counter = 1 16 | for i in range(int(number)): 17 | n = input(f"Please enter {counter}. Name: ") 18 | names.append(n) 19 | counter += 1 20 | break 21 | sort(names) 22 | 23 | def sort(names): 24 | sorte = [] 25 | trial = copy.copy(names) 26 | for i in range(len(names)//2): 27 | a = random.choice(trial) 28 | trial.remove(a) 29 | b = random.choice(trial) 30 | trial.remove(b) 31 | sorte.append((a,b)) 32 | print(sorte) 33 | again() 34 | 35 | def again(): 36 | while True: 37 | again = input("Do you want me to shuffle again?:") 38 | if again == "yes" or again == "y": 39 | sort(names) 40 | elif again == "no" or again == "n": 41 | print("It was nice seeing you. See you later :)") 42 | exit() 43 | else: 44 | print("Your entry should be yes or no. Please enter again") 45 | 46 | main() 47 | 48 | -------------------------------------------------------------------------------- /Math Questions Contest.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | allnumbers = [] 4 | 5 | for i in range(0,10001): 6 | allnumbers.append(str(i)) 7 | allnumbers.append(str(-i)) 8 | 9 | falseansw = 0 10 | 11 | operations = ["+", "-", "*", "/", "%"] 12 | 13 | numbers1 = ["1","2","3","4","5","6","7","8","9","10"] 14 | 15 | numbers2 = [] 16 | 17 | for i in range(1,101): 18 | numbers2.append(str(i)) 19 | 20 | print ("Welcome to the random math question game!") 21 | 22 | def level1(falseansw): 23 | 24 | strpoint = 0 25 | 26 | inuse = [operations[0]] 27 | 28 | print ("Level1:") 29 | 30 | print ("Possible length of Numbers: 1") 31 | 32 | print ("Possible number of Operators: 1") 33 | 34 | for i in range(5): 35 | nb1 = random.choice(numbers1) 36 | nb2 = random.choice(numbers1) 37 | op = random.choice(inuse) 38 | cransw = str(eval(nb1 + op + nb2)) 39 | print (strpoint * "*") 40 | ans = input("what is "+nb1+op+nb2+" ?:") 41 | while True: 42 | if ans not in allnumbers: 43 | print ("ERROR! Un-acceptable entry detected, try again please!") 44 | ans = input("what is " + nb1 + op + nb2 + " ?:") 45 | else: 46 | break 47 | if ans == cransw: 48 | strpoint += 1 49 | print ("Correct! You gain an additional star! You now have %s out of five stars!" % (strpoint)) 50 | if ans != cransw: 51 | falseansw+=1 52 | print ("Wrong! You do not gain any stars for that question!") 53 | print ("You now have %s out of five stars!" % (strpoint)) 54 | if strpoint<3: 55 | print ("You do not have enough stars to move on to the next level, this as far as you go!") 56 | exit() 57 | elif strpoint>=3: 58 | print ("You have enough stars this level, time to move on!") 59 | level2(falseansw) 60 | 61 | def level2(falseansw): 62 | strpoint = 0 63 | 64 | inuse = [operations[0],operations[1]] 65 | 66 | print ("Level2:") 67 | 68 | print ("Possible length of Numbers: 1") 69 | 70 | print ("Possible number of Operators: 2") 71 | 72 | for i in range(5): 73 | nb1 = random.choice(numbers1) 74 | nb2 = random.choice(numbers1) 75 | op = random.choice(inuse) 76 | cransw = str(eval(nb1 + op + nb2)) 77 | print (strpoint * "*") 78 | ans = input("what is " + nb1 + op + nb2 + " ?:") 79 | while True: 80 | if ans not in allnumbers: 81 | print ("ERROR! Un-acceptable entry detected, try again please!") 82 | ans = raw_input("what is " + nb1 + op + nb2 + " ?:") 83 | else: 84 | break 85 | if ans == cransw: 86 | strpoint += 1 87 | print ("Correct! You gain an additional star! You now have %s out of five stars!" % (strpoint)) 88 | if ans != cransw: 89 | falseansw += 1 90 | print ("Wrong! You do not gain any stars for that question!") 91 | print ("You now have %s out of five stars!" % (strpoint)) 92 | if strpoint < 3: 93 | print ("You do not have enough stars to move on to the next level, this as far as you go!") 94 | exit() 95 | if strpoint >= 3: 96 | print ("You have enough stars this level, time to move on!") 97 | level3(falseansw) 98 | 99 | def level3(falseansw): 100 | strpoint = 0 101 | 102 | inuse = [operations[0], operations[1],operations[2]] 103 | 104 | print ("Level3:") 105 | 106 | print ("Possible length of Numbers: 1") 107 | 108 | print ("Possible number of Operators: 3") 109 | 110 | for i in range(5): 111 | nb1 = random.choice(numbers1) 112 | nb2 = random.choice(numbers1) 113 | op = random.choice(inuse) 114 | cransw = str(eval(nb1 + op + nb2)) 115 | 116 | print (strpoint * "*") 117 | ans = input("what is " + nb1 + op + nb2 + " ?:") 118 | while True: 119 | if ans not in allnumbers: 120 | print ("ERROR! Un-acceptable entry detected, try again please!") 121 | ans = input("what is " + nb1 + op + nb2 + " ?:") 122 | else: 123 | break 124 | if ans == cransw: 125 | strpoint += 1 126 | print ("Correct! You gain an additional star! You now have %s out of five stars!" % (strpoint)) 127 | if ans != cransw: 128 | falseansw += 1 129 | print ("Wrong! You do not gain any stars for that question!") 130 | print ("You now have %s out of five stars!" % (strpoint)) 131 | if strpoint < 3: 132 | print ("You do not have enough stars to move on to the next level, this as far as you go!") 133 | exit() 134 | if strpoint >= 3: 135 | print ("You have enough stars this level, time to move on!") 136 | level4(falseansw) 137 | 138 | def level4(falseansw): 139 | strpoint = 0 140 | 141 | inuse = [operations[0], operations[1],operations[2],operations[3]] 142 | 143 | print ("Level4:") 144 | 145 | print ("Possible length of Numbers: 2") 146 | 147 | print ("Possible number of Operators: 4") 148 | 149 | for i in range(5): 150 | nb1 = random.choice(numbers1) 151 | nb2 = random.choice(numbers1) 152 | op = random.choice(inuse) 153 | cransw = str(eval(nb1 + op + nb2)) 154 | print (strpoint * "*") 155 | ans = input("what is " + nb1 + op + nb2 + " ?:") 156 | while True: 157 | if ans not in allnumbers: 158 | print ("ERROR! Un-acceptable entry detected, try again please!") 159 | ans = input("what is " + nb1 + op + nb2 + " ?:") 160 | else: 161 | break 162 | if ans == cransw: 163 | strpoint += 1 164 | print ("Correct! You gain an additional star! You now have %s out of five stars!" % (strpoint)) 165 | if ans != cransw: 166 | falseansw += 1 167 | print ("Wrong! You do not gain any stars for that question!") 168 | print ("You now have %s out of five stars!" % (strpoint)) 169 | if strpoint < 3: 170 | print ("You do not have enough stars to move on to the next level, this as far as you go!") 171 | exit() 172 | if strpoint >= 3: 173 | print ("You have enough stars this level, time to move on!") 174 | level5(falseansw) 175 | 176 | def level5(falseansw): 177 | strpoint = 0 178 | 179 | inuse = [operations[0], operations[1],operations[2],operations[3],operations[4]] 180 | 181 | print ("Level5:") 182 | 183 | print ("Possible length of Numbers: 2") 184 | 185 | print ("Possible number of Operators: 5") 186 | 187 | for i in range(5): 188 | nb1 = random.choice(numbers1) 189 | nb2 = random.choice(numbers1) 190 | op = random.choice(inuse) 191 | cransw = str(eval(nb1 + op + nb2)) 192 | print (strpoint * "*") 193 | ans = input("what is " + nb1 + op + nb2 + " ?:") 194 | while True: 195 | if ans not in allnumbers: 196 | print ("ERROR! Un-acceptable entry detected, try again please!") 197 | ans = input("what is " + nb1 + op + nb2 + " ?:") 198 | else: 199 | break 200 | if ans == cransw: 201 | strpoint += 1 202 | print ("Correct! You gain an additional star! You now have %s out of five stars!" % (strpoint)) 203 | if ans != cransw: 204 | falseansw += 1 205 | print ("Wrong! You do not gain any stars for that question!") 206 | print ("You now have %s out of five stars!" % (strpoint)) 207 | if strpoint < 3: 208 | print ("You do not have enough stars to move on to the next level, this as far as you go!") 209 | exit() 210 | if strpoint >= 3: 211 | print ("You have enough stars this level, time to move on!") 212 | print ("Amazing! You beat the game! You answered a total of %s answers wrong this attempt" % (falseansw)) 213 | exit() 214 | 215 | level1(falseansw) 216 | -------------------------------------------------------------------------------- /Password Generator.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | numbers = list() 4 | 5 | for i in range(40): numbers.append(str(i)) 6 | 7 | while True: 8 | ans = input("How many password do you want?:") 9 | 10 | if ans not in numbers: print("Your integer must be between 8 and 40. Please enter a valid number.") 11 | else: break 12 | 13 | while True: 14 | leng = input("How long do you want your password to be?:") 15 | 16 | if leng not in numbers: print("Your integer must be between 8 and 40. Please enter a valid number.") 17 | else: break 18 | 19 | for i in range(int(ans)): 20 | pas = list() 21 | 22 | C = random.sample("ABCDEFGHIJKLMNOPQRSTUVWXYZ", int(leng)//4) 23 | CH = random.sample("!'#+%&/*?-_@,.:;", int(leng) // 4) 24 | NUM = random.sample("0123456789", int(leng) // 4) 25 | SML = random.sample("abcdefghijklmnopqrstuvwxyz", int(leng)-int(leng)//4*3) 26 | 27 | for i in C: pas+= i 28 | for i in CH: pas+= i 29 | for i in NUM: pas+= i 30 | for i in SML: pas+= i 31 | 32 | random.shuffle(pas) 33 | password = "".join(pas) 34 | print (password) 35 | 36 | input("Press enter to exit") 37 | 38 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Small Projects 2 | 3 | Here are my 25 small practice projects. 4 | These are good starting projects if you are new in python. 5 | -------------------------------------------------------------------------------- /Remember the Number.py: -------------------------------------------------------------------------------- 1 | import random 2 | print ("Welcome to the AkTech's new hit game. The game is simple. You are going to enter a number, add to tour previous number and remember it.\n" \ 3 | "For example if you said 3 you are going to type 3. on the next turn if you say 4 you are going to type 34. Good Luck :)\n") 4 | class Number: 5 | def __init__(self): 6 | self.Users() 7 | def Users(self): 8 | self.users = {} 9 | while True: 10 | self.name1 = input("Please enter the first player's name:") 11 | print ("") 12 | if self.name1 == "": 13 | print ("Your name can not be empty. Please enter a valid name.\n") 14 | else: 15 | self.users[self.name1] = "" 16 | break 17 | while True: 18 | self.name2 = input("Please enter the second player's name:") 19 | print ("") 20 | if self.name2 == "": 21 | print ("Your name can not be empty. Please enter a valid name.\n") 22 | elif self.name2 == self.name1: 23 | print (f"{self.name2} is taken. Please enter another name\n") 24 | else: 25 | self.users[self.name2] = "" 26 | break 27 | self.Game() 28 | def Game(self): 29 | self.num = [] 30 | self.players = [] 31 | for i in self.users: 32 | self.players.append(i) 33 | for i in range(10): 34 | self.num.append(str(i)) 35 | print ("Now i'll decide who goes first\n") 36 | self.first_player = random.choice(self.players) 37 | self.players.remove(self.first_player) 38 | self.second_player = random.choice(self.players) 39 | print (f"{self.first_player} starts first\n") 40 | while True: 41 | self.first_number = input(f"{self.second_player} enter {self.first_player}'s first number:") 42 | print ("") 43 | if len(self.first_number) != 1: 44 | print ("Number should be 1 digit. Please enter again\n") 45 | elif self.first_number not in self.num: 46 | print ("Your input should be an integer. Please enter again.\n") 47 | else: 48 | self.users[self.first_player]+=self.first_number 49 | break 50 | i = 0 51 | while True: 52 | if i%2==0: 53 | print (f"----- {self.first_player}'s Turn -----\n") 54 | print ("I'll print your number try to memorize it.*\n") 55 | print (f"{self.users[self.first_player]}\n") 56 | ready = input("Press Enter when you are ready?:") 57 | print("*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n") 58 | ask = input("Plese type your number:") 59 | print ("") 60 | 61 | if ask == self.users[self.first_player]: 62 | 63 | print ("Correct. You entered right. Congratulations. Moving on.\n") 64 | 65 | while True: 66 | 67 | self.second_number = input(f"{self.first_player} enter {self.second_player}'s first number:") 68 | print ("") 69 | 70 | if len(self.second_number) != 1: 71 | 72 | print ("Number should be 1 digit. Please enter again\n") 73 | 74 | elif self.second_number not in self.num: 75 | 76 | print ("Your input should be an integer. Please enter again.\n") 77 | 78 | else: 79 | 80 | self.users[self.second_player] += self.second_number 81 | break 82 | 83 | else: 84 | 85 | print (":( unfortunately that is wrong.\n") 86 | 87 | print (f"print ################################## {self.second_player} Wins !!! ##################################\n") 88 | 89 | try: 90 | print (f"{self.second_player} remembered {self.second_number} digit number\n") 91 | except AttributeError: 92 | print(f"{self.second_player} could not even play.\n") 93 | 94 | 95 | 96 | while True: 97 | 98 | again = input("Do you want to play again? Y or N:") 99 | print ("") 100 | 101 | if again == "Y" or again == "y": 102 | 103 | self.users() 104 | 105 | elif again == "N" or again == "n": 106 | 107 | exit() 108 | 109 | else: 110 | 111 | print ("You have to enter either Y or N") 112 | 113 | if i%2 == 1: 114 | 115 | print (f"----- {self.second_player}'s Turn -----") 116 | 117 | print ("I'll print your number try to memorize it.*\n") 118 | 119 | print(f"{self.users[self.second_player]}\n") 120 | 121 | ready = input("Press Enter when you are ready?:") 122 | print("*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n") 123 | 124 | ask = input("Plese type your number:") 125 | print ("") 126 | 127 | if ask == self.users[self.second_player]: 128 | 129 | print ("Correct. You entered right. Congratulations. Moving on.\n") 130 | 131 | while True: 132 | 133 | self.first_number = input(f"{self.second_player} enter {self.first_player}'s first number:") 134 | print ("") 135 | 136 | if len(self.first_number) != 1: 137 | 138 | print ("Number should be 1 digit. Please enter again\n") 139 | 140 | elif self.first_number not in self.num: 141 | 142 | print ("Your input should be an integer. Please enter again.\n") 143 | 144 | else: 145 | 146 | self.users[self.first_player] += self.first_number 147 | break 148 | 149 | else: 150 | 151 | print (":( unfortunately that is wrong.\n") 152 | 153 | print (f"print ################################## {self.first_player} Wins !!! ##################################\n") 154 | 155 | print (f"{self.first_player} remembered {self.first_number} digit number\n") 156 | 157 | 158 | while True: 159 | 160 | again = input("Do you want to play again? Y or N:") 161 | print ("") 162 | 163 | if again == "Y" or again == "y": 164 | 165 | self.users() 166 | 167 | elif again == "N" or again == "n": 168 | 169 | exit() 170 | 171 | else: 172 | 173 | print ("You have to enter either Y or N") 174 | 175 | i+=1 176 | 177 | Number() -------------------------------------------------------------------------------- /Rock Paper Scissors.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | shapes = {"s": "✂", "p": "📄", "r": "🤘"} 4 | 5 | def gameLogic(): 6 | print("Welcome to classic awesome Rock Paper Scissor.\nChoose a shape by entering its initial.\nEx r for Rock, s for Scissors and p for paper.\nGood luck :)\n") 7 | playerName = input("Please enter your name: ").capitalize() 8 | print("") 9 | scores = {playerName: 0, "Computer": 0} 10 | state = True 11 | 12 | while state: 13 | items = dict() 14 | playerShape = input("Choose a shape on the count of three 1, 2, 3: ") 15 | print("") 16 | 17 | if playerShape not in shapes: 18 | print("Please choose Rock (r), Paper (p) or Scissors (s).\n") 19 | continue 20 | 21 | computerShape = random.choice(list(shapes.keys())) 22 | items[playerShape], items[computerShape] = playerName, "Computer" 23 | print(f"{playerName}: {shapes[playerShape]}{' ' * 10}Computer: {shapes[computerShape]}\n") 24 | 25 | if playerShape == computerShape: print(f"Its a Withdraw\n\n{playerName}: {scores[playerName]}{' ' * 11}Computer: {scores['Computer']}\n") 26 | elif "r" not in items: 27 | scores[items['s']] += 1 28 | print(f"{items['s']} gets point !!!\n\n{playerName}: {scores[playerName]}{' ' * 11}Computer: {scores['Computer']}\n") 29 | elif "p" not in items: 30 | scores[items['r']] += 1 31 | print(f"{items['r']} gets point !!!\n\n{playerName}: {scores[playerName]}{' ' * 11}Computer: {scores['Computer']}\n") 32 | elif "s" not in items: 33 | scores[items['p']] += 1 34 | print(f"{items['p']} gets point !!!\n\n{playerName}: {scores[playerName]}{' ' * 11}Computer: {scores['Computer']}\n") 35 | 36 | if 3 in scores.values(): 37 | print("#####################################################\n" 38 | f"#################### {list(scores.keys())[list(scores.values()).index(3)]} #######################\n" 39 | "#####################################################\n") 40 | state = False 41 | 42 | while True: 43 | answer = input("Do you want to play again (y or n)?: ") 44 | print("") 45 | 46 | if answer == "y": gameLogic() 47 | elif answer == "n": exit() 48 | else: print("Please enter y or no\n") 49 | 50 | if __name__ == '__main__': 51 | gameLogic() -------------------------------------------------------------------------------- /Tic Tac Toe.py: -------------------------------------------------------------------------------- 1 | import random, os, time 2 | 3 | indexes = [str(i+1) for i in range(0,9)] 4 | 5 | moves = {"1":"00","2":"01","3":"02","4":"10","5":"11","6":"12","7":"20","8":"21","9":"22"} 6 | 7 | 8 | def login(): 9 | 10 | print("Welcome to Tic Tac Toe") 11 | 12 | global gameBoard, playerName1, playerName2 13 | 14 | gameBoard = [[".", ".", "."], 15 | [".", ".", "."], 16 | [".", ".", "."]] 17 | 18 | state = True 19 | 20 | while state: 21 | playerName1 = input("Please enter first players: ").capitalize() 22 | print("") 23 | 24 | if playerName1 == "": print("your name can't be blank\n") 25 | elif len(playerName1) < 3: print("Your name needs to be longer than 2 characters.\n") 26 | else: 27 | print(f"Welcome {playerName1} good luck.\n") 28 | state = False 29 | 30 | state = True 31 | 32 | while state: 33 | playerName2 = input("Please enter second player's name: ").capitalize() 34 | print("") 35 | 36 | if playerName1 == "": print("your name can't be blank\n") 37 | elif len(playerName1) < 3: print("Your name needs to be longer than 2 characters.\n") 38 | elif playerName2 == playerName1: print(f"{playerName1} is taken. Please choose another name\n") 39 | else: 40 | print(f"Welcome {playerName2} good luck.\n") 41 | state = False 42 | 43 | prepareForGame() 44 | 45 | 46 | def prepareForGame(): 47 | print("Now I will decide who goes first and plays as what.\n") 48 | 49 | firstPlayer, secondPlayer = random.sample([playerName1, playerName2], 2) 50 | 51 | firstPlayerShape, secondPlayerShape = random.sample(["X", "O"], 2) 52 | 53 | print(f"{firstPlayer} goes first and plays as {firstPlayerShape}\n\n{secondPlayer} is second and plays as {secondPlayerShape}\n") 54 | 55 | time.sleep(3) 56 | 57 | players = {firstPlayer: firstPlayerShape, secondPlayer: secondPlayerShape} 58 | 59 | gameLogic(firstPlayer, secondPlayer, players) 60 | 61 | 62 | def gameLogic(firstPlayer, secondPlayer, players): 63 | 64 | state = True 65 | 66 | turn = 0 67 | 68 | while state: 69 | 70 | clear() 71 | 72 | for row in gameBoard: 73 | print(f"{row}\n\n") 74 | 75 | 76 | if turn % 2 == 0: 77 | name = firstPlayer 78 | print(f"It is your turn {name}\n") 79 | 80 | while True: 81 | index = input("Please choose an index: ") 82 | print("") 83 | 84 | if index not in indexes: print("Please enter a valid index with spaces between it.\n") 85 | 86 | else: 87 | row, column = list(moves[index]) 88 | row, column = int(row), int(column) 89 | 90 | if gameBoard[row][column] == ".": 91 | gameBoard[row][column] = players[firstPlayer] 92 | break 93 | 94 | else: 95 | print(f"({index}) is filled with {gameBoard[row][column]}. Please choose another index\n", end = "\r") 96 | 97 | else: 98 | name = secondPlayer 99 | print(f"It is your turn {name}\n") 100 | 101 | while True: 102 | index = input("Please choose an index: ") 103 | print("") 104 | 105 | if index not in indexes: 106 | print("Please enter a valid index\n") 107 | 108 | else: 109 | row, column = list(moves[index]) 110 | row, column = int(row), int(column) 111 | 112 | if gameBoard[row][column] == ".": 113 | gameBoard[row][column] = players[secondPlayer] 114 | break 115 | else: 116 | print(f"({index}) is filled with {gameBoard[row][column]}. Please choose another index\n", end = "\r") 117 | 118 | if gameBoard[0][0] == gameBoard[0][1] == gameBoard[0][2] != "." or \ 119 | gameBoard[1][0] == gameBoard[1][1] == gameBoard[1][2] != "." or \ 120 | gameBoard[2][0] == gameBoard[2][1] == gameBoard[2][2] != "." or \ 121 | gameBoard[0][0] == gameBoard[1][0] == gameBoard[2][0] != "." or \ 122 | gameBoard[0][1] == gameBoard[1][1] == gameBoard[2][1] != "." or \ 123 | gameBoard[0][2] == gameBoard[1][2] == gameBoard[2][2] != "." or \ 124 | gameBoard[0][0] == gameBoard[1][1] == gameBoard[2][2] != "." or \ 125 | gameBoard[0][2] == gameBoard[1][1] == gameBoard[2][0] != ".": 126 | 127 | clear() 128 | 129 | for row in gameBoard: 130 | print(f"{row}\n\n") 131 | 132 | print(f"Congratulations {name} you won.\n") 133 | 134 | 135 | print("Game is over\n") 136 | state = False 137 | 138 | elif "." not in gameBoard[0] and "." not in gameBoard[1] and "." not in gameBoard[2]: 139 | print("I'm sorry. The bord is full. Its a drawn :(\n") 140 | state = False 141 | 142 | turn += 1 143 | 144 | while True: 145 | again = input("Do yo want to play again (y or n)?: ") 146 | print("") 147 | 148 | if again == "y": 149 | clear() 150 | login() 151 | 152 | elif again == "n": 153 | print("Thank for playing. I hope i can see you soon :)") 154 | exit() 155 | 156 | else: print("your answer only can be y or no. Please enter a valid answer.\n") 157 | 158 | 159 | def clear(): 160 | os.system("cls" if os.name == "nt" else "clear") 161 | 162 | 163 | if __name__ == '__main__': 164 | login() 165 | -------------------------------------------------------------------------------- /YoutubeVideoDownloader.pyw: -------------------------------------------------------------------------------- 1 | from pytube import YouTube 2 | from tkinter import * 3 | import threading 4 | 5 | 6 | class GUI(Frame): 7 | def __init__(self, parent): 8 | Frame.__init__(self,parent) 9 | self.thread = threading.Thread(target = self.download) 10 | self.initUI() 11 | 12 | 13 | def initUI(self): 14 | self.pack(fill = BOTH, expand = True) 15 | 16 | self.frame1 = Frame(self) 17 | self.frame1.pack() 18 | 19 | self.frame2 = Frame(self) 20 | self.frame2.pack(fill = X, padx = 10, pady = 40) 21 | 22 | self.frame3 = Frame(self) 23 | self.frame3.pack() 24 | 25 | self.frame4 = Frame(self) 26 | self.frame4.pack() 27 | 28 | 29 | Label(self.frame1, text = "YouTube", font = "ComicSans 20", fg = "red").pack() 30 | 31 | Label(self.frame2, text = "Url: ", font = "ComicSans 12").grid(row = 0, column = 0, padx = (0, 10)) 32 | 33 | self.link = Entry(self.frame2, width = 50) 34 | self.link.grid(row = 0, column = 1) 35 | 36 | button = Button(self.frame3, text = "Fetch", font = "ComicSans 12", command = self.fetch) 37 | button.pack() 38 | 39 | self.display = Listbox(self.frame4, selectbackground = "green", activestyle = "none", height = 10, width = 30) 40 | 41 | def fetch(self): 42 | url = self.link.get() 43 | yt = YouTube(url) 44 | self.videos = yt.streams.all() 45 | 46 | self.display.grid(row = 0, column = 0, pady = (30, 0)) 47 | self.select = Button(self.frame4, text = "Select", font = "ComicSans 12", command = self.find) 48 | self.select.grid(row = 0, column = 1, padx = 30) 49 | root.geometry("400x400+450+50") 50 | 51 | for index, video in enumerate(self.videos): 52 | self.display.insert("end" ,f"{index + 1}: {video.mime_type}, {video.resolution}\n") 53 | 54 | def find(self): 55 | name = self.display.get(ACTIVE) 56 | index = int(name.split(":")[0]) - 1 57 | 58 | self.video = self.videos[index] 59 | self.thread.start() 60 | 61 | 62 | 63 | def download(self): 64 | link = "C:\\Users\\Muhammed Fatih\\Downloads\\Videos" 65 | self.video.download(link) 66 | 67 | 68 | 69 | 70 | 71 | if __name__ == '__main__': 72 | root = Tk() 73 | app = GUI(root) 74 | root.title("Video Downloader") 75 | root.geometry("400x200+450+50") 76 | root.mainloop() -------------------------------------------------------------------------------- /try.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fatom98/SmallProjects/4a76b23394387c81285f62d2105fdb678601480f/try.py --------------------------------------------------------------------------------