├── CODSOFT -Task 3 -Quiz Game .ipynb ├── CODSOFT password Generator.ipynb └── To do task.ipynb /CODSOFT -Task 3 -Quiz Game .ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "id": "e69cc1bc", 7 | "metadata": {}, 8 | "outputs": [], 9 | "source": [ 10 | "\n", 11 | "import tkinter as tk\n", 12 | "from tkinter import StringVar\n", 13 | "\n", 14 | "root = tk.Tk()\n", 15 | "root.geometry('500x500')\n", 16 | "\n", 17 | "questions = [\"WhICH ONE IS THE OLDER PROGRAMMING LANGUAGE = ?\",\"What is the Capital of Gujarat = ?\",\"Which of the following is FRAMEWORK web development = ?\",\"Which of the following is true for python? = ?\",\"EXTENSION for python = ?\"]\n", 18 | "options = [['PYTHON','HTML','JAVA','CSS','PYTHON'],['MEHSANA','GANDHINAGAR','AHMEDABAD','SURAT','GANDHINAGAR'],\n", 19 | " ['HTML','CSS','ANGULARJS','PHP','ANGULARJS'],['print(\"Hello WORLD\")','program(\"Hello World\")','get(\"Hello world\")','line(\"Hello World)','print(\"Hello WORLD\")'],['.pi','.py','.pie','.o','.py']]\n", 20 | "\n", 21 | "\n", 22 | "frame = tk.Frame(root, padx=10, pady=10,bg='#fff')\n", 23 | "question_label = tk.Label(frame,height=5, width=28,bg='grey',fg=\"#fff\", \n", 24 | " font=('Verdana', 20),wraplength=500)\n", 25 | "\n", 26 | "\n", 27 | "v1 = StringVar(frame)\n", 28 | "v2 = StringVar(frame)\n", 29 | "v3 = StringVar(frame)\n", 30 | "v4 = StringVar(frame)\n", 31 | "\n", 32 | "option1 = tk.Radiobutton(frame, bg=\"#fff\", variable=v1, font=('Verdana', 20),\n", 33 | " command = lambda : checkAnswer(option1))\n", 34 | "option2 = tk.Radiobutton(frame, bg=\"#fff\", variable=v2, font=('Verdana', 20), \n", 35 | " command = lambda : checkAnswer(option2))\n", 36 | "option3 = tk.Radiobutton(frame, bg=\"#fff\", variable=v3, font=('Verdana', 20), \n", 37 | " command = lambda : checkAnswer(option3))\n", 38 | "option4 = tk.Radiobutton(frame, bg=\"#fff\", variable=v4, font=('Verdana', 20), \n", 39 | " command = lambda : checkAnswer(option4))\n", 40 | "\n", 41 | "button_next = tk.Button(frame, text='Next',bg='Orange', font=('Verdana', 20), \n", 42 | " command = lambda : displayNextQuestion())\n", 43 | "\n", 44 | "frame.pack(fill=\"both\", expand=\"true\")\n", 45 | "question_label.grid(row=0, column=0)\n", 46 | "\n", 47 | "option1.grid(sticky= 'W', row=1, column=0)\n", 48 | "option2.grid(sticky= 'W', row=2, column=0)\n", 49 | "option3.grid(sticky= 'W', row=3, column=0)\n", 50 | "option4.grid(sticky= 'W', row=4, column=0)\n", 51 | "\n", 52 | "button_next.grid(row=6, column=0)\n", 53 | "\n", 54 | "\n", 55 | "index = 0\n", 56 | "correct = 0\n", 57 | "\n", 58 | "# create a function to disable radiobuttons\n", 59 | "def disableButtons(state):\n", 60 | " option1['state'] = state\n", 61 | " option2['state'] = state\n", 62 | " option3['state'] = state\n", 63 | " option4['state'] = state\n", 64 | "\n", 65 | "\n", 66 | "# create a function to check the selected answer\n", 67 | "def checkAnswer(radio):\n", 68 | " global correct, index\n", 69 | " \n", 70 | " # the 4th item is the correct answer\n", 71 | " # we will check the user selected answer with the 4th item\n", 72 | " if radio['text'] == options[index][4]:\n", 73 | " correct +=1\n", 74 | "\n", 75 | " index +=1\n", 76 | " disableButtons('disable')\n", 77 | "\n", 78 | "\n", 79 | "# create a function to display the next question\n", 80 | "def displayNextQuestion():\n", 81 | " global index, correct\n", 82 | "\n", 83 | " if button_next['text'] == 'Restart The Quiz':\n", 84 | " correct = 0\n", 85 | " index = 0\n", 86 | " question_label['bg'] = 'grey'\n", 87 | " button_next['text'] = 'Next'\n", 88 | "\n", 89 | " if index == len(options):\n", 90 | " question_label['text'] = str(correct) + \" / \" + str(len(options))\n", 91 | " button_next['text'] = 'Restart The Quiz'\n", 92 | " if correct >= len(options)/2:\n", 93 | " question_label['bg'] = 'green'\n", 94 | " else:\n", 95 | " question_label['bg'] = 'red'\n", 96 | "\n", 97 | "\n", 98 | "\n", 99 | "\n", 100 | "\n", 101 | " else:\n", 102 | " question_label['text'] = questions[index]\n", 103 | " \n", 104 | " disableButtons('normal')\n", 105 | " opts = options[index]\n", 106 | " option1['text'] = opts[0]\n", 107 | " option2['text'] = opts[1]\n", 108 | " option3['text'] = opts[2]\n", 109 | " option4['text'] = opts[3]\n", 110 | " v1.set(opts[0])\n", 111 | " v2.set(opts[1])\n", 112 | " v3.set(opts[2])\n", 113 | " v4.set(opts[3])\n", 114 | "\n", 115 | " if index == len(options) - 1:\n", 116 | " button_next['text'] = 'Check the Results'\n", 117 | "\n", 118 | "\n", 119 | "\n", 120 | "\n", 121 | "\n", 122 | "displayNextQuestion()\n", 123 | "\n", 124 | "root.mainloop()" 125 | ] 126 | }, 127 | { 128 | "cell_type": "code", 129 | "execution_count": null, 130 | "id": "084032f7", 131 | "metadata": {}, 132 | "outputs": [], 133 | "source": [] 134 | } 135 | ], 136 | "metadata": { 137 | "kernelspec": { 138 | "display_name": "Python 3 (ipykernel)", 139 | "language": "python", 140 | "name": "python3" 141 | }, 142 | "language_info": { 143 | "codemirror_mode": { 144 | "name": "ipython", 145 | "version": 3 146 | }, 147 | "file_extension": ".py", 148 | "mimetype": "text/x-python", 149 | "name": "python", 150 | "nbconvert_exporter": "python", 151 | "pygments_lexer": "ipython3", 152 | "version": "3.9.13" 153 | } 154 | }, 155 | "nbformat": 4, 156 | "nbformat_minor": 5 157 | } 158 | -------------------------------------------------------------------------------- /CODSOFT password Generator.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "id": "e69cc1bc", 7 | "metadata": {}, 8 | "outputs": [], 9 | "source": [ 10 | "\n", 11 | "import tkinter as tk\n", 12 | "from tkinter import messagebox\n", 13 | "import random\n", 14 | "import string\n", 15 | "\n", 16 | "\n", 17 | "entry_username = None\n", 18 | "entry_password_length = None\n", 19 | "entry_generated_password = None\n", 20 | "\n", 21 | "def generate_password():\n", 22 | " global entry_generated_password\n", 23 | " password_length = int(entry_password_length.get())\n", 24 | " if password_length < 8:\n", 25 | " messagebox.showwarning(\"Warning\", \"Password length should be at least 8 characters.\")\n", 26 | " return\n", 27 | "\n", 28 | " characters = string.ascii_letters + string.digits + string.punctuation\n", 29 | " generated_password = ''.join(random.choice(characters) for _ in range(password_length))\n", 30 | " entry_generated_password.delete(0, tk.END)\n", 31 | " entry_generated_password.insert(tk.END, generated_password)\n", 32 | "\n", 33 | "def accept_password():\n", 34 | " global entry_username, entry_generated_password\n", 35 | " username = entry_username.get()\n", 36 | " password = entry_generated_password.get()\n", 37 | " if not username or not password:\n", 38 | " messagebox.showwarning(\"Warning\", \"Please enter username and generate a password.\")\n", 39 | " return\n", 40 | "\n", 41 | "\n", 42 | " messagebox.showinfo(\"Accepted\", f\"Username: {username}\\nPassword: {password}\")\n", 43 | "\n", 44 | "def reset_fields():\n", 45 | " global entry_username, entry_password_length, entry_generated_password\n", 46 | " entry_username.delete(0, tk.END)\n", 47 | " entry_password_length.delete(0, tk.END)\n", 48 | " entry_generated_password.delete(0, tk.END)\n", 49 | "\n", 50 | "def main():\n", 51 | " global entry_username, entry_password_length, entry_generated_password\n", 52 | " root = tk.Tk()\n", 53 | " root.title(\"Password Generator\")\n", 54 | "\n", 55 | "\n", 56 | " heading_label = tk.Label(root, text=\"Password Generator\", font=(\"Helvetica\", 16, \"bold\"))\n", 57 | " heading_label.grid(row=0, column=0, columnspan=3, pady=20)\n", 58 | "\n", 59 | "\n", 60 | " label_username = tk.Label(root, text=\"Enter Username:\")\n", 61 | " label_username.grid(row=1, column=0, sticky=tk.E)\n", 62 | "\n", 63 | " entry_username = tk.Entry(root, width=30)\n", 64 | " entry_username.grid(row=1, column=1, columnspan=2)\n", 65 | "\n", 66 | "\n", 67 | " label_password_length = tk.Label(root, text=\"Enter Password Length:\")\n", 68 | " label_password_length.grid(row=2, column=0, sticky=tk.E)\n", 69 | "\n", 70 | " entry_password_length = tk.Entry(root, width=10)\n", 71 | " entry_password_length.grid(row=2, column=1)\n", 72 | "\n", 73 | "\n", 74 | " label_generated_password = tk.Label(root, text=\"Generated Password:\")\n", 75 | " label_generated_password.grid(row=3, column=0, sticky=tk.E)\n", 76 | "\n", 77 | " entry_generated_password = tk.Entry(root, width=30)\n", 78 | " entry_generated_password.grid(row=3, column=1, columnspan=2)\n", 79 | "\n", 80 | "\n", 81 | " button_generate_password = tk.Button(root, text=\"Generate Password\", command=generate_password)\n", 82 | " button_generate_password.grid(row=4, column=0, padx=5, pady=10)\n", 83 | "\n", 84 | " button_accept_password = tk.Button(root, text=\"Accept\", command=accept_password)\n", 85 | " button_accept_password.grid(row=4, column=1, padx=5, pady=10)\n", 86 | "\n", 87 | " button_reset_fields = tk.Button(root, text=\"Reset\", command=reset_fields)\n", 88 | " button_reset_fields.grid(row=4, column=2, padx=5, pady=10)\n", 89 | "\n", 90 | " root.mainloop()\n", 91 | "\n", 92 | "if __name__ == \"__main__\":\n", 93 | " main()" 94 | ] 95 | }, 96 | { 97 | "cell_type": "code", 98 | "execution_count": null, 99 | "id": "084032f7", 100 | "metadata": {}, 101 | "outputs": [], 102 | "source": [] 103 | } 104 | ], 105 | "metadata": { 106 | "kernelspec": { 107 | "display_name": "Python 3 (ipykernel)", 108 | "language": "python", 109 | "name": "python3" 110 | }, 111 | "language_info": { 112 | "codemirror_mode": { 113 | "name": "ipython", 114 | "version": 3 115 | }, 116 | "file_extension": ".py", 117 | "mimetype": "text/x-python", 118 | "name": "python", 119 | "nbconvert_exporter": "python", 120 | "pygments_lexer": "ipython3", 121 | "version": "3.9.13" 122 | } 123 | }, 124 | "nbformat": 4, 125 | "nbformat_minor": 5 126 | } 127 | -------------------------------------------------------------------------------- /To do task.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 4, 6 | "id": "80ba0999", 7 | "metadata": {}, 8 | "outputs": [], 9 | "source": [ 10 | "import tkinter as tk\n", 11 | "from tkinter import *\n", 12 | "from tkinter import messagebox\n", 13 | "\n", 14 | "tasks = []\n", 15 | "\n", 16 | "\n", 17 | "def add_task():\n", 18 | " task = task_entry.get()\n", 19 | " if task:\n", 20 | " tasks.append(task)\n", 21 | " task_listbox.insert(tk.END, task)\n", 22 | " task_entry.delete(0, tk.END)\n", 23 | " else:\n", 24 | " messagebox.showwarning(\"Empty Task\", \"Please enter a task.\")\n", 25 | "\n", 26 | "\n", 27 | "def update_task():\n", 28 | " selected_task = task_listbox.curselection()\n", 29 | " if selected_task:\n", 30 | " new_task = task_entry.get()\n", 31 | " tasks[selected_task[0]] = new_task\n", 32 | " task_listbox.delete(selected_task)\n", 33 | " task_listbox.insert(selected_task, new_task)\n", 34 | " task_entry.delete(0, tk.END)\n", 35 | " else:\n", 36 | " messagebox.showwarning(\"No Task Selected\", \"Please select a task to update.\")\n", 37 | "\n", 38 | "\n", 39 | "def delete_task():\n", 40 | " selected_task = task_listbox.curselection()\n", 41 | " if selected_task:\n", 42 | " tasks.pop(selected_task[0])\n", 43 | " task_listbox.delete(selected_task)\n", 44 | " else:\n", 45 | " messagebox.showwarning(\"No Task Selected\", \"Please select a task to delete.\")\n", 46 | "\n", 47 | "\n", 48 | "# Create the main window\n", 49 | "root = tk.Tk()\n", 50 | "root.title(\"ToDo List\")\n", 51 | "root.configure(background='lightblue')\n", 52 | "root.geometry('280x380')\n", 53 | "\n", 54 | "lbl = Label(root, text='Enter Task:')\n", 55 | "lbl.grid(row=0, column=0, pady=(15, 5))\n", 56 | "lbl.configure(bg='lightblue', font=('verdana', 12, 'bold'))\n", 57 | "\n", 58 | "# Create and configure the task entry widget\n", 59 | "task_entry = tk.Entry(root, width=40, border=2)\n", 60 | "task_entry.grid(row=2, column=0, padx=20, pady=(3, 15))\n", 61 | "\n", 62 | "# Create and configure the buttons\n", 63 | "add_button = tk.Button(root, text=\"Add\", command=add_task)\n", 64 | "add_button.grid(row=5, column=0, sticky='w', padx=(50, 0), ipadx=9, ipady=1)\n", 65 | "add_button.config(bg='sky blue', font=('none', 10, 'bold'))\n", 66 | "\n", 67 | "update_button = tk.Button(root, text=\"Update \", command=update_task)\n", 68 | "update_button.grid(row=5, column=0, sticky='e', padx=(0, 50), ipady=1)\n", 69 | "update_button.config(bg='sky blue', font=('none', 10, 'bold'),)\n", 70 | "\n", 71 | "delete_button = tk.Button(root, text=\"Delete \", command=delete_task)\n", 72 | "delete_button.grid(row=9, column=0, pady=(10, 0), ipadx=7, ipady=1)\n", 73 | "delete_button.config(bg='sky blue', font=('none', 10, 'bold'))\n", 74 | "\n", 75 | "lbl = Label(root, text='List:')\n", 76 | "lbl.grid(row=7, column=0, pady=(15, 0))\n", 77 | "lbl.configure(bg='lightblue', font=('verdana', 12, 'bold'))\n", 78 | "\n", 79 | "# Create and configure the task listbox widget\n", 80 | "task_listbox = tk.Listbox(root, width=40)\n", 81 | "task_listbox.grid(row=8, column=0)\n", 82 | "\n", 83 | "# Start the main event loop\n", 84 | "root.mainloop()" 85 | ] 86 | }, 87 | { 88 | "cell_type": "code", 89 | "execution_count": null, 90 | "id": "55c39fb9", 91 | "metadata": {}, 92 | "outputs": [], 93 | "source": [] 94 | }, 95 | { 96 | "cell_type": "code", 97 | "execution_count": null, 98 | "id": "9413dc4e", 99 | "metadata": {}, 100 | "outputs": [], 101 | "source": [] 102 | } 103 | ], 104 | "metadata": { 105 | "kernelspec": { 106 | "display_name": "Python 3 (ipykernel)", 107 | "language": "python", 108 | "name": "python3" 109 | }, 110 | "language_info": { 111 | "codemirror_mode": { 112 | "name": "ipython", 113 | "version": 3 114 | }, 115 | "file_extension": ".py", 116 | "mimetype": "text/x-python", 117 | "name": "python", 118 | "nbconvert_exporter": "python", 119 | "pygments_lexer": "ipython3", 120 | "version": "3.9.13" 121 | } 122 | }, 123 | "nbformat": 4, 124 | "nbformat_minor": 5 125 | } 126 | --------------------------------------------------------------------------------