├── Basics of python.ipynb ├── Calculator.py ├── Contact.py ├── IterateArray1.java ├── Rockpaperscissor.py ├── Todolist.py └── password.py /Basics of python.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "provenance": [], 7 | "authorship_tag": "ABX9TyOkl3fScg8CsLS5t7O2CM40", 8 | "include_colab_link": true 9 | }, 10 | "kernelspec": { 11 | "name": "python3", 12 | "display_name": "Python 3" 13 | }, 14 | "language_info": { 15 | "name": "python" 16 | } 17 | }, 18 | "cells": [ 19 | { 20 | "cell_type": "markdown", 21 | "metadata": { 22 | "id": "view-in-github", 23 | "colab_type": "text" 24 | }, 25 | "source": [ 26 | "\"Open" 27 | ] 28 | }, 29 | { 30 | "cell_type": "markdown", 31 | "source": [ 32 | "Programming Languages used for Machine Learning\n", 33 | "1. Python\n", 34 | "2. R" 35 | ], 36 | "metadata": { 37 | "id": "O7EYOPb8ktVU" 38 | } 39 | }, 40 | { 41 | "cell_type": "markdown", 42 | "source": [ 43 | "#Print Functions\n" 44 | ], 45 | "metadata": { 46 | "id": "OikutXSRlva3" 47 | } 48 | }, 49 | { 50 | "cell_type": "code", 51 | "source": [ 52 | "print(\"Machine Learning\")" 53 | ], 54 | "metadata": { 55 | "colab": { 56 | "base_uri": "https://localhost:8080/" 57 | }, 58 | "id": "7cNS9_-0kxqM", 59 | "outputId": "0fb34e47-62a7-404c-ad9c-ba80dda5bd48" 60 | }, 61 | "execution_count": 4, 62 | "outputs": [ 63 | { 64 | "output_type": "stream", 65 | "name": "stdout", 66 | "text": [ 67 | "Machine Learning\n" 68 | ] 69 | } 70 | ] 71 | }, 72 | { 73 | "cell_type": "code", 74 | "source": [ 75 | "print(\"Machine Learning\" + \" Projects\")" 76 | ], 77 | "metadata": { 78 | "colab": { 79 | "base_uri": "https://localhost:8080/" 80 | }, 81 | "id": "s97ZiqsplCir", 82 | "outputId": "fa523bc7-2db1-4c35-d749-54485986cb1a" 83 | }, 84 | "execution_count": 6, 85 | "outputs": [ 86 | { 87 | "output_type": "stream", 88 | "name": "stdout", 89 | "text": [ 90 | "Machine Learning Projects\n" 91 | ] 92 | } 93 | ] 94 | }, 95 | { 96 | "cell_type": "code", 97 | "source": [ 98 | "print(8+3)" 99 | ], 100 | "metadata": { 101 | "colab": { 102 | "base_uri": "https://localhost:8080/" 103 | }, 104 | "id": "2LkKjA5PlP31", 105 | "outputId": "2d499654-8547-4081-f111-950422fca29d" 106 | }, 107 | "execution_count": 7, 108 | "outputs": [ 109 | { 110 | "output_type": "stream", 111 | "name": "stdout", 112 | "text": [ 113 | "11\n" 114 | ] 115 | } 116 | ] 117 | }, 118 | { 119 | "cell_type": "markdown", 120 | "source": [ 121 | "#BASIC DATA TYPES\n", 122 | "1.int\n", 123 | "2.str\n", 124 | "3.float" 125 | ], 126 | "metadata": { 127 | "id": "l7EbW3vCm_AC" 128 | } 129 | }, 130 | { 131 | "cell_type": "code", 132 | "source": [ 133 | "type(5)" 134 | ], 135 | "metadata": { 136 | "colab": { 137 | "base_uri": "https://localhost:8080/" 138 | }, 139 | "id": "vybDnma-mCmJ", 140 | "outputId": "b04bf1fa-d218-44d4-8ef3-6bebc2a7c0b6" 141 | }, 142 | "execution_count": 9, 143 | "outputs": [ 144 | { 145 | "output_type": "execute_result", 146 | "data": { 147 | "text/plain": [ 148 | "int" 149 | ] 150 | }, 151 | "metadata": {}, 152 | "execution_count": 9 153 | } 154 | ] 155 | }, 156 | { 157 | "cell_type": "code", 158 | "source": [ 159 | "type(\"hi\")" 160 | ], 161 | "metadata": { 162 | "colab": { 163 | "base_uri": "https://localhost:8080/" 164 | }, 165 | "id": "8Lvzq-qbmPrI", 166 | "outputId": "357ef1eb-c839-452d-81d8-7e9219719a3c" 167 | }, 168 | "execution_count": 11, 169 | "outputs": [ 170 | { 171 | "output_type": "execute_result", 172 | "data": { 173 | "text/plain": [ 174 | "str" 175 | ] 176 | }, 177 | "metadata": {}, 178 | "execution_count": 11 179 | } 180 | ] 181 | }, 182 | { 183 | "cell_type": "code", 184 | "source": [ 185 | "type(9.0)" 186 | ], 187 | "metadata": { 188 | "colab": { 189 | "base_uri": "https://localhost:8080/" 190 | }, 191 | "id": "sgkGQl-tmUB6", 192 | "outputId": "37032118-ed60-4816-ffb6-f9a77b0542e3" 193 | }, 194 | "execution_count": 12, 195 | "outputs": [ 196 | { 197 | "output_type": "execute_result", 198 | "data": { 199 | "text/plain": [ 200 | "float" 201 | ] 202 | }, 203 | "metadata": {}, 204 | "execution_count": 12 205 | } 206 | ] 207 | }, 208 | { 209 | "cell_type": "markdown", 210 | "source": [ 211 | "#CONSTANTS & VARIABLES" 212 | ], 213 | "metadata": { 214 | "id": "WgDcnL4fnJeM" 215 | } 216 | }, 217 | { 218 | "cell_type": "code", 219 | "source": [ 220 | "a= \"python\"\n", 221 | "print(a)" 222 | ], 223 | "metadata": { 224 | "colab": { 225 | "base_uri": "https://localhost:8080/" 226 | }, 227 | "id": "oIrm9yoGmh_Z", 228 | "outputId": "78abc7ac-1796-4ebb-e66d-b407ecc8fa13" 229 | }, 230 | "execution_count": 13, 231 | "outputs": [ 232 | { 233 | "output_type": "stream", 234 | "name": "stdout", 235 | "text": [ 236 | "python\n" 237 | ] 238 | } 239 | ] 240 | }, 241 | { 242 | "cell_type": "code", 243 | "source": [ 244 | "hero1 , hero2 , hero3 = \"Iron Man\" , \"Captain America\" , \"Bat Man\"\n", 245 | "print(hero1)\n", 246 | "print(hero2)\n", 247 | "print(hero3)" 248 | ], 249 | "metadata": { 250 | "colab": { 251 | "base_uri": "https://localhost:8080/" 252 | }, 253 | "id": "WRM-BJ_knUx9", 254 | "outputId": "0a7f3c59-eecd-4666-eb2d-09e5b5fc6c12" 255 | }, 256 | "execution_count": 16, 257 | "outputs": [ 258 | { 259 | "output_type": "stream", 260 | "name": "stdout", 261 | "text": [ 262 | "Iron Man\n", 263 | "Captain America\n", 264 | "Bat Man\n" 265 | ] 266 | } 267 | ] 268 | }, 269 | { 270 | "cell_type": "code", 271 | "source": [ 272 | "x = y = z = 32\n", 273 | "print(x)\n", 274 | "print(y)\n", 275 | "print(z)" 276 | ], 277 | "metadata": { 278 | "colab": { 279 | "base_uri": "https://localhost:8080/" 280 | }, 281 | "id": "Yub1Xm8En4ms", 282 | "outputId": "589892be-2765-4b60-f685-e1075e10793c" 283 | }, 284 | "execution_count": 17, 285 | "outputs": [ 286 | { 287 | "output_type": "stream", 288 | "name": "stdout", 289 | "text": [ 290 | "32\n", 291 | "32\n", 292 | "32\n" 293 | ] 294 | } 295 | ] 296 | }, 297 | { 298 | "cell_type": "markdown", 299 | "source": [ 300 | "#INPUT FUNCTION" 301 | ], 302 | "metadata": { 303 | "id": "j95qQiGkoZh6" 304 | } 305 | }, 306 | { 307 | "cell_type": "code", 308 | "source": [ 309 | "number_1 = int(input(\"enter the first number:\"))\n", 310 | "number_2 = int(input(\"enter the second number:\"))\n", 311 | "sum = number_1 + number_2\n", 312 | "print(sum)" 313 | ], 314 | "metadata": { 315 | "colab": { 316 | "base_uri": "https://localhost:8080/" 317 | }, 318 | "id": "x7KMykSyocjG", 319 | "outputId": "3aa23399-b442-41e2-9aee-eccdc86fdb9e" 320 | }, 321 | "execution_count": 21, 322 | "outputs": [ 323 | { 324 | "output_type": "stream", 325 | "name": "stdout", 326 | "text": [ 327 | "enter the first number:12\n", 328 | "enter the second number:21\n", 329 | "33\n" 330 | ] 331 | } 332 | ] 333 | }, 334 | { 335 | "cell_type": "markdown", 336 | "source": [ 337 | "#CHANGING DATA TYPES" 338 | ], 339 | "metadata": { 340 | "id": "IOzGWJIspNUo" 341 | } 342 | }, 343 | { 344 | "cell_type": "code", 345 | "source": [ 346 | "num = 5\n", 347 | "float(num)" 348 | ], 349 | "metadata": { 350 | "colab": { 351 | "base_uri": "https://localhost:8080/" 352 | }, 353 | "id": "9zEzQ7AvpQSR", 354 | "outputId": "a2da6124-2d4a-4011-fdf0-f305f5aa8cc5" 355 | }, 356 | "execution_count": 22, 357 | "outputs": [ 358 | { 359 | "output_type": "execute_result", 360 | "data": { 361 | "text/plain": [ 362 | "5.0" 363 | ] 364 | }, 365 | "metadata": {}, 366 | "execution_count": 22 367 | } 368 | ] 369 | }, 370 | { 371 | "cell_type": "markdown", 372 | "source": [], 373 | "metadata": { 374 | "id": "MmleLZDupu6s" 375 | } 376 | }, 377 | { 378 | "cell_type": "markdown", 379 | "source": [ 380 | "#Basic Data Types\n", 381 | "1.integer\n", 382 | "2.floating point\n", 383 | "3.complex\n", 384 | "4.boolean\n", 385 | "5.string" 386 | ], 387 | "metadata": { 388 | "id": "wTWUe-Bgp3Kj" 389 | } 390 | }, 391 | { 392 | "cell_type": "code", 393 | "source": [ 394 | "#integers\n", 395 | "a = 8\n", 396 | "print(a)" 397 | ], 398 | "metadata": { 399 | "colab": { 400 | "base_uri": "https://localhost:8080/" 401 | }, 402 | "id": "72AhPFcLpz7b", 403 | "outputId": "42cce2db-7455-4c0e-a917-321b015b2724" 404 | }, 405 | "execution_count": 23, 406 | "outputs": [ 407 | { 408 | "output_type": "stream", 409 | "name": "stdout", 410 | "text": [ 411 | "8\n" 412 | ] 413 | } 414 | ] 415 | }, 416 | { 417 | "cell_type": "code", 418 | "source": [], 419 | "metadata": { 420 | "id": "03hG5KMrpsK1" 421 | }, 422 | "execution_count": null, 423 | "outputs": [] 424 | } 425 | ] 426 | } -------------------------------------------------------------------------------- /Calculator.py: -------------------------------------------------------------------------------- 1 | def addition(n1, n2): 2 | return n1 + n2 3 | def subtraction(n1, n2): 4 | return n1 - n2 5 | def multiplication(n1, n2): 6 | return n1 * n2 7 | def division(n1, n2): 8 | return n1 / n2 9 | print("Select Operations") 10 | print( 11 | "1. Addition\n" 12 | "2. Subtraction\n" 13 | "3. Multiplication\n" 14 | "4. Division\n") 15 | operation = int(input("Enter choice of operation 1/2/3/4: ")) 16 | n1 = float(input("Enter the First Number: ")) 17 | n2 = float(input("Enter the Second Number: ")) 18 | if operation == 1: 19 | print (n1, "+", n2, "=", addition(n1, n2)) 20 | elif operation == 2: 21 | print (n1, "-", n2, "=", subtraction(n1, n2)) 22 | elif operation == 3: 23 | print (n1, "*", n2, "=", multiplication(n1, n2)) 24 | elif operation == 4: 25 | print (n1, "/", n2, "=", division(n1, n2)) 26 | else: 27 | print("Invalid Input") 28 | -------------------------------------------------------------------------------- /Contact.py: -------------------------------------------------------------------------------- 1 | class Contact: 2 | def __init__(self, name, phone, email, address): 3 | self.name = name 4 | self.phone = phone 5 | self.email = email 6 | self.address = address 7 | 8 | class ContactBook: 9 | def __init__(self): 10 | self.contacts = [] 11 | 12 | def add_contact(self, contact): 13 | self.contacts.append(contact) 14 | 15 | def view_contacts(self): 16 | if not self.contacts: 17 | print("No contacts found.") 18 | else: 19 | for index, contact in enumerate(self.contacts, start=1): 20 | print(f"{index}. Name: {contact.name}, Phone: {contact.phone}") 21 | 22 | def search_contact(self, query): 23 | found_contacts = [] 24 | for contact in self.contacts: 25 | if query.lower() in contact.name.lower() or query in contact.phone: 26 | found_contacts.append(contact) 27 | if not found_contacts: 28 | print("No matching contacts found.") 29 | else: 30 | for contact in found_contacts: 31 | print(f"Name: {contact.name}, Phone: {contact.phone}, Email: {contact.email}, Address: {contact.address}") 32 | 33 | def update_contact(self, index, new_contact): 34 | if 0 < index <= len(self.contacts): 35 | self.contacts[index - 1] = new_contact 36 | print("Contact updated successfully.") 37 | else: 38 | print("Invalid contact index.") 39 | 40 | def delete_contact(self, index): 41 | if 0 < index <= len(self.contacts): 42 | del self.contacts[index - 1] 43 | print("Contact deleted successfully.") 44 | else: 45 | print("Invalid contact index.") 46 | 47 | def main(): 48 | contact_book = ContactBook() 49 | 50 | while True: 51 | print("\nContact Book Menu:") 52 | print("1. Add Contact") 53 | print("2. View Contact List") 54 | print("3. Search Contact") 55 | print("4. Update Contact") 56 | print("5. Delete Contact") 57 | print("6. Exit") 58 | 59 | choice = input("Enter your choice: ") 60 | 61 | if choice == "1": 62 | name = input("Enter name: ") 63 | phone = input("Enter phone number: ") 64 | email = input("Enter email: ") 65 | address = input("Enter address: ") 66 | contact_book.add_contact(Contact(name, phone, email, address)) 67 | print("Contact added successfully.") 68 | 69 | elif choice == "2": 70 | print("\nContact List:") 71 | contact_book.view_contacts() 72 | 73 | elif choice == "3": 74 | query = input("Enter name or phone number to search: ") 75 | contact_book.search_contact(query) 76 | 77 | elif choice == "4": 78 | index = int(input("Enter the index of the contact to update: ")) 79 | if 0 < index <= len(contact_book.contacts): 80 | name = input("Enter new name: ") 81 | phone = input("Enter new phone number: ") 82 | email = input("Enter new email: ") 83 | address = input("Enter new address: ") 84 | contact_book.update_contact(index, Contact(name, phone, email, address)) 85 | else: 86 | print("Invalid contact index.") 87 | 88 | elif choice == "5": 89 | index = int(input("Enter the index of the contact to delete: ")) 90 | contact_book.delete_contact(index) 91 | 92 | elif choice == "6": 93 | print("Exiting...") 94 | break 95 | 96 | else: 97 | print("Invalid choice. Please try again.") 98 | 99 | if __name__ == "__main__": 100 | main() 101 | -------------------------------------------------------------------------------- /IterateArray1.java: -------------------------------------------------------------------------------- 1 | class IterateArray1 { 2 | public static void main(String args[]) { 3 | int[] arr={1,2,3,4,5,6,7}; 4 | ComArray co=new ComArray(); 5 | for(int l:co.arr3) { 6 | System.out.println(l); 7 | } 8 | ComArray.main(null); 9 | System.out.println("elements are:"); 10 | for(int i=0;i Paper wins \n" 5 | 6 | + "Rock vs Scissors -> Rock wins \n" 7 | 8 | + "Paper vs Scissors -> Scissor wins \n") 9 | 10 | 11 | while True: 12 | print("Enter your choice \n 1 - Rock \n 2 - Paper \n 3 - Scissors \n") 13 | choice=int(input("Enter your choice :")) 14 | while choice > 3 or choice <1: 15 | choice=int(input('Enter a valid choice please ☺')) 16 | if choice == 1: 17 | choice_name= 'Rock' 18 | 19 | elif choice == 2: 20 | choice_name= 'Paper' 21 | 22 | else: 23 | choice_name= 'Scissors' 24 | 25 | print('User choice is \n',choice_name) 26 | 27 | print('Now its Computers Turn....') 28 | 29 | comp_choice = random.randint(1,3) 30 | 31 | while comp_choice == choice: 32 | 33 | comp_choice = random.randint(1,3) 34 | 35 | if comp_choice == 1: 36 | 37 | comp_choice_name = 'rocK' 38 | 39 | elif comp_choice == 2: 40 | 41 | comp_choice_name = 'papeR' 42 | 43 | else: 44 | 45 | comp_choice_name = 'scissoR' 46 | 47 | print("Computer choice is \n", comp_choice_name) 48 | 49 | print(choice_name,'Vs',comp_choice_name) 50 | 51 | if choice == comp_choice: 52 | 53 | print('Its a Draw',end="") 54 | 55 | result="DRAW" 56 | 57 | if (choice==1 and comp_choice==2): 58 | 59 | print('paper wins =>',end="") 60 | 61 | result='papeR' 62 | 63 | elif (choice==2 and comp_choice==1): 64 | 65 | print('paper wins =>',end="") 66 | 67 | result='Paper' 68 | 69 | if (choice==1 and comp_choice==3): 70 | 71 | print('Rock wins =>\n',end= "") 72 | 73 | result='Rock' 74 | 75 | elif (choice==3 and comp_choice==1): 76 | 77 | print('Rock wins =>\n',end= "") 78 | 79 | result='rocK' 80 | 81 | if (choice==2 and comp_choice==3): 82 | 83 | print('Scissors wins =>',end="") 84 | 85 | result='scissoR' 86 | 87 | elif (choice==3 and comp_choice==2): 88 | 89 | print('Scissors wins =>',end="") 90 | 91 | result='Rock' 92 | 93 | if result == 'DRAW': 94 | 95 | print("<== Its a tie ==>") 96 | 97 | if result == choice_name: 98 | 99 | print("<== User wins ==>") 100 | 101 | else: 102 | 103 | print("<== Computer wins ==>") 104 | 105 | print("Do you want to play again? (Y/N)") 106 | 107 | ans = input().lower() 108 | 109 | if ans =='n': 110 | 111 | break 112 | 113 | print("thanks for playing") 114 | -------------------------------------------------------------------------------- /Todolist.py: -------------------------------------------------------------------------------- 1 | class ToDoList: 2 | def __init__(self): 3 | self.tasks = [] 4 | 5 | def add_task(self, task): 6 | self.tasks.append(task) 7 | print(f"Task '{task}' added to the list.") 8 | 9 | def remove_task(self, task): 10 | if task in self.tasks: 11 | self.tasks.remove(task) 12 | print(f"Task '{task}' removed from the list.") 13 | else: 14 | print(f"Task '{task}' not found in the list.") 15 | 16 | def update_task(self, old_task, new_task): 17 | if old_task in self.tasks: 18 | index = self.tasks.index(old_task) 19 | self.tasks[index] = new_task 20 | print(f"Task '{old_task}' updated to '{new_task}'.") 21 | else: 22 | print(f"Task '{old_task}' not found in the list.") 23 | 24 | def display_tasks(self): 25 | if self.tasks: 26 | print("Tasks in the list:") 27 | for i, task in enumerate(self.tasks, start=1): 28 | print(f"{i}. {task}") 29 | else: 30 | print("No tasks in the list.") 31 | 32 | def main(): 33 | todo_list = ToDoList() 34 | 35 | while True: 36 | print("\nTo-Do List Application") 37 | print("1. Add Task") 38 | print("2. Remove Task") 39 | print("3. Update Task") 40 | print("4. Display Tasks") 41 | print("5. Exit") 42 | 43 | choice = input("Enter your choice (1/2/3/4/5): ") 44 | 45 | if choice == '1': 46 | task = input("Enter the task: ") 47 | todo_list.add_task(task) 48 | elif choice == '2': 49 | task = input("Enter the task to remove: ") 50 | todo_list.remove_task(task) 51 | elif choice == '3': 52 | old_task = input("Enter the task to update: ") 53 | new_task = input("Enter the new task description: ") 54 | todo_list.update_task(old_task, new_task) 55 | elif choice == '4': 56 | todo_list.display_tasks() 57 | elif choice == '5': 58 | print("Exiting the application. Goodbye!") 59 | break 60 | else: 61 | print("Invalid choice. Please select a valid option.") 62 | 63 | if __name__ == "__main__": 64 | main() 65 | -------------------------------------------------------------------------------- /password.py: -------------------------------------------------------------------------------- 1 | import string 2 | import random 3 | length = int(input("Enter password length: ")) 4 | 5 | print('''Choose character set for password from these : 6 | 7 | 1. Digits 8 | 9 | 2. Letters 10 | 11 | 3. Special characters 12 | 13 | 4. Exit''') 14 | characterList = "" 15 | while(True): 16 | choice = int(input("Pick a number ")) 17 | if(choice == 1): 18 | characterList += string.ascii_letters 19 | elif(choice == 2): 20 | characterList += string.digits 21 | elif(choice == 3): 22 | characterList += string.punctuation 23 | elif(choice == 4): 24 | break 25 | else: 26 | print("Please pick a valid option!") 27 | password = [] 28 | for i in range(length): 29 | randomchar = random.choice(characterList) 30 | password.append(randomchar) 31 | 32 | print("The random password is " + "".join(password)) 33 | --------------------------------------------------------------------------------