├── 001_Python_Final_Assignment.ipynb ├── 001_Python_HW_Assignment_01.ipynb ├── 002_Python_HW_Assignment_02.ipynb ├── 003_Python_HW_Assignment_03.ipynb ├── 004_Python_HW_Assignment_04.ipynb ├── 005_Python_HW_Assignment_05.ipynb ├── 006_Python_HW_Assignment_06.ipynb ├── README.md ├── happynumbers1_1000.txt ├── nameslist.txt ├── primenumbers1_1000.txt └── sowpods.txt /001_Python_Final_Assignment.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "         **JLUFE**                                   **Fall 2021(Sep-Jan)** \n", 8 | "\n", 9 | "\n", 10 | "**
Final Assignment Report
**\n", 11 | "
\n", 12 | "\n", 13 | "**
JILIN UNIVERSITY OF FINANCE AND ECONOMICS
**\n", 14 | "
\n", 15 | "\n", 16 | "**
College of Managment Science and Information Engineering
**\n", 17 | "\n", 18 | "**
BSc in Data Science and Big Data Technology
**\n", 19 | "\n", 20 | "**
(2021)
**\n", 21 | "\n", 22 | "
\n", 23 | "\n", 24 | "**
MODULE: Intelligent Technology
**\n", 25 | "\n", 26 | "**
Final Assignment
**\n", 27 | "\n", 28 | "
\n", 29 | "\n", 30 | "**
20/12/2021
**\n", 31 | "\n", 32 | "\n", 33 | "\n", 34 | "**
Submitted by:
**\n", 35 | "\n", 36 | "**
Milan(米兰) 0318021907632 (2005)
**\n", 37 | "**
QQ: 3086215265 | Github ID: milaan9
**" 38 | ] 39 | }, 40 | { 41 | "cell_type": "markdown", 42 | "metadata": {}, 43 | "source": [ 44 | "# Instructions: \n", 45 | "\n", 46 | "\n", 47 | "1. I have added tips and required learning resources for each question, which helps you to solve the problems. \n", 48 | "\n", 49 | "2. Finish the assignment on your **OWN**. **Any student find copying/sharing from classmates or internet will get '0' points!!!**\n", 50 | "\n", 51 | "3. Accept this assignment from ➞ **[GitHub Clasroom link](https://classroom.github.com/a/KX_0SzHL)**. This will create private repository of the assignment in your GitHub Clasroom account.\n", 52 | "\n", 53 | "4. In your repository CloneDownload ZIP in your computer.\n", 54 | "\n", 55 | "5. Change your ➞ **Major**, **Name**, **Student number**, **Class number**, **QQ number** and **GitHub ID**\n", 56 | "\n", 57 | "6. Once you finish the Assignment **[convert your .ipynb file into PDF](https://github.com/milaan9/91_Python_Mini_Projects/tree/main/001_Convert_IPython_to_PDF)** (both **.ipynb** and **.pdf** file will be required!)\n", 58 | "\n", 59 | "7. To submit your assignment, go to GitHub Classrom repository and Add fileUpload filesCommit changes\n", 60 | " 1. Replace the question (**.ipynb**) file with your solution (**.ipynb**) file.\n", 61 | " 2. Also, upload (**.pdf**) converted file of your solution (**.ipynb**) file." 62 | ] 63 | }, 64 | { 65 | "cell_type": "markdown", 66 | "metadata": {}, 67 | "source": [ 68 | "# Python Final Assignment" 69 | ] 70 | }, 71 | { 72 | "cell_type": "markdown", 73 | "metadata": {}, 74 | "source": [ 75 | "### Question 1: \n", 76 | "\n", 77 | "Write a python program to create a 3x3 matrix with values ranging from 12 to 20\n", 78 | "\n", 79 | "Expected Output:\n", 80 | "```\n", 81 | "[[12 13 14]\n", 82 | " [15 16 17]\n", 83 | " [18 19 20]]\n", 84 | "```" 85 | ] 86 | }, 87 | { 88 | "cell_type": "code", 89 | "execution_count": null, 90 | "metadata": {}, 91 | "outputs": [], 92 | "source": [ 93 | "# Solution 1\n", 94 | "\n" 95 | ] 96 | }, 97 | { 98 | "cell_type": "markdown", 99 | "metadata": {}, 100 | "source": [ 101 | "### Question 2: \n", 102 | "\n", 103 | "Write a python program to find the gravitational force acting between two objects.\n", 104 | "\n", 105 | "\\begin{equation*}\n", 106 | "F=G\\frac{{m_1}{m_2}}{{r^2}}\n", 107 | "\\end{equation*}\n", 108 | "\n", 109 | "Expected Output:\n", 110 | "```\n", 111 | "Enter the first mass (m1): 7000000\n", 112 | "Enter the second mass (m2): 600000\n", 113 | "Enter the distance between the centres of the masses (N): 16\n", 114 | "Hence, the Gravitational Force is: 1.09 N\n", 115 | "```" 116 | ] 117 | }, 118 | { 119 | "cell_type": "code", 120 | "execution_count": null, 121 | "metadata": {}, 122 | "outputs": [], 123 | "source": [ 124 | "# Solution 2\n", 125 | "\n" 126 | ] 127 | }, 128 | { 129 | "cell_type": "markdown", 130 | "metadata": {}, 131 | "source": [ 132 | "### Question 3: \n", 133 | "\n", 134 | "Write a python program to create a 9x9 array with random values and find the minimum and maximum values\n", 135 | "\n", 136 | "`💡hint: min, max`" 137 | ] 138 | }, 139 | { 140 | "cell_type": "code", 141 | "execution_count": null, 142 | "metadata": {}, 143 | "outputs": [], 144 | "source": [ 145 | "# Solution 3\n", 146 | "\n" 147 | ] 148 | }, 149 | { 150 | "cell_type": "markdown", 151 | "metadata": {}, 152 | "source": [ 153 | "### Question 4: \n", 154 | "\n", 155 | "Write a python program that generates a list containing only common elements between the two randomly generated lists (without duplicates). Make sure your program works on two lists of different sizes.\n", 156 | "\n", 157 | "Expected Output:\n", 158 | "```\n", 159 | "List 1: [0, 2, 4, 6, 12, 13, 14, 18, 20, 24, 25, 26, 27]\n", 160 | "List 2: [0, 4, 7, 9, 10, 11, 13, 14, 17, 18, 20,]\n", 161 | "List of common elements are: [0, 4, 13, 14, 18, 20]\n", 162 | "```" 163 | ] 164 | }, 165 | { 166 | "cell_type": "code", 167 | "execution_count": null, 168 | "metadata": {}, 169 | "outputs": [], 170 | "source": [ 171 | "# Solution 4\n", 172 | "\n" 173 | ] 174 | }, 175 | { 176 | "cell_type": "markdown", 177 | "metadata": {}, 178 | "source": [ 179 | "### Question 5: \n", 180 | "\n", 181 | "Write a python program that asks the user **reverse** of last 2 digit of (your) student number and generates Fibonacci series.\n", 182 | "\n", 183 | "Expected Output:\n", 184 | "```\n", 185 | "Last two numbers of my student number: 21\n", 186 | "How many numbers that generates?: 12\n", 187 | "Fibonacci series:\n", 188 | " [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144]\n", 189 | "```" 190 | ] 191 | }, 192 | { 193 | "cell_type": "code", 194 | "execution_count": null, 195 | "metadata": {}, 196 | "outputs": [], 197 | "source": [ 198 | "# Solution 5\n", 199 | "\n" 200 | ] 201 | }, 202 | { 203 | "cell_type": "markdown", 204 | "metadata": {}, 205 | "source": [ 206 | "### Question 6:\n", 207 | "\n", 208 | "Generate solution by asking the user what size game board they want to draw, and draw it for them to the screen using Python's print statement.\n", 209 | "\n", 210 | "Expected Output:\n", 211 | "```\n", 212 | "Enter the size of board you want to draw: 4\n", 213 | " --- --- --- ---\n", 214 | "| | | | | \n", 215 | " --- --- --- ---\n", 216 | "| | | | | \n", 217 | " --- --- --- ---\n", 218 | "| | | | | \n", 219 | " --- --- --- ---\n", 220 | "| | | | | \n", 221 | " --- --- --- ---\n", 222 | "```" 223 | ] 224 | }, 225 | { 226 | "cell_type": "code", 227 | "execution_count": null, 228 | "metadata": {}, 229 | "outputs": [], 230 | "source": [ 231 | "# Solution 6\n", 232 | "\n" 233 | ] 234 | }, 235 | { 236 | "cell_type": "markdown", 237 | "metadata": {}, 238 | "source": [ 239 | "### Question 7: \n", 240 | "\n", 241 | "Write a python program using function that takes a string and returns the number (count) of vowels contained within it.\n", 242 | "\n", 243 | "Expected Output:\n", 244 | "```\n", 245 | "Enter string: Celebration\n", 246 | "Total vowels in the string: 5\n", 247 | "Identified vowels are: ['e', 'e', 'a', 'i', 'o']\n", 248 | "```\n", 249 | "\n", 250 | "More examples:\n", 251 | "```\n", 252 | "count_vowels(\"Palm\") ➞ 1\n", 253 | "count_vowels(\"Prediction\") ➞ 4\n", 254 | "```" 255 | ] 256 | }, 257 | { 258 | "cell_type": "code", 259 | "execution_count": null, 260 | "metadata": {}, 261 | "outputs": [], 262 | "source": [ 263 | "# Solution 7\n", 264 | "\n" 265 | ] 266 | }, 267 | { 268 | "cell_type": "markdown", 269 | "metadata": {}, 270 | "source": [ 271 | "### Question 8: \n", 272 | "\n", 273 | "Write a python program using function that encrypts a given input with these steps:\n", 274 | "\n", 275 | "Input: \"apple\"\n", 276 | "\n", 277 | "* Step 1: Reverse the input: \"elppa\"\n", 278 | "* Step 2: Replace all vowels using the following chart:\n", 279 | "\n", 280 | "```python\n", 281 | "a => 0\n", 282 | "e => 1\n", 283 | "i => 2\n", 284 | "o => 2\n", 285 | "u => 3\n", 286 | "# 1lpp0\n", 287 | "```\n", 288 | "\n", 289 | "* Step 3: Add \"aca\" to the end of the word: \"1lpp0aca\"\n", 290 | "\n", 291 | "Expected Output:\n", 292 | "```\n", 293 | "Word: apple\n", 294 | "Encrypted word: 1lpp0aca\n", 295 | "```\n", 296 | "\n", 297 | "More Examples:\n", 298 | "```\n", 299 | "encrypt(\"banana\") ➞ \"0n0n0baca\"\n", 300 | "encrypt(\"karaca\") ➞ \"0c0r0kaca\"\n", 301 | "encrypt(\"burak\") ➞ \"k0r3baca\"\n", 302 | "encrypt(\"alpaca\") ➞ \"0c0pl0aca\"\n", 303 | "```" 304 | ] 305 | }, 306 | { 307 | "cell_type": "code", 308 | "execution_count": null, 309 | "metadata": {}, 310 | "outputs": [], 311 | "source": [ 312 | "# Solution 8\n", 313 | "\n" 314 | ] 315 | }, 316 | { 317 | "cell_type": "markdown", 318 | "metadata": {}, 319 | "source": [ 320 | "### Question 9: \n", 321 | "\n", 322 | "Write a python program to generate password. Be creative with how you generate passwords - strong passwords have a mix of lowercase letters, uppercase letters, numbers, and symbols. The passwords should be random, generating a new password every time the user asks for a new password. Include your code in a main method.\n", 323 | "\n", 324 | "Expected Output:\n", 325 | "```\n", 326 | "Please choose strong or weak:\n", 327 | "strong\n", 328 | "password: 3SPk|0}y\n", 329 | "do you want a new password? y/n\n", 330 | "n\n", 331 | "```" 332 | ] 333 | }, 334 | { 335 | "cell_type": "code", 336 | "execution_count": null, 337 | "metadata": {}, 338 | "outputs": [], 339 | "source": [ 340 | "# Solution 9\n", 341 | "\n" 342 | ] 343 | }, 344 | { 345 | "cell_type": "markdown", 346 | "metadata": {}, 347 | "source": [ 348 | "### Question 10: \n", 349 | "\n", 350 | "Write a python program to ask user for a string and then perform following operations:\n", 351 | "1. Calculate the num of digits \n", 352 | "2. Calculate the num of characters \n", 353 | "3. Calculate the num of vowels\n", 354 | "4. Calculate the num of lowercase letters\n", 355 | "5. replace ' ' with '_' in the string\n", 356 | "6. Print and Store the ouput to 'output.txt' file.\n", 357 | "\n", 358 | "Expected Output:\n", 359 | "```\n", 360 | "Enter string: Good Morning 369\n", 361 | "Output printed in'output.txt'\n", 362 | "```\n", 363 | "\n", 364 | "Expected Output in file output.txt:\n", 365 | "```\n", 366 | "The entered string is: Good Morning 369\n", 367 | "The number of digits is: 3\n", 368 | "The number of characters is: 16\n", 369 | "The number of vowels is: 4\n", 370 | "The number of lowercase letters is: 9\n", 371 | "The modified string is: Good_Morning_369\n", 372 | "```" 373 | ] 374 | }, 375 | { 376 | "cell_type": "code", 377 | "execution_count": null, 378 | "metadata": {}, 379 | "outputs": [], 380 | "source": [ 381 | "# Solution 10\n", 382 | "\n" 383 | ] 384 | }, 385 | { 386 | "cell_type": "markdown", 387 | "metadata": {}, 388 | "source": [ 389 | "### Question 11: \n", 390 | "\n", 391 | "Write a python program where user, will have a number in head between 0 and 100. The program will guess a number, and you, the user, will say whether it is too \"high\", too \"low\", or your number. Also, in the end program should print out how many guesses it took to get your number. Refer the Expected output for example.\n", 392 | "\n", 393 | "Expected Output:\n", 394 | "```\n", 395 | "WELCOME TO GUESS ME!\n", 396 | "Let me select a number between 1 and 100\n", 397 | "If your guess is more than 10 away from my number, I'll tell you you're COLD\n", 398 | "If your guess is within 10 of my number, I'll tell you you're WARM\n", 399 | "If your guess is farther than your most recent guess, I'll say you're getting COLDER\n", 400 | "If your guess is closer than your most recent guess, I'll say you're getting WARMER\n", 401 | "LET'S PLAY!\n", 402 | "Make your guess\n", 403 | "5\n", 404 | "WARMER!\n", 405 | "Make your guess\n", 406 | "9\n", 407 | "WARM!\n", 408 | "Make your guess\n", 409 | "3\n", 410 | "WARM!\n", 411 | "Make your guess\n", 412 | "4\n", 413 | "WARM!\n", 414 | "Make your guess\n", 415 | "6\n", 416 | "CONGRATULATIONS!, you guessed the correct answer in 5 attempts.\n", 417 | "```" 418 | ] 419 | }, 420 | { 421 | "cell_type": "code", 422 | "execution_count": null, 423 | "metadata": {}, 424 | "outputs": [], 425 | "source": [ 426 | "# Solution 11\n", 427 | "\n" 428 | ] 429 | }, 430 | { 431 | "cell_type": "markdown", 432 | "metadata": {}, 433 | "source": [ 434 | "### Question 12: \n", 435 | "\n", 436 | "Write a python program using function that picks a random word from a list of words from the **[dictionary](https://github.com/milaan9/JLUFE_Intelligent_Tech_2005-2006/blob/main/sowpods.txt)**. Each line in the file contains a single word.\n", 437 | "\n", 438 | "`💡hint: use the Python random library for picking a random word`\n", 439 | "\n", 440 | "Expected Output:\n", 441 | "```\n", 442 | "Random word: GRAYNESSES\n", 443 | "```" 444 | ] 445 | }, 446 | { 447 | "cell_type": "code", 448 | "execution_count": null, 449 | "metadata": {}, 450 | "outputs": [], 451 | "source": [ 452 | "# Solution 12\n", 453 | "\n" 454 | ] 455 | }, 456 | { 457 | "cell_type": "markdown", 458 | "metadata": {}, 459 | "source": [ 460 | "### Question 13: \n", 461 | "\n", 462 | "Write a python program where a text(.txt) file is given **[nameslist.txt](https://github.com/milaan9/JLUFE_Intelligent_Tech_2005-2006/blob/main/nameslist.txt)** that contains list of a bunch of names, count how many of each name there are in the file, and print out the results to the screen. \n", 463 | "\n", 464 | "Expected Output:\n", 465 | "```\n", 466 | "{'Darth': 31, 'Luke': 15, 'Leia': 54}\n", 467 | "```" 468 | ] 469 | }, 470 | { 471 | "cell_type": "code", 472 | "execution_count": null, 473 | "metadata": {}, 474 | "outputs": [], 475 | "source": [ 476 | "# Solution 13\n", 477 | "\n" 478 | ] 479 | }, 480 | { 481 | "cell_type": "markdown", 482 | "metadata": {}, 483 | "source": [ 484 | "### Question 14: \n", 485 | "\n", 486 | "Write a python program where two .txt files are given that have lists of numbers in them, find the numbers that are overlapping. One '**[primenumbers1_1000.txt](https://github.com/milaan9/JLUFE_Intelligent_Tech_2005-2006/blob/main/primenumbers1_1000.txt)**' file has a list of all prime numbers under 1000, and the other '**[happynumbers1_1000.txt](https://github.com/milaan9/JLUFE_Intelligent_Tech_2005-2006/blob/main/happynumbers1_1000.txt)**' file has a list of **[happy numbers](https://en.wikipedia.org/wiki/Happy_number)** up to 1000.\n", 487 | "\n", 488 | "Expected Output:\n", 489 | "```\n", 490 | "The list of overlapping numbers:\n", 491 | " [7, 13, 19, 23, 31, 79, 97, 103, 109, 139, 167, 193, 239, 263, 293, 313, 331, 367, 379, 383, 397, 409, 487, 563, 617, 653, 673, 683, 709, 739, 761, 863, 881, 907, 937]\n", 492 | "```" 493 | ] 494 | }, 495 | { 496 | "cell_type": "code", 497 | "execution_count": null, 498 | "metadata": {}, 499 | "outputs": [], 500 | "source": [ 501 | "# Solution 14\n", 502 | "\n" 503 | ] 504 | }, 505 | { 506 | "cell_type": "markdown", 507 | "metadata": {}, 508 | "source": [ 509 | "### Question 15: \n", 510 | "\n", 511 | "Create a function that takes a string as an argument and returns the Morse code equivalent.\n", 512 | "\n", 513 | "For example:\n", 514 | "```\n", 515 | "encode_morse(\"HELP ME !\") ➞ \".... . .-.. .--. -- . -.-.--\"\n", 516 | "```\n", 517 | "\n", 518 | "Expected Output:\n", 519 | "```\n", 520 | "Enter a sentence: I love\n", 521 | ".. .-.. --- ...- .\n", 522 | "Enter morse code: .--. -.-- - .... --- -.\n", 523 | "PYTHON\n", 524 | "```\n", 525 | "\n", 526 | "This dictionary can be used for coding:\n", 527 | "```\n", 528 | "char_to_dots = {\n", 529 | " 'A': '.-', 'B': '-...', 'C': '-.-.', 'D': '-..', 'E': '.', 'F': '..-.',\n", 530 | " 'G': '--.', 'H': '....', 'I': '..', 'J': '.---', 'K': '-.-', 'L': '.-..',\n", 531 | " 'M': '--', 'N': '-.', 'O': '---', 'P': '.--.', 'Q': '--.-', 'R': '.-.',\n", 532 | " 'S': '...', 'T': '-', 'U': '..-', 'V': '...-', 'W': '.--', 'X': '-..-',\n", 533 | " 'Y': '-.--', 'Z': '--..', \n", 534 | " \n", 535 | " '0': '-----', '1': '.----', '2': '..---', '3': '...--', '4': '....-', \n", 536 | " '5': '.....', '6': '-....', '7': '--...', '8': '---..', '9': '----.',\n", 537 | " \n", 538 | " ' ': ' ', '&': '.-...', \"'\": '.----.', '@': '.--.-.', ')': '-.--.-', \n", 539 | " '(': '-.--.', ':': '---...', ',': '--..--', '=': '-...-', '!': '-.-.--', \n", 540 | " '.': '.-.-.-', '-': '-....-', '+': '.-.-.', '\"': '.-..-.', '?': '..--..', \n", 541 | " '/': '-..-.'\n", 542 | "}\n", 543 | "```" 544 | ] 545 | }, 546 | { 547 | "cell_type": "code", 548 | "execution_count": null, 549 | "metadata": {}, 550 | "outputs": [], 551 | "source": [ 552 | "# Solution 15\n", 553 | "\n" 554 | ] 555 | }, 556 | { 557 | "cell_type": "code", 558 | "execution_count": null, 559 | "metadata": {}, 560 | "outputs": [], 561 | "source": [] 562 | } 563 | ], 564 | "metadata": { 565 | "hide_input": false, 566 | "kernelspec": { 567 | "display_name": "Python 3", 568 | "language": "python", 569 | "name": "python3" 570 | }, 571 | "language_info": { 572 | "codemirror_mode": { 573 | "name": "ipython", 574 | "version": 3 575 | }, 576 | "file_extension": ".py", 577 | "mimetype": "text/x-python", 578 | "name": "python", 579 | "nbconvert_exporter": "python", 580 | "pygments_lexer": "ipython3", 581 | "version": "3.8.8" 582 | }, 583 | "toc": { 584 | "base_numbering": 1, 585 | "nav_menu": {}, 586 | "number_sections": true, 587 | "sideBar": true, 588 | "skip_h1_title": false, 589 | "title_cell": "Table of Contents", 590 | "title_sidebar": "Contents", 591 | "toc_cell": false, 592 | "toc_position": {}, 593 | "toc_section_display": true, 594 | "toc_window_display": false 595 | }, 596 | "varInspector": { 597 | "cols": { 598 | "lenName": 16, 599 | "lenType": 16, 600 | "lenVar": 40 601 | }, 602 | "kernels_config": { 603 | "python": { 604 | "delete_cmd_postfix": "", 605 | "delete_cmd_prefix": "del ", 606 | "library": "var_list.py", 607 | "varRefreshCmd": "print(var_dic_list())" 608 | }, 609 | "r": { 610 | "delete_cmd_postfix": ") ", 611 | "delete_cmd_prefix": "rm(", 612 | "library": "var_list.r", 613 | "varRefreshCmd": "cat(var_dic_list()) " 614 | } 615 | }, 616 | "types_to_exclude": [ 617 | "module", 618 | "function", 619 | "builtin_function_or_method", 620 | "instance", 621 | "_Feature" 622 | ], 623 | "window_display": false 624 | } 625 | }, 626 | "nbformat": 4, 627 | "nbformat_minor": 2 628 | } 629 | -------------------------------------------------------------------------------- /001_Python_HW_Assignment_01.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "ExecuteTime": { 7 | "end_time": "2021-07-20T09:16:22.081113Z", 8 | "start_time": "2021-07-20T09:16:22.072320Z" 9 | } 10 | }, 11 | "source": [ 12 | "         **JLUFE**                                   **Fall 2021(Sep-Jan)** \n", 13 | "\n", 14 | "\n", 15 | "**
Homework Assignment Report
**\n", 16 | "
\n", 17 | "\n", 18 | "**
JILIN UNIVERSITY OF FINANCE AND ECONOMICS
**\n", 19 | "
\n", 20 | "\n", 21 | "**
College of Managment Science and Information Engineering
**\n", 22 | "\n", 23 | "**
BSc in Data Science and Big Data Technology
**\n", 24 | "\n", 25 | "**
(2021)
**\n", 26 | "\n", 27 | "
\n", 28 | "\n", 29 | "**
MODULE: Intelligent Technology
**\n", 30 | "\n", 31 | "**
Homework Assignment: 01
**\n", 32 | "\n", 33 | "**
Variables and Operators
**\n", 34 | "\n", 35 | "**
16/09/2021
**\n", 36 | "\n", 37 | "
\n", 38 | "\n", 39 | "**
Submitted by:
**\n", 40 | "\n", 41 | "**
Milan(米兰) 0318021907632 (2005)
**\n", 42 | "**
QQ: 3086215265 | Github ID: milaan9
**" 43 | ] 44 | }, 45 | { 46 | "cell_type": "markdown", 47 | "metadata": {}, 48 | "source": [ 49 | "# Instructions: \n", 50 | "\n", 51 | "\n", 52 | "1. I have added tips and required learning resources for each question, which helps you to solve the problems. \n", 53 | "\n", 54 | "2. Finish the assignment on your **OWN**. **Any student find copying/sharing from classmates or internet will get '0' points!!!**\n", 55 | "\n", 56 | "3. After Accepting this assignment from ➞ **[GitHub Clasroom link](https://classroom.github.com/a/E8YXLgc4)**, Github will create private repository of the assignment in your GitHub Classroom account.\n", 57 | "\n", 58 | "4. In your repository CloneDownload ZIP in your computer.\n", 59 | "\n", 60 | "5. Change your ➞ **College**, **Major**, **Name**, **Student number**, **Class number**, **QQ number** and **GitHub ID**\n", 61 | "\n", 62 | "6. Once you finish the Assignment **[convert your .ipynb file into PDF](https://github.com/milaan9/91_Python_Mini_Projects/tree/main/001_Convert_IPython_to_PDF)** (both **.ipynb** and **.pdf** file will be required!)\n", 63 | "\n", 64 | "7. To submit your assignment, go to GitHub Classroom repository and Add fileUpload filesCommit changes\n", 65 | " 1. Replace the question (**.ipynb**) file with your solution (**.ipynb**) file.\n", 66 | " 2. Also, upload (**.pdf**) converted file of your solution (**.ipynb**) file." 67 | ] 68 | }, 69 | { 70 | "cell_type": "markdown", 71 | "metadata": {}, 72 | "source": [ 73 | "# Python Assignment 01" 74 | ] 75 | }, 76 | { 77 | "cell_type": "markdown", 78 | "metadata": {}, 79 | "source": [ 80 | "# Part A ➞ Variables Level 1" 81 | ] 82 | }, 83 | { 84 | "cell_type": "markdown", 85 | "metadata": {}, 86 | "source": [ 87 | "1. Write a python comment saying **`Python variables and Constants`**\n", 88 | "2. Declare a **`first_name`** variable and assign a value to it\n", 89 | "3. Declare a **`last_name`** variable and assign a value to it\n", 90 | "4. Declare a **`full_name`** variable and assign a value to it\n", 91 | "5. Declare a variable **`is_light_on`** and assign a value to it\n", 92 | "6. Declare multiple variable on one line" 93 | ] 94 | }, 95 | { 96 | "cell_type": "code", 97 | "execution_count": null, 98 | "metadata": {}, 99 | "outputs": [], 100 | "source": [ 101 | "# Solution: \n", 102 | "\n" 103 | ] 104 | }, 105 | { 106 | "cell_type": "markdown", 107 | "metadata": {}, 108 | "source": [ 109 | "# Part B ➞ Variables Level 2\n", 110 | "\n", 111 | ">**Note:** Please create new cell for each question" 112 | ] 113 | }, 114 | { 115 | "cell_type": "markdown", 116 | "metadata": {}, 117 | "source": [ 118 | "1. Check the data type of all your variables using **[type()](https://github.com/milaan9/04_Python_Functions/blob/main/002_Python_Functions_Built_in/064_Python_type%28%29.ipynb)** built-in function\n", 119 | "2. Using the **[len()](https://github.com/milaan9/04_Python_Functions/blob/main/002_Python_Functions_Built_in/040_Python_len%28%29.ipynb)** built-in function, find the length of your first name\n", 120 | "3. Compare the length of your **`first_name`** and your **`last_name`**\n", 121 | "4. Declare **6** as **`num_1`** and **4** as **`num_2`**\n", 122 | " 1. Add **`num_1`** and **`num_2`** and assign the value to a variable **`total`**\n", 123 | " 2. Subtract **`num_2`** from **`num_1`** and assign the value to a variable **`difference`**\n", 124 | " 3. Multiply **`num_2`** and **`num_1`** and assign the value to a variable **`product`**\n", 125 | " 4. Divide **`num_1`** by **`num_2`** and assign the value to a variable **`division`**\n", 126 | " 5. Use modulus division to find **`num_2`** divided by **`num_1`** and assign the value to a variable **`remainder`**\n", 127 | " 6. Calculate **`num_1`** to the power of **`num_2`** and assign the value to a variable **`exp`**\n", 128 | " 7. Find floor division of **`num_1`** by **`num_2`** and assign the value to a variable **`floor_division`**\n", 129 | "\n", 130 | "5. Use the built-in **[input()](https://github.com/milaan9/04_Python_Functions/blob/main/002_Python_Functions_Built_in/032_Python_input%28%29.ipynb)** function to get first name, last name, country and age from a user and store the value to their corresponding variable names\n", 131 | "\n", 132 | "6. The radius of a circle is **30 meters**.\n", 133 | " 1. Calculate the area of a circle and assign the value to a variable name of **`area_of_circle`** by taking user **[input()](https://github.com/milaan9/04_Python_Functions/blob/main/002_Python_Functions_Built_in/032_Python_input%28%29.ipynb)**\n", 134 | " 2. Calculate the circumference of a circle and assign the value to a variable name of **`circum_of_circle`** by taking user **[input()](https://github.com/milaan9/04_Python_Functions/blob/main/002_Python_Functions_Built_in/032_Python_input%28%29.ipynb)**\n", 135 | " 3. Take radius as user **[input()](https://github.com/milaan9/04_Python_Functions/blob/main/002_Python_Functions_Built_in/032_Python_input%28%29.ipynb)** and calculate the area.\n", 136 | "\n", 137 | "7. Run help (**`keywords`**) in Python shell or in your file to check for the Python reserved words or keywords" 138 | ] 139 | }, 140 | { 141 | "cell_type": "code", 142 | "execution_count": null, 143 | "metadata": {}, 144 | "outputs": [], 145 | "source": [ 146 | "# Solution : \n", 147 | "\n" 148 | ] 149 | }, 150 | { 151 | "cell_type": "markdown", 152 | "metadata": {}, 153 | "source": [ 154 | "# Part C ➞ Operators Level 1\n", 155 | "\n", 156 | ">**Note:** Please create new cell for each question" 157 | ] 158 | }, 159 | { 160 | "cell_type": "markdown", 161 | "metadata": {}, 162 | "source": [ 163 | "1. Declare your age as integer variable\n", 164 | "2. Declare your height as a float variable\n", 165 | "3. Declare a variable that store a complex number\n", 166 | "4. Write a code that prompts the user to enter base and height of the triangle and calculate an area of this triangle (area = 0.5 x b x h).\n", 167 | "\n", 168 | " - ```py\n", 169 | " Enter base: 20\n", 170 | " Enter height: 10\n", 171 | " The area of the triangle is 100\n", 172 | " ```\n", 173 | "\n", 174 | "5. Write a code that prompts the user to enter side a, side b, and side c of the triangle. Calculate the perimeter of the triangle (perimeter = a + b + c).\n", 175 | "\n", 176 | " - ```py\n", 177 | " Enter side a: 5\n", 178 | " Enter side b: 4\n", 179 | " Enter side c: 3\n", 180 | " The perimeter of the triangle is 12\n", 181 | " ```\n", 182 | "\n", 183 | "6. Get length and width of a rectangle using prompt. Calculate its area (**area = length x width**) and perimeter (**perimeter = 2 x (length + width)**)\n", 184 | "7. Get radius of a circle using prompt. Calculate the area (**area = pi x r x r**) and circumference (**c = 2 x pi x r**) where pi = 3.14.\n", 185 | "8. Calculate the slope, **`x`**-intercept and **`y`**-intercept of $y = 2x -2$\n", 186 | "9. Slope is ($m = (y2-y1)/(x2-x1)$). Find the slope and **[Euclidean distance](https://en.wikipedia.org/wiki/Euclidean_distance#:~:text=In%20mathematics%2C%20the%20Euclidean%20distance,being%20called%20the%20Pythagorean%20distance.)** between point (2, 2) and point (6,10) \n", 187 | "10. Compare the slopes in tasks 8 and 9.\n", 188 | "11. Calculate the value of **`y`**: ($y = x^2 + 6x + 9$). Try to use different **`x`** values and figure out at what **`x`** value **`y`** is going to be 0.\n", 189 | "12. Find the length of **`'python'`** and **`'datascience'`** and compare if the length are same using **`==`**.\n", 190 | "13. Use **`and`** operator to check if **`on`** is found in both **`python`** and **`cannon`**\n", 191 | "14. **`I hope this course is not full of jargon`**. Use **`in`** operator to check if **`jargon`** is in the sentence.\n", 192 | "15. There is no **`on`** in both **`python`** and **`cannon`**\n", 193 | "16. Find the length of the text **`python`** and convert the value to float and convert it to string\n", 194 | "17. Even numbers are divisible by 2 and the remainder is zero. How do you check if a number is even or not using python?\n", 195 | "18. Check if the floor division of 7 by 3 is equal to the int converted value of 2.7.\n", 196 | "19. Check if type of **\"10\"** is equal to type of 10\n", 197 | "20. Check if int(**\"9.6\"**) is equal to 10\n", 198 | "21. Write a code that prompts the user to enter hours and rate per hour. Calculate pay of the person?\n", 199 | "\n", 200 | " - ```py\n", 201 | "Enter hours: 40\n", 202 | "Enter rate per hour: 30\n", 203 | "Your weekly earning is 1200\n", 204 | " ```\n", 205 | "\n", 206 | "22. Write a script that prompts the user to enter number of years. Calculate the number of seconds a person can live. Assume a person can live hundred years\n", 207 | "\n", 208 | " - ```py\n", 209 | "Enter number of years you have lived: 100\n", 210 | "You have lived for 3153600000 seconds.\n", 211 | " ```\n", 212 | "\n", 213 | "23. Write a Python code that displays the following table **using operators**\n", 214 | "\n", 215 | " - ```py\n", 216 | "1 2 3 4 5 \n", 217 | "2 4 6 8 10\n", 218 | "3 6 9 12 15\n", 219 | "4 8 12 16 20\n", 220 | "5 10 15 20 25\n", 221 | " ```" 222 | ] 223 | }, 224 | { 225 | "cell_type": "code", 226 | "execution_count": null, 227 | "metadata": {}, 228 | "outputs": [], 229 | "source": [ 230 | "# Solution: \n", 231 | "\n" 232 | ] 233 | } 234 | ], 235 | "metadata": { 236 | "hide_input": false, 237 | "kernelspec": { 238 | "display_name": "Python 3", 239 | "language": "python", 240 | "name": "python3" 241 | }, 242 | "language_info": { 243 | "codemirror_mode": { 244 | "name": "ipython", 245 | "version": 3 246 | }, 247 | "file_extension": ".py", 248 | "mimetype": "text/x-python", 249 | "name": "python", 250 | "nbconvert_exporter": "python", 251 | "pygments_lexer": "ipython3", 252 | "version": "3.8.8" 253 | }, 254 | "toc": { 255 | "base_numbering": 1, 256 | "nav_menu": {}, 257 | "number_sections": true, 258 | "sideBar": true, 259 | "skip_h1_title": false, 260 | "title_cell": "Table of Contents", 261 | "title_sidebar": "Contents", 262 | "toc_cell": false, 263 | "toc_position": {}, 264 | "toc_section_display": true, 265 | "toc_window_display": false 266 | }, 267 | "varInspector": { 268 | "cols": { 269 | "lenName": 16, 270 | "lenType": 16, 271 | "lenVar": 40 272 | }, 273 | "kernels_config": { 274 | "python": { 275 | "delete_cmd_postfix": "", 276 | "delete_cmd_prefix": "del ", 277 | "library": "var_list.py", 278 | "varRefreshCmd": "print(var_dic_list())" 279 | }, 280 | "r": { 281 | "delete_cmd_postfix": ") ", 282 | "delete_cmd_prefix": "rm(", 283 | "library": "var_list.r", 284 | "varRefreshCmd": "cat(var_dic_list()) " 285 | } 286 | }, 287 | "types_to_exclude": [ 288 | "module", 289 | "function", 290 | "builtin_function_or_method", 291 | "instance", 292 | "_Feature" 293 | ], 294 | "window_display": false 295 | } 296 | }, 297 | "nbformat": 4, 298 | "nbformat_minor": 2 299 | } 300 | -------------------------------------------------------------------------------- /002_Python_HW_Assignment_02.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "ExecuteTime": { 7 | "end_time": "2021-07-20T09:16:22.081113Z", 8 | "start_time": "2021-07-20T09:16:22.072320Z" 9 | } 10 | }, 11 | "source": [ 12 | "         **JLUFE**                                   **Fall 2021(Sep-Jan)** \n", 13 | "\n", 14 | "\n", 15 | "**
Homework Assignment Report
**\n", 16 | "
\n", 17 | "\n", 18 | "**
JILIN UNIVERSITY OF FINANCE AND ECONOMICS
**\n", 19 | "
\n", 20 | "\n", 21 | "**
College of Managment Science and Information Engineering
**\n", 22 | "\n", 23 | "**
BSc in Data Science and Big Data Technology
**\n", 24 | "\n", 25 | "**
(2021)
**\n", 26 | "\n", 27 | "
\n", 28 | "\n", 29 | "**
MODULE: Intelligent Technology
**\n", 30 | "\n", 31 | "**
Homework Assignment: 02
**\n", 32 | "\n", 33 | "**
Strings and Lists
**\n", 34 | "\n", 35 | "**
23/09/2021
**\n", 36 | "\n", 37 | "
\n", 38 | "\n", 39 | "**
Submitted by:
**\n", 40 | "\n", 41 | "**
Milan(米兰) 0318021907632 (2005)
**\n", 42 | "**
QQ: 3086215265 | Github ID: milaan9
**" 43 | ] 44 | }, 45 | { 46 | "cell_type": "markdown", 47 | "metadata": {}, 48 | "source": [ 49 | "# Instructions: \n", 50 | "\n", 51 | "\n", 52 | "1. I have added tips and required learning resources for each question, which helps you to solve the problems. \n", 53 | "\n", 54 | "2. Finish the assignment on your **OWN**. **Any student find copying/sharing from classmates or internet will get '0' points!!!**\n", 55 | "\n", 56 | "3. After Accepting this assignment from ➞ **[GitHub Clasroom link](https://classroom.github.com/a/ZPJFystv)**, Github will create private repository of the assignment in your GitHub Classroom account.\n", 57 | "\n", 58 | "4. In your repository CloneDownload ZIP in your computer.\n", 59 | "\n", 60 | "5. Change your ➞ **College**, **Major**, **Name**, **Student number**, **Class number**, **QQ number** and **GitHub ID**\n", 61 | "\n", 62 | "6. Once you finish the Assignment **[convert your .ipynb file into PDF](https://github.com/milaan9/91_Python_Mini_Projects/tree/main/001_Convert_IPython_to_PDF)** (both **.ipynb** and **.pdf** file will be required!)\n", 63 | "\n", 64 | "7. To submit your assignment, go to GitHub Classroom repository and Add fileUpload filesCommit changes\n", 65 | " 1. Replace the question (**.ipynb**) file with your solution (**.ipynb**) file.\n", 66 | " 2. Also, upload (**.pdf**) converted file of your solution (**.ipynb**) file." 67 | ] 68 | }, 69 | { 70 | "cell_type": "markdown", 71 | "metadata": {}, 72 | "source": [ 73 | "# Python Assignment 02" 74 | ] 75 | }, 76 | { 77 | "cell_type": "markdown", 78 | "metadata": {}, 79 | "source": [ 80 | "# Part A ➞ String Level 1\n", 81 | "\n", 82 | ">**Note:** Please create new cell for each question" 83 | ] 84 | }, 85 | { 86 | "cell_type": "markdown", 87 | "metadata": {}, 88 | "source": [ 89 | "1. Concatenate the string **`Python`**, **`4`**, **`Data`**, **`Science`** to a single string, **`Python 4 Data Science`**.\n", 90 | "\n", 91 | "2. Declare a variable named **`course`** and assign it to an initial value **`Python 4 Data Science`**.\n", 92 | "\n", 93 | "3. Print the length of the **`course`** string using **[len()](https://github.com/milaan9/04_Python_Functions/blob/main/002_Python_Functions_Built_in/040_Python_len%28%29.ipynb)** method and **[print()](https://github.com/milaan9/04_Python_Functions/blob/main/002_Python_Functions_Built_in/051_Python_print%28%29.ipynb)**.\n", 94 | "\n", 95 | "4. Change all the characters of variable company to uppercase and lowercase letters using **[upper()](https://github.com/milaan9/02_Python_Datatypes/blob/main/002_Python_String_Methods/026_Python_String_upper%28%29.ipynb)** and **[lower()](https://github.com/milaan9/02_Python_Datatypes/blob/main/002_Python_String_Methods/025_Python_String_lower%28%29.ipynb)** method.\n", 96 | "\n", 97 | "5. Use **[capitalize()](https://github.com/milaan9/02_Python_Datatypes/blob/main/002_Python_String_Methods/001_Python_String_capitalize%28%29.ipynb)**, **[title()](https://github.com/milaan9/02_Python_Datatypes/blob/main/002_Python_String_Methods/042_Python_String_title%28%29.ipynb)**, **[swapcase()](https://github.com/milaan9/02_Python_Datatypes/blob/main/002_Python_String_Methods/027_Python_String_swapcase%28%29.ipynb)** methods to format the value of the string **`Python 4 Data Science`**.\n", 98 | "\n", 99 | "6. Cut(slice) out the first word of **`Python 4 Data Science`**.\n", 100 | "\n", 101 | "7. Check if **`Python 4 Data Science`** string contains a word **`Python`** using the method: **[index()](https://github.com/milaan9/02_Python_Datatypes/blob/main/002_Python_String_Methods/010_Python_String_index%28%29.ipynb)**, **[find()](https://github.com/milaan9/02_Python_Datatypes/blob/main/002_Python_String_Methods/008_Python_String_find%28%29.ipynb)** or other methods.\n", 102 | "\n", 103 | "8. Change **`Python 4 Data Science`** to **`Python 4 Everybody`** using the **[replace()](https://github.com/milaan9/02_Python_Datatypes/blob/main/002_Python_String_Methods/035_Python_String_replace%28%29.ipynb)** method or other methods.\n", 104 | "\n", 105 | "9. Split the string **`Python 4 Data Science`** using space as the separator (**[split()](https://github.com/milaan9/02_Python_Datatypes/blob/main/002_Python_String_Methods/038_Python_String_split%28%29.ipynb)**).\n", 106 | "\n", 107 | "11. **`Google, Facebook, Microsoft, Apple, IBM, Oracle, Amazon`** split the string at the comma.\n", 108 | "\n", 109 | "12. What is the character at index 9 in the string **`Python 4 Data Science`**.\n", 110 | "\n", 111 | "13. What is the second last index of the string **`Python 4 Data Science`**.\n", 112 | "\n", 113 | "14. Create an acronym or an abbreviation for the name **`Python 4 Data Science`**.\n", 114 | "\n", 115 | "15. Use **[index()](https://github.com/milaan9/02_Python_Datatypes/blob/main/002_Python_String_Methods/010_Python_String_index%28%29.ipynb)** to determine the position of the first occurrence of **`D`** in **`Python 4 Data Science`**.\n", 116 | "\n", 117 | "16. Use **[rfind](https://github.com/milaan9/02_Python_Datatypes/blob/main/002_Python_String_Methods/036_Python_String_rfind%28%29.ipynb)** to determine the position of the last occurrence of **`e`** in **`Python 4 Data Science`**.\n", 118 | "\n", 119 | "17. Use **[index()](https://github.com/milaan9/02_Python_Datatypes/blob/main/002_Python_String_Methods/010_Python_String_index%28%29.ipynb)** or **[find()](https://github.com/milaan9/02_Python_Datatypes/blob/main/002_Python_String_Methods/008_Python_String_find%28%29.ipynb)** to find the position of the first occurrence of the word **`because`** in the following sentence: \n", 120 | "\n", 121 | " - **`We cannot end the sentence with ‘because’, because ‘because’ is a conjunction.`**.\n", 122 | "\n", 123 | "18. Use **[rindex](https://github.com/milaan9/02_Python_Datatypes/blob/main/002_Python_String_Methods/037_Python_String_rindex%28%29.ipynb)** to find the position of the first and last occurrence of the word **`because`** in the following sentence: \n", 124 | "\n", 125 | " - **`We cannot end the sentence with ‘because’, because ‘because’ is a conjunction.`**.\n", 126 | "\n", 127 | "19. Slice out the phrase **`‘because’, because ‘because’`** in the following sentence: \n", 128 | "\n", 129 | " - **`We cannot end the sentence with ‘because’, because ‘because’ is a conjunction.`**.\n", 130 | "\n", 131 | "20. Does **`Python 4 Data Science`** start with a substring **`Python`**?\n", 132 | "\n", 133 | "21. Does '**`Python 4 Data Science`** contains with a substring **`Python`**?\n", 134 | "\n", 135 | "22. **` Python 4 DataScience `** remove the left and right trailing spaces in the given string.\n", 136 | "\n", 137 | "23. The following list contains the names of some of python libraries: **`['Django', 'Flask', 'Bottle', 'Pyramid', 'Falcon']`**. Join the list with a hash with space string.\n", 138 | "\n", 139 | "24. Which one of the following variables return True when we use the method **[isidentifier()](https://github.com/milaan9/02_Python_Datatypes/blob/main/002_Python_String_Methods/015_Python_String_isidentifier%28%29.ipynb)**\n", 140 | " - ```py\n", 141 | " 2021PythonDataypes\n", 142 | " Python_Dataypes_2021\n", 143 | " ```\n", 144 | "25. Make the following using string formatting methods:\n", 145 | "\n", 146 | " - ```py\n", 147 | "8 + 6 = 14\n", 148 | "8 - 6 = 2\n", 149 | "8 * 6 = 48\n", 150 | "8 / 6 = 1.33\n", 151 | "8 % 6 = 2\n", 152 | "8 // 6 = 1\n", 153 | "8 ** 6 = 262144\n", 154 | " ```\n", 155 | "\n", 156 | "26. Use a **new line** and **tab** escape sequence to print the following lines.\n", 157 | " - ```py\n", 158 | " Name Age Country City\n", 159 | " Milaan 96 Finland Tampere\n", 160 | " ```" 161 | ] 162 | }, 163 | { 164 | "cell_type": "code", 165 | "execution_count": null, 166 | "metadata": {}, 167 | "outputs": [], 168 | "source": [ 169 | "# Solution: \n", 170 | "\n" 171 | ] 172 | }, 173 | { 174 | "cell_type": "markdown", 175 | "metadata": {}, 176 | "source": [ 177 | "# Part B ➞ List Level 1\n", 178 | "\n", 179 | ">**Note:** Please create new cell for each question" 180 | ] 181 | }, 182 | { 183 | "cell_type": "markdown", 184 | "metadata": {}, 185 | "source": [ 186 | "1. Declare a list with more than 5 items with different data types\n", 187 | "2. Find the length of your list\n", 188 | "3. Get the first item, the middle item and the last item of the list\n", 189 | "4. Declare a list **`called my_info`**, put your (name, age, height, marital status, country)\n", 190 | "5. Declare a list variable named **`mix_fruits`** and assign initial values Guava, Mango, Apple, Pear, Fig, Orange and Banana and print the list.\n", 191 | "6. Print the list using **[print()](https://github.com/milaan9/04_Python_Functions/blob/main/002_Python_Functions_Built_in/051_Python_print%28%29.ipynb)**\n", 192 | "7. Print the number of **`mix_fruits`** in the list\n", 193 | "8. Print the first, middle and last fruit\n", 194 | "9. Print the list after modifying one of the fruit\n", 195 | "10. Add an fruit to variable **`mix_fruits`**\n", 196 | "11. Insert an fruit in the middle of the **`mix_fruits`** list\n", 197 | "12. Change one of the fruit names to uppercase\n", 198 | "13. Join the elements in **`mix_fruits`** with a string **`-#-`**\n", 199 | "14. Check if a certain fruit exists in the **`mix_fruits`** list.\n", 200 | "15. Sort the list using **[sort()](https://github.com/milaan9/02_Python_Datatypes/blob/main/003_Python_List_Methods/009_Python_List_sort%28%29.ipynb)** method\n", 201 | "16. Reverse the list in descending order using **[reverse()](https://github.com/milaan9/02_Python_Datatypes/blob/main/003_Python_List_Methods/008_Python_List_reverse%28%29.ipynb)** method\n", 202 | "17. Slice out the first 3 fruits from the list\n", 203 | "18. Slice out the last 3 fruits from the list\n", 204 | "19. Slice out the middle fruit or fruits from the list\n", 205 | "20. Remove the first fruit from the list\n", 206 | "21. Remove the middle fruit or companies from the list\n", 207 | "22. Remove the last fruit from the list\n", 208 | "23. Remove all fruits from the list\n", 209 | "24. Delete the fruits list\n", 210 | "25. Join the following lists:\n", 211 | "\n", 212 | " - ```py\n", 213 | " front_end = ['HTML', 'CSS', 'JS', 'React', 'Redux']\n", 214 | " back_end = ['Node','Express', 'MongoDB']\n", 215 | " ```\n", 216 | "\n", 217 | "26. After joining the lists in question 25. Copy the joined list and assign it to a variable full_stack. Then insert **`'Python'`** and **`'SQL'`** after **`'Redux'`**." 218 | ] 219 | }, 220 | { 221 | "cell_type": "code", 222 | "execution_count": null, 223 | "metadata": {}, 224 | "outputs": [], 225 | "source": [ 226 | "# Solution: \n", 227 | "\n" 228 | ] 229 | }, 230 | { 231 | "cell_type": "markdown", 232 | "metadata": {}, 233 | "source": [ 234 | "# Part B ➞ List Level 2\n", 235 | "\n", 236 | ">**Note:** Please create new cell for each question" 237 | ] 238 | }, 239 | { 240 | "cell_type": "markdown", 241 | "metadata": {}, 242 | "source": [ 243 | "1. The following is a list of 10 students ages:\n", 244 | "\n", 245 | " - ```py\n", 246 | "ages = [19, 23, 19, 25, 21, 20, 25, 26, 25, 24]\n", 247 | " ```\n", 248 | "\n", 249 | " - Sort the list and find the min and max age\n", 250 | " - Add the min age and the max age again to the list\n", 251 | " - Find the median age (one middle item or two middle items divided by two)\n", 252 | " - Find the average age (sum of all items divided by their number )\n", 253 | " - Find the range of the ages (max - min)\n", 254 | " - Compare the value of (min - average) and (max - average), use **[abs()](https://github.com/milaan9/04_Python_Functions/blob/main/002_Python_Functions_Built_in/001_Python_abs%28%29.ipynb)** method\n", 255 | "\n", 256 | "2. Find the middle country(ies) in the **[countries list](https://github.com/milaan9/02_Python_Datatypes/blob/main/countries_data.py)**\n", 257 | "3. Divide the countries list into two equal lists if it is even if not one more country for the first half.\n", 258 | "4. **`['India', 'Russia', 'China', 'Finland', 'Sweden', 'Norway', 'Denmark']`**. Unpack the first three countries and the rest as scandic countries." 259 | ] 260 | }, 261 | { 262 | "cell_type": "code", 263 | "execution_count": null, 264 | "metadata": {}, 265 | "outputs": [], 266 | "source": [ 267 | "# Solution: \n", 268 | "\n" 269 | ] 270 | } 271 | ], 272 | "metadata": { 273 | "hide_input": false, 274 | "kernelspec": { 275 | "display_name": "Python 3", 276 | "language": "python", 277 | "name": "python3" 278 | }, 279 | "language_info": { 280 | "codemirror_mode": { 281 | "name": "ipython", 282 | "version": 3 283 | }, 284 | "file_extension": ".py", 285 | "mimetype": "text/x-python", 286 | "name": "python", 287 | "nbconvert_exporter": "python", 288 | "pygments_lexer": "ipython3", 289 | "version": "3.8.8" 290 | }, 291 | "toc": { 292 | "base_numbering": 1, 293 | "nav_menu": {}, 294 | "number_sections": true, 295 | "sideBar": true, 296 | "skip_h1_title": false, 297 | "title_cell": "Table of Contents", 298 | "title_sidebar": "Contents", 299 | "toc_cell": false, 300 | "toc_position": {}, 301 | "toc_section_display": true, 302 | "toc_window_display": false 303 | }, 304 | "varInspector": { 305 | "cols": { 306 | "lenName": 16, 307 | "lenType": 16, 308 | "lenVar": 40 309 | }, 310 | "kernels_config": { 311 | "python": { 312 | "delete_cmd_postfix": "", 313 | "delete_cmd_prefix": "del ", 314 | "library": "var_list.py", 315 | "varRefreshCmd": "print(var_dic_list())" 316 | }, 317 | "r": { 318 | "delete_cmd_postfix": ") ", 319 | "delete_cmd_prefix": "rm(", 320 | "library": "var_list.r", 321 | "varRefreshCmd": "cat(var_dic_list()) " 322 | } 323 | }, 324 | "types_to_exclude": [ 325 | "module", 326 | "function", 327 | "builtin_function_or_method", 328 | "instance", 329 | "_Feature" 330 | ], 331 | "window_display": false 332 | } 333 | }, 334 | "nbformat": 4, 335 | "nbformat_minor": 2 336 | } 337 | -------------------------------------------------------------------------------- /003_Python_HW_Assignment_03.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "ExecuteTime": { 7 | "end_time": "2021-07-20T09:16:22.081113Z", 8 | "start_time": "2021-07-20T09:16:22.072320Z" 9 | } 10 | }, 11 | "source": [ 12 | "         **JLUFE**                                   **Fall 2021(Sep-Jan)** \n", 13 | "\n", 14 | "\n", 15 | "**
Homework Assignment Report
**\n", 16 | "
\n", 17 | "\n", 18 | "**
JILIN UNIVERSITY OF FINANCE AND ECONOMICS
**\n", 19 | "
\n", 20 | "\n", 21 | "**
College of Managment Science and Information Engineering
**\n", 22 | "\n", 23 | "**
BSc in Data Science and Big Data Technology
**\n", 24 | "\n", 25 | "**
(2021)
**\n", 26 | "\n", 27 | "
\n", 28 | "\n", 29 | "**
MODULE: Intelligent Technology
**\n", 30 | "\n", 31 | "**
Homework Assignment: 03
**\n", 32 | "\n", 33 | "**
Tuples, Sets and Dictionary
**\n", 34 | "\n", 35 | "**
30/09/2021
**\n", 36 | "\n", 37 | "
\n", 38 | "\n", 39 | "**
Submitted by:
**\n", 40 | "\n", 41 | "**
Milan(米兰) 0318021907632 (2005)
**\n", 42 | "**
QQ: 3086215265 | Github ID: milaan9
**" 43 | ] 44 | }, 45 | { 46 | "cell_type": "markdown", 47 | "metadata": {}, 48 | "source": [ 49 | "# Instructions: \n", 50 | "\n", 51 | "\n", 52 | "1. I have added tips and required learning resources for each question, which helps you to solve the problems. \n", 53 | "\n", 54 | "2. Finish the assignment on your **OWN**. **Any student find copying/sharing from classmates or internet will get '0' points!!!**\n", 55 | "\n", 56 | "3. After Accepting this assignment from ➞ **[GitHub Clasroom link](https://classroom.github.com/a/Dzu4NqBh)**, Github will create private repository of the assignment in your GitHub Classroom account.\n", 57 | "\n", 58 | "4. In your repository CloneDownload ZIP in your computer.\n", 59 | "\n", 60 | "5. Change your ➞ **College**, **Major**, **Name**, **Student number**, **Class number**, **QQ number** and **GitHub ID**\n", 61 | "\n", 62 | "6. Once you finish the Assignment **[convert your .ipynb file into PDF](https://github.com/milaan9/91_Python_Mini_Projects/tree/main/001_Convert_IPython_to_PDF)** (both **.ipynb** and **.pdf** file will be required!)\n", 63 | "\n", 64 | "7. To submit your assignment, go to GitHub Classroom repository and Add fileUpload filesCommit changes\n", 65 | " 1. Replace the question (**.ipynb**) file with your solution (**.ipynb**) file.\n", 66 | " 2. Also, upload (**.pdf**) converted file of your solution (**.ipynb**) file." 67 | ] 68 | }, 69 | { 70 | "cell_type": "markdown", 71 | "metadata": {}, 72 | "source": [ 73 | "# Python Assignment 03" 74 | ] 75 | }, 76 | { 77 | "cell_type": "markdown", 78 | "metadata": {}, 79 | "source": [ 80 | "# Part A ➞ Tuple Level 1 & 2\n", 81 | "\n", 82 | ">**Note:** Please create new cell for each question" 83 | ] 84 | }, 85 | { 86 | "cell_type": "markdown", 87 | "metadata": {}, 88 | "source": [ 89 | "### Part A ➞ Level 1\n", 90 | ">**Note:** Please create new cell for each question\n", 91 | "\n", 92 | "1. Create a tuple containing names of **`fruits`** and **`vegetables`**\n", 93 | "2. Join **`fruits`** and **`vegetables`** tuples and assign it to **`fruits_vegetables`**\n", 94 | "3. How many **`fruits_vegetables`** do you have?\n", 95 | "4. Modify the **`fruits_vegetables`** tuple and add the name of your favorite mushroom and beverage and assign it to **`food_tuple`**" 96 | ] 97 | }, 98 | { 99 | "cell_type": "code", 100 | "execution_count": null, 101 | "metadata": {}, 102 | "outputs": [], 103 | "source": [ 104 | "# Solution: \n", 105 | "\n" 106 | ] 107 | }, 108 | { 109 | "cell_type": "markdown", 110 | "metadata": {}, 111 | "source": [ 112 | "### Part A ➞ Level 2\n", 113 | ">**Note:** Please create new cell for each question\n", 114 | "\n", 115 | "1. Unpack **`fruits_vegetables`** and mushroom and beverage from **`food_tuple`**\n", 116 | "2. Change the about **`food_tuple`** tuple to a **`food_list`** list\n", 117 | "3. Slice out the middle item or items from the **`food_tuple`** tuple or **`food_list`** list.\n", 118 | "4. Slice out the first three items and the last three items from **`food_list`** list\n", 119 | "5. Delete the **`food_tuple`** tuple completely\n", 120 | "6. Check if an item exists in tuple:\n", 121 | " - Check if **`'Finland'`** is a asian country\n", 122 | " - Check if **`'India'`** is a asian country\n", 123 | " ```python\n", 124 | "asian_countries = ('India','China','Singapore','Thailand','Indonesia')\n", 125 | " ```" 126 | ] 127 | }, 128 | { 129 | "cell_type": "code", 130 | "execution_count": null, 131 | "metadata": {}, 132 | "outputs": [], 133 | "source": [ 134 | "# Solution: \n", 135 | "\n" 136 | ] 137 | }, 138 | { 139 | "cell_type": "markdown", 140 | "metadata": {}, 141 | "source": [ 142 | "# Part B ➞ Sets Level 1, 2 and 3\n", 143 | "\n", 144 | ">**Note:** Please create new cell for each question" 145 | ] 146 | }, 147 | { 148 | "cell_type": "markdown", 149 | "metadata": {}, 150 | "source": [ 151 | "```py\n", 152 | "mix_fruits = {'Guava', 'Pear', 'Mango', 'Apple', 'Fig', 'Orange', 'Banana'}\n", 153 | "A = {19, 22, 24, 20, 25, 26}\n", 154 | "B = {19, 22, 20, 25, 26, 24, 28, 27}\n", 155 | "num = [22, 19, 24, 25, 26, 24, 25, 24]\n", 156 | "```\n", 157 | "\n", 158 | "### Part B ➞ Level 1\n", 159 | ">**Note:** Please create new cell for each question\n", 160 | "\n", 161 | "1. Find the length of the set **`mix_fruits`**\n", 162 | "2. Add **`'Kiwi'`** to **`mix_fruits`**\n", 163 | "3. Insert multiple fruits at once to the set **`mix_fruits`**\n", 164 | "4. Remove one of the fruit from the set **`mix_fruits`**\n", 165 | "5. What is the difference between **remove** and **discard**" 166 | ] 167 | }, 168 | { 169 | "cell_type": "code", 170 | "execution_count": null, 171 | "metadata": {}, 172 | "outputs": [], 173 | "source": [ 174 | "# Solution: \n", 175 | "\n" 176 | ] 177 | }, 178 | { 179 | "cell_type": "markdown", 180 | "metadata": {}, 181 | "source": [ 182 | "### Part B ➞ Level 2\n", 183 | ">**Note:** Please create new cell for each question\n", 184 | "\n", 185 | "Use Imaginary values for Set **`A`** and **`B`**\n", 186 | "\n", 187 | "1. Join **`A`** and **`B`**\n", 188 | "2. Find **`A`** intersection **`B`**\n", 189 | "3. Is **`A`** subset of **`B`**\n", 190 | "4. Are **`A`** and **`B`** disjoint sets\n", 191 | "5. Join **`A`** with **`B`** and **`B`** with **`A`**\n", 192 | "6. What is the symmetric difference between A and **`B`**\n", 193 | "7. Delete the sets completely" 194 | ] 195 | }, 196 | { 197 | "cell_type": "code", 198 | "execution_count": null, 199 | "metadata": {}, 200 | "outputs": [], 201 | "source": [ 202 | "# Solution: \n", 203 | "\n" 204 | ] 205 | }, 206 | { 207 | "cell_type": "markdown", 208 | "metadata": {}, 209 | "source": [ 210 | "### Part B ➞ Level 3\n", 211 | ">**Note:** Please create new cell for each question\n", 212 | "\n", 213 | "1. Convert the **`num`** to a set and compare the length of the list and the set, which one is bigger?\n", 214 | "2. Explain the difference between the following data types: **string**, **list**, **tuple** and **set**\n", 215 | "3. **`I am a researcher cum teacher and I love to inspire and teach people.`**. How many unique words have been used in the sentence? Use the **`split`** methods and set to get the unique words." 216 | ] 217 | }, 218 | { 219 | "cell_type": "code", 220 | "execution_count": null, 221 | "metadata": {}, 222 | "outputs": [], 223 | "source": [ 224 | "# Solution: \n", 225 | "\n" 226 | ] 227 | }, 228 | { 229 | "cell_type": "markdown", 230 | "metadata": {}, 231 | "source": [ 232 | "# Part C ➞ Dictionary Level 1\n", 233 | "\n", 234 | ">**Note:** Please create new cell for each question" 235 | ] 236 | }, 237 | { 238 | "cell_type": "markdown", 239 | "metadata": {}, 240 | "source": [ 241 | "1. Create an empty dictionary called **`bird`**\n", 242 | "2. Add **`name`**, **`color`**, **`breed`**, **`legs`**, **`age`** to the **`bird`** dictionary\n", 243 | "3. Create a **`student`** dictionary and add **`first_name`**, **`last_name`**, **`gender`**, **`age`**, **`marital_status`**, **`skills`**, **`country`**, **`city`** and **`address`** as keys for the dictionary\n", 244 | "3. Get the length of the **`student`** dictionary\n", 245 | "4. Get the value of **`skills`** and check the data type, it should be a list\n", 246 | "5. Modify the **`skills`** values by adding one or two skills\n", 247 | "6. Get the dictionary keys as a list\n", 248 | "7. Get the dictionary values as a list\n", 249 | "8. Change the dictionary to a list of tuples using **[items()](https://github.com/milaan9/02_Python_Datatypes/blob/main/005_Python_Dictionary_Methods/005_Python_Dictionary_items%28%29.ipynb)** method\n", 250 | "9. Delete one of the items in the dictionary\n", 251 | "10. Delete one of the dictionaries" 252 | ] 253 | }, 254 | { 255 | "cell_type": "code", 256 | "execution_count": null, 257 | "metadata": {}, 258 | "outputs": [], 259 | "source": [ 260 | "# Solution:\n", 261 | "\n" 262 | ] 263 | } 264 | ], 265 | "metadata": { 266 | "hide_input": false, 267 | "kernelspec": { 268 | "display_name": "Python 3", 269 | "language": "python", 270 | "name": "python3" 271 | }, 272 | "language_info": { 273 | "codemirror_mode": { 274 | "name": "ipython", 275 | "version": 3 276 | }, 277 | "file_extension": ".py", 278 | "mimetype": "text/x-python", 279 | "name": "python", 280 | "nbconvert_exporter": "python", 281 | "pygments_lexer": "ipython3", 282 | "version": "3.8.8" 283 | }, 284 | "toc": { 285 | "base_numbering": 1, 286 | "nav_menu": {}, 287 | "number_sections": true, 288 | "sideBar": true, 289 | "skip_h1_title": false, 290 | "title_cell": "Table of Contents", 291 | "title_sidebar": "Contents", 292 | "toc_cell": false, 293 | "toc_position": {}, 294 | "toc_section_display": true, 295 | "toc_window_display": false 296 | }, 297 | "varInspector": { 298 | "cols": { 299 | "lenName": 16, 300 | "lenType": 16, 301 | "lenVar": 40 302 | }, 303 | "kernels_config": { 304 | "python": { 305 | "delete_cmd_postfix": "", 306 | "delete_cmd_prefix": "del ", 307 | "library": "var_list.py", 308 | "varRefreshCmd": "print(var_dic_list())" 309 | }, 310 | "r": { 311 | "delete_cmd_postfix": ") ", 312 | "delete_cmd_prefix": "rm(", 313 | "library": "var_list.r", 314 | "varRefreshCmd": "cat(var_dic_list()) " 315 | } 316 | }, 317 | "types_to_exclude": [ 318 | "module", 319 | "function", 320 | "builtin_function_or_method", 321 | "instance", 322 | "_Feature" 323 | ], 324 | "window_display": false 325 | } 326 | }, 327 | "nbformat": 4, 328 | "nbformat_minor": 2 329 | } 330 | -------------------------------------------------------------------------------- /004_Python_HW_Assignment_04.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "ExecuteTime": { 7 | "end_time": "2021-07-20T09:16:22.081113Z", 8 | "start_time": "2021-07-20T09:16:22.072320Z" 9 | } 10 | }, 11 | "source": [ 12 | "         **JLUFE**                                   **Fall 2021(Sep-Jan)** \n", 13 | "\n", 14 | "\n", 15 | "**
Homework Assignment Report
**\n", 16 | "
\n", 17 | "\n", 18 | "**
JILIN UNIVERSITY OF FINANCE AND ECONOMICS
**\n", 19 | "
\n", 20 | "\n", 21 | "**
College of Managment Science and Information Engineering
**\n", 22 | "\n", 23 | "**
BSc in Data Science and Big Data Technology
**\n", 24 | "\n", 25 | "**
(2021)
**\n", 26 | "\n", 27 | "
\n", 28 | "\n", 29 | "**
MODULE: Intelligent Technology
**\n", 30 | "\n", 31 | "**
Homework Assignment: 04
**\n", 32 | "\n", 33 | "**
Flow Control Statements
**\n", 34 | "\n", 35 | "**
21/10/2021
**\n", 36 | "\n", 37 | "
\n", 38 | "\n", 39 | "**
Submitted by:
**\n", 40 | "\n", 41 | "**
Milan(米兰) 0318021907632 (2005)
**\n", 42 | "**
QQ: 3086215265 | Github ID: milaan9
**" 43 | ] 44 | }, 45 | { 46 | "cell_type": "markdown", 47 | "metadata": {}, 48 | "source": [ 49 | "# Instructions: \n", 50 | "\n", 51 | "\n", 52 | "1. I have added tips and required learning resources for each question, which helps you to solve the problems. \n", 53 | "\n", 54 | "2. Finish the assignment on your **OWN**. **Any student find copying/sharing from classmates or internet will get '0' points!!!**\n", 55 | "\n", 56 | "3. After Accepting this assignment from ➞ **[GitHub Clasroom link](https://classroom.github.com/a/zeslyIXN)**, Github will create private repository of the assignment in your GitHub Classroom account.\n", 57 | "\n", 58 | "4. In your repository CloneDownload ZIP in your computer.\n", 59 | "\n", 60 | "5. Change your ➞ **College**, **Major**, **Name**, **Student number**, **Class number**, **QQ number** and **GitHub ID**\n", 61 | "\n", 62 | "6. Once you finish the Assignment **[convert your .ipynb file into PDF](https://github.com/milaan9/91_Python_Mini_Projects/tree/main/001_Convert_IPython_to_PDF)** (both **.ipynb** and **.pdf** file will be required!)\n", 63 | "\n", 64 | "7. To submit your assignment, go to GitHub Classroom repository and Add fileUpload filesCommit changes\n", 65 | " 1. Replace the question (**.ipynb**) file with your solution (**.ipynb**) file.\n", 66 | " 2. Also, upload (**.pdf**) converted file of your solution (**.ipynb**) file." 67 | ] 68 | }, 69 | { 70 | "cell_type": "markdown", 71 | "metadata": {}, 72 | "source": [ 73 | "# Python Assignment 04" 74 | ] 75 | }, 76 | { 77 | "cell_type": "markdown", 78 | "metadata": {}, 79 | "source": [ 80 | "# Part A ➞ If-elif-else Statements Level 1, 2 & 3\n", 81 | "\n", 82 | ">**Note:** Please create new cell for each question" 83 | ] 84 | }, 85 | { 86 | "cell_type": "markdown", 87 | "metadata": {}, 88 | "source": [ 89 | "### Part A ➞ Level 1\n", 90 | ">**Note:** Please create new cell for each question\n", 91 | "\n", 92 | "1. Get two numbers from the user using **`input()`** prompt. \n", 93 | " - If **`num_1`** is greater than **`num_2`** return **`num_1`** is greater than **`num_2`**, \n", 94 | " - if **`num_1`** is less **`num_2`** return **`num_1`** is smaller than **`num_2`**, \n", 95 | " - else **`num_1`** is equal to **`num_2`**. \n", 96 | "\n", 97 | " - ```sh\n", 98 | "Enter number one: 9\n", 99 | "Enter number two: 6\n", 100 | "9 is greater than 6\n", 101 | " ```" 102 | ] 103 | }, 104 | { 105 | "cell_type": "code", 106 | "execution_count": null, 107 | "metadata": {}, 108 | "outputs": [], 109 | "source": [ 110 | "# Solution: \n", 111 | "\n" 112 | ] 113 | }, 114 | { 115 | "cell_type": "markdown", 116 | "metadata": {}, 117 | "source": [ 118 | "### Part A ➞ Level 2\n", 119 | ">**Note:** Please create new cell for each question\n", 120 | "\n", 121 | "1. Write a code which gives grade to students according to theirs scores get from user **`input()`**:\n", 122 | " \n", 123 | " - ```sy\n", 124 | " 80-100, A\n", 125 | " 70-89, B\n", 126 | " 60-69, C\n", 127 | " 50-59, D\n", 128 | " 0-49, F\n", 129 | " ```\n", 130 | "\n", 131 | "2. Check if the season is **`Autumn`**, **`Winter`**, **`Spring`** or **`Summer`**. \n", 132 | " - If the user **`input()`** is:\n", 133 | " - September, October or November, the season is Autumn.\n", 134 | " - December, January or February, the season is Winter.\n", 135 | " - March, April or May, the season is Spring\n", 136 | " - June, July or August, the season is Summer\n", 137 | "\n", 138 | "\n", 139 | "3. The following list contains some fruits:\n", 140 | " - Taker user **`input()`** and if a fruit doesn't exist in the list add the fruit to the list and print the modified list. If the fruit exists print **`('That fruit already exist in the list')`** \n", 141 | " \n", 142 | " ```py\n", 143 | " fruits = ['banana', 'orange', 'mango', 'pear']\n", 144 | " ``` " 145 | ] 146 | }, 147 | { 148 | "cell_type": "markdown", 149 | "metadata": {}, 150 | "source": [ 151 | "### Part A ➞ Level 3\n", 152 | ">**Note:** Please create new cell for each question\n", 153 | "\n", 154 | "1. Here we have a person dictionary. Feel free to modify it!\n", 155 | " \n", 156 | " - ```py\n", 157 | " person={\n", 158 | " 'first_name': 'Milaan',\n", 159 | " 'last_name': 'Parmar',\n", 160 | " 'age': 96,\n", 161 | " 'country': 'England',\n", 162 | " 'is_marred': True,\n", 163 | " 'skills': ['Python', 'Matlab', 'R', 'C', 'C++'],\n", 164 | " 'address': {\n", 165 | " 'street': 'Space street',\n", 166 | " 'zipcode': '02210'\n", 167 | " }\n", 168 | " }\n", 169 | " ```\n", 170 | "\n", 171 | " * Check if the person dictionary has **`skills`** key, if so print out the middle skill in the skills list.\n", 172 | " * Check if the person dictionary has **`skills`** key, if so check if the person has 'Python' skill and print out the result.\n", 173 | " * If a person skills has only Python and Matlab, print ('He knows machine learning'), if the person skills has Python, and R print ('He knows statistics'), if the person skills has C, and C++, Print ('He knows software development'), else print ('unknown title') - for more accurate results more conditions can be nested!\n", 174 | " * If the person is married and if he lives in England, print the information in the following format:\n", 175 | "\n", 176 | " - ```sy\n", 177 | " Milaan Parmar lives in England. He is married.\n", 178 | " ```" 179 | ] 180 | }, 181 | { 182 | "cell_type": "code", 183 | "execution_count": null, 184 | "metadata": {}, 185 | "outputs": [], 186 | "source": [ 187 | "# Solution: \n", 188 | "\n" 189 | ] 190 | }, 191 | { 192 | "cell_type": "markdown", 193 | "metadata": {}, 194 | "source": [ 195 | "# Part B ➞ Loops Level 1, 2 and 3\n", 196 | "\n", 197 | ">**Note:** Please create new cell for each question" 198 | ] 199 | }, 200 | { 201 | "cell_type": "markdown", 202 | "metadata": {}, 203 | "source": [ 204 | "### Part B ➞ Level 1\n", 205 | ">**Note:** Please create new cell for each question\n", 206 | "\n", 207 | "1. Iterate 0 to 10 using **`for`** loop, do the same using **`while`** loop.\n", 208 | "2. Iterate 10 to 0 using **`for`** loop, do the same using **`while`** loop.\n", 209 | "3. Write a code so we get on the output the following square by taking **`input()`** from user:\n", 210 | "\n", 211 | " - ```sy\n", 212 | "# = # = # = # = #\n", 213 | "# = # = # = # = #\n", 214 | "# = # = # = # = #\n", 215 | "# = # = # = # = #\n", 216 | "# = # = # = # = #\n", 217 | "# = # = # = # = #\n", 218 | "# = # = # = # = #\n", 219 | "# = # = # = # = #\n", 220 | " ```\n", 221 | "\n", 222 | "4. Use nested loops to create the following by taking **`input()`** from user:\n", 223 | "\n", 224 | "```sy\n", 225 | " #\n", 226 | " ###\n", 227 | " #####\n", 228 | " #######\n", 229 | " #########\n", 230 | " ###########\n", 231 | "#############\n", 232 | "```\n", 233 | "\n", 234 | "5. Print the following using loops by taking **`input()`** from user:\n", 235 | "\n", 236 | " - ```sy\n", 237 | " 0 x 0 = 0\n", 238 | " 1 x 1 = 1\n", 239 | " 2 x 2 = 4\n", 240 | " 3 x 3 = 9\n", 241 | " 4 x 4 = 16\n", 242 | " 5 x 5 = 25\n", 243 | " 6 x 6 = 36\n", 244 | " 7 x 7 = 49\n", 245 | " 8 x 8 = 64\n", 246 | " 9 x 9 = 81\n", 247 | " 10 x 10 = 100\n", 248 | " ```\n", 249 | "\n", 250 | "6. Iterate through the list, **`['Python', 'Numpy', 'Pandas', 'Scikit', 'Pytorch']`** using a **`for`** loop and print out the items.\n", 251 | "\n", 252 | "7. Use **`while`** loop to iterate from 0 to 100 and print the sum of all numbers.\n", 253 | "\n", 254 | " - ```py\n", 255 | " The sum of all numbers is 5050.\n", 256 | " ```\n", 257 | " \n", 258 | "8. Use **`for`** loop to iterate from 0 to 100 and print the sum of all evens and the sum of all odds.\n", 259 | "\n", 260 | " - ```py\n", 261 | " The sum of all evens is 2550. And the sum of all odds is 2500.\n", 262 | " ```" 263 | ] 264 | }, 265 | { 266 | "cell_type": "code", 267 | "execution_count": null, 268 | "metadata": {}, 269 | "outputs": [], 270 | "source": [ 271 | "# Solution: \n", 272 | "\n" 273 | ] 274 | }, 275 | { 276 | "cell_type": "markdown", 277 | "metadata": {}, 278 | "source": [ 279 | "### Part B ➞ Level 2\n", 280 | ">**Note:** Please create new cell for each question\n", 281 | "\n", 282 | "1. Use **`for`** loop to find fibonacci numbers from from 0 to 100 and print only even numbers from it. Also, find how many even numbers are in it.\n", 283 | "2. Use **`while`** loop to find fibonacci numbers from from 0 to 100 and print only odd numbers from it. Also find how many odd numbers are in it." 284 | ] 285 | }, 286 | { 287 | "cell_type": "markdown", 288 | "metadata": {}, 289 | "source": [ 290 | "### Part B ➞ Level 3\n", 291 | ">**Note:** Please create new cell for each question\n", 292 | "\n", 293 | "1. Go to the data folder and use the **[countries_data.py](https://github.com/milaan9/02_Python_Datatypes/blob/main/countries_data.py)** file. Loop through the countries and extract all the countries containing the word **`land`**.\n", 294 | "2. This is a fruit list, **`['banana', 'orange', 'mango', 'lemon']`** reverse the order using loop.\n", 295 | "3. Go to the data folder and use the **[countries_details_data.py](https://github.com/milaan9/03_Python_Flow_Control/blob/main/countries_details_data.py)** file. \n", 296 | " 1. What are the total number of languages in the data\n", 297 | " 2. Find the ten most spoken languages from the data\n", 298 | " 3. Find the 10 most populated countries in the world" 299 | ] 300 | }, 301 | { 302 | "cell_type": "code", 303 | "execution_count": null, 304 | "metadata": {}, 305 | "outputs": [], 306 | "source": [ 307 | "# Solution: \n", 308 | "\n" 309 | ] 310 | } 311 | ], 312 | "metadata": { 313 | "hide_input": false, 314 | "kernelspec": { 315 | "display_name": "Python 3", 316 | "language": "python", 317 | "name": "python3" 318 | }, 319 | "language_info": { 320 | "codemirror_mode": { 321 | "name": "ipython", 322 | "version": 3 323 | }, 324 | "file_extension": ".py", 325 | "mimetype": "text/x-python", 326 | "name": "python", 327 | "nbconvert_exporter": "python", 328 | "pygments_lexer": "ipython3", 329 | "version": "3.8.8" 330 | }, 331 | "toc": { 332 | "base_numbering": 1, 333 | "nav_menu": {}, 334 | "number_sections": true, 335 | "sideBar": true, 336 | "skip_h1_title": false, 337 | "title_cell": "Table of Contents", 338 | "title_sidebar": "Contents", 339 | "toc_cell": false, 340 | "toc_position": {}, 341 | "toc_section_display": true, 342 | "toc_window_display": false 343 | }, 344 | "varInspector": { 345 | "cols": { 346 | "lenName": 16, 347 | "lenType": 16, 348 | "lenVar": 40 349 | }, 350 | "kernels_config": { 351 | "python": { 352 | "delete_cmd_postfix": "", 353 | "delete_cmd_prefix": "del ", 354 | "library": "var_list.py", 355 | "varRefreshCmd": "print(var_dic_list())" 356 | }, 357 | "r": { 358 | "delete_cmd_postfix": ") ", 359 | "delete_cmd_prefix": "rm(", 360 | "library": "var_list.r", 361 | "varRefreshCmd": "cat(var_dic_list()) " 362 | } 363 | }, 364 | "types_to_exclude": [ 365 | "module", 366 | "function", 367 | "builtin_function_or_method", 368 | "instance", 369 | "_Feature" 370 | ], 371 | "window_display": false 372 | } 373 | }, 374 | "nbformat": 4, 375 | "nbformat_minor": 2 376 | } 377 | -------------------------------------------------------------------------------- /005_Python_HW_Assignment_05.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "ExecuteTime": { 7 | "end_time": "2021-07-20T09:16:22.081113Z", 8 | "start_time": "2021-07-20T09:16:22.072320Z" 9 | } 10 | }, 11 | "source": [ 12 | "         **JLUFE**                                   **Fall 2021(Sep-Jan)** \n", 13 | "\n", 14 | "\n", 15 | "**
Homework Assignment Report
**\n", 16 | "
\n", 17 | "\n", 18 | "**
JILIN UNIVERSITY OF FINANCE AND ECONOMICS
**\n", 19 | "
\n", 20 | "\n", 21 | "**
College of Managment Science and Information Engineering
**\n", 22 | "\n", 23 | "**
BSc in Data Science and Big Data Technology
**\n", 24 | "\n", 25 | "**
(2021)
**\n", 26 | "\n", 27 | "
\n", 28 | "\n", 29 | "**
MODULE: Intelligent Technology
**\n", 30 | "\n", 31 | "**
Homework Assignment: 05
**\n", 32 | "\n", 33 | "**
Functions
**\n", 34 | "\n", 35 | "**
04/11/2021
**\n", 36 | "\n", 37 | "
\n", 38 | "\n", 39 | "**
Submitted by:
**\n", 40 | "\n", 41 | "**
Milan(米兰) 0318021907632 (2005)
**\n", 42 | "**
QQ: 3086215265 | Github ID: milaan9
**" 43 | ] 44 | }, 45 | { 46 | "cell_type": "markdown", 47 | "metadata": {}, 48 | "source": [ 49 | "# Instructions: \n", 50 | "\n", 51 | "\n", 52 | "1. I have added tips and required learning resources for each question, which helps you to solve the problems. \n", 53 | "\n", 54 | "2. Finish the assignment on your **OWN**. **Any student find copying/sharing from classmates or internet will get '0' points!!!**\n", 55 | "\n", 56 | "3. After Accepting this assignment from ➞ **[GitHub Clasroom link](https://classroom.github.com/a/I_ScEHXx)**, Github will create private repository of the assignment in your GitHub Classroom account.\n", 57 | "\n", 58 | "4. In your repository CloneDownload ZIP in your computer.\n", 59 | "\n", 60 | "5. Change your ➞ **College**, **Major**, **Name**, **Student number**, **Class number**, **QQ number** and **GitHub ID**\n", 61 | "\n", 62 | "6. Once you finish the Assignment **[convert your .ipynb file into PDF](https://github.com/milaan9/91_Python_Mini_Projects/tree/main/001_Convert_IPython_to_PDF)** (both **.ipynb** and **.pdf** file will be required!)\n", 63 | "\n", 64 | "7. To submit your assignment, go to GitHub Classroom repository and Add fileUpload filesCommit changes\n", 65 | " 1. Replace the question (**.ipynb**) file with your solution (**.ipynb**) file.\n", 66 | " 2. Also, upload (**.pdf**) converted file of your solution (**.ipynb**) file." 67 | ] 68 | }, 69 | { 70 | "cell_type": "markdown", 71 | "metadata": {}, 72 | "source": [ 73 | "# Python Assignment 05" 74 | ] 75 | }, 76 | { 77 | "cell_type": "markdown", 78 | "metadata": {}, 79 | "source": [ 80 | "# Functions ➞ Level 1, 2 & 3\n", 81 | "\n", 82 | ">**Note:** Please create new cell for each question" 83 | ] 84 | }, 85 | { 86 | "cell_type": "markdown", 87 | "metadata": {}, 88 | "source": [ 89 | "### Part A ➞ Level 1\n", 90 | ">**Note:** Please create new cell for each question\n", 91 | "\n", 92 | "1. Area of a circle is calculated as follows: **area = $πr^2$** and **perimeter = $2πr$**. Write a function that calculates **`area_of_circle`** and **`perimeter_of_circle`** by taking user input for value of **`r`**.\n", 93 | "2. Write a function called **`add_all_nums`** which takes arbitrary number of arguments and sums all the arguments. Check if all the list items are number data types. If not do give a reasonable feedback.\n", 94 | "3. Temperature in **°C** can be converted to **°F** using this formula: **°F = $(°C * 9/5) + 32$**. Write a function which converts **°C to °F**, **`convert_celsius_2_fahrenheit`**.\n", 95 | "4. Write a function called **`check_season`**, it takes a month parameter and returns the season: **`Autumn`**, **`Winter`**, **`Spring`** or **`Summer`**.\n", 96 | "5. Write a function called **`calculate_slope`** which return the slope of a linear equation\n", 97 | "6. Quadratic equation is calculated as follows: **$ax² + bx + c = 0$**. Write a function which calculates solution set of a quadratic equation, **`solve_quadratic_eqn`**.\n", 98 | "7. Declare a function named **`print_list`**. It takes a list as a parameter and it prints out each element of the list.\n", 99 | "8. Declare a function named **`reverse_list`**. It takes an array as a parameter and it returns the reverse of the array (use loops).\n", 100 | "\n", 101 | " - ```py\n", 102 | "print(reverse_list([1, 2, 3, 4, 5]))\n", 103 | "#[5, 4, 3, 2, 1]\n", 104 | "print(reverse_list1([\"A\", \"B\", \"C\"]))\n", 105 | "#[\"C\", \"B\", \"A\"]\n", 106 | " ```\n", 107 | "\n", 108 | "9. Declare a function named **`capitalize_list_items`**. It takes a list as a parameter and it returns a capitalized list of items\n", 109 | "10. Declare a function named **`add_item`**. It takes a list and an item parameters. It returns a list with the item added at the end.\n", 110 | "\n", 111 | " - ```py\n", 112 | "food_staff = ['Potato', 'Tomato', 'Mango', 'Milk']\n", 113 | "print(add_item(food_staff, 'Fungi')) #['Potato', 'Tomato', 'Mango', 'Milk', 'Fungi']\n", 114 | "numbers = [2, 3, 7, 9]\n", 115 | "print(add_item(numbers, 5)) #[2, 3, 7, 9, 5]\n", 116 | " ```\n", 117 | "\n", 118 | "11. Declare a function named **`remove_item`**. It takes a list and an item parameters. It returns a list with the item removed from it.\n", 119 | "\n", 120 | " - ```py\n", 121 | "food_staff = ['Potato', 'Tomato', 'Mango', 'Milk']\n", 122 | "print(remove_item(food_staff, 'Mango')) # ['Potato', 'Tomato', 'Milk']\n", 123 | "numbers = [2, 3, 7, 9]\n", 124 | "print(remove_item(numbers, 3)) # [2, 7, 9]\n", 125 | " ```\n", 126 | "\n", 127 | "12. Declare a function named **`sum_of_numbers`**. It takes a number parameter and it adds all the numbers in that range.\n", 128 | "\n", 129 | " - ```sh\n", 130 | "print(sum_of_numbers(5)) # 15\n", 131 | "print(sum_all_numbers(10)) # 55\n", 132 | "print(sum_all_numbers(100)) # 5050\n", 133 | " ```\n", 134 | "\n", 135 | "13. Declare a function named **`sum_of_odds`**. It takes a number parameter and it adds all the odd numbers in that range.\n", 136 | "14. Declare a function named **`sum_of_even`**. It takes a number parameter and it adds all the even numbers in that range." 137 | ] 138 | }, 139 | { 140 | "cell_type": "code", 141 | "execution_count": null, 142 | "metadata": {}, 143 | "outputs": [], 144 | "source": [ 145 | "# Solution: \n", 146 | "\n" 147 | ] 148 | }, 149 | { 150 | "cell_type": "markdown", 151 | "metadata": {}, 152 | "source": [ 153 | "### Part B ➞ Level 2\n", 154 | ">**Note:** Please create new cell for each question\n", 155 | "\n", 156 | "1. Declare a function named **`evens_and_odds`**. It takes a positive integer as parameter and it counts number of evens and odds in the number.\n", 157 | "\n", 158 | " - ```py\n", 159 | " print(evens_and_odds(100))\n", 160 | " #The number of odds are 50.\n", 161 | " #The number of evens are 51.\n", 162 | " ```\n", 163 | "\n", 164 | "2. Call your function **`factorial`**, it takes a whole number as a parameter and it return a factorial of the number\n", 165 | "3. Call your function **`is_empty`**, it takes a parameter and it checks if it is empty or not\n", 166 | "4. Write different functions which take lists. They should **`calculate_mean`**, **`calculate_median`**, **`calculate_mode`**, **`calculate_range`**, **`calculate_variance`**, **`calculate_std`** (standard deviation)." 167 | ] 168 | }, 169 | { 170 | "cell_type": "code", 171 | "execution_count": null, 172 | "metadata": {}, 173 | "outputs": [], 174 | "source": [ 175 | "# Solution: \n", 176 | "\n" 177 | ] 178 | }, 179 | { 180 | "cell_type": "markdown", 181 | "metadata": {}, 182 | "source": [ 183 | "### Part C ➞ Level 3\n", 184 | ">**Note:** Please create new cell for each question\n", 185 | "\n", 186 | "1. Write a function called **`is_prime`**, which checks if a number is prime and prints all prime numbers in that range.\n", 187 | "2. Write a functions which checks if all items are *unique* in the list.\n", 188 | "3. Write a function which checks if all the items of the list are of the *same data type*.\n", 189 | "4. Write a function which check if provided variable is a valid *python variable*\n", 190 | "5. Go to the data folder and access the **[countries-data.py](https://github.com/milaan9/03_Python_Flow_Control/blob/main/countries_details_data.py)** file.\n", 191 | "\n", 192 | "- Create a function called the **`most_spoken_languages`** in the world. It should return 10 or 20 most spoken languages in the world in descending order\n", 193 | "- Create a function called the **`most_populated_countries`**. It should return 10 or 20 most populated countries in descending order." 194 | ] 195 | }, 196 | { 197 | "cell_type": "code", 198 | "execution_count": null, 199 | "metadata": {}, 200 | "outputs": [], 201 | "source": [ 202 | "# Solution: \n", 203 | "\n" 204 | ] 205 | } 206 | ], 207 | "metadata": { 208 | "hide_input": false, 209 | "kernelspec": { 210 | "display_name": "Python 3", 211 | "language": "python", 212 | "name": "python3" 213 | }, 214 | "language_info": { 215 | "codemirror_mode": { 216 | "name": "ipython", 217 | "version": 3 218 | }, 219 | "file_extension": ".py", 220 | "mimetype": "text/x-python", 221 | "name": "python", 222 | "nbconvert_exporter": "python", 223 | "pygments_lexer": "ipython3", 224 | "version": "3.8.8" 225 | }, 226 | "toc": { 227 | "base_numbering": 1, 228 | "nav_menu": {}, 229 | "number_sections": true, 230 | "sideBar": true, 231 | "skip_h1_title": false, 232 | "title_cell": "Table of Contents", 233 | "title_sidebar": "Contents", 234 | "toc_cell": false, 235 | "toc_position": {}, 236 | "toc_section_display": true, 237 | "toc_window_display": false 238 | }, 239 | "varInspector": { 240 | "cols": { 241 | "lenName": 16, 242 | "lenType": 16, 243 | "lenVar": 40 244 | }, 245 | "kernels_config": { 246 | "python": { 247 | "delete_cmd_postfix": "", 248 | "delete_cmd_prefix": "del ", 249 | "library": "var_list.py", 250 | "varRefreshCmd": "print(var_dic_list())" 251 | }, 252 | "r": { 253 | "delete_cmd_postfix": ") ", 254 | "delete_cmd_prefix": "rm(", 255 | "library": "var_list.r", 256 | "varRefreshCmd": "cat(var_dic_list()) " 257 | } 258 | }, 259 | "types_to_exclude": [ 260 | "module", 261 | "function", 262 | "builtin_function_or_method", 263 | "instance", 264 | "_Feature" 265 | ], 266 | "window_display": false 267 | } 268 | }, 269 | "nbformat": 4, 270 | "nbformat_minor": 2 271 | } 272 | -------------------------------------------------------------------------------- /006_Python_HW_Assignment_06.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "ExecuteTime": { 7 | "end_time": "2021-07-20T09:16:22.081113Z", 8 | "start_time": "2021-07-20T09:16:22.072320Z" 9 | } 10 | }, 11 | "source": [ 12 | "         **JLUFE**                                   **Fall 2021(Sep-Jan)** \n", 13 | "\n", 14 | "\n", 15 | "**
Homework Assignment Report
**\n", 16 | "
\n", 17 | "\n", 18 | "**
JILIN UNIVERSITY OF FINANCE AND ECONOMICS
**\n", 19 | "
\n", 20 | "\n", 21 | "**
College of Managment Science and Information Engineering
**\n", 22 | "\n", 23 | "**
BSc in Data Science and Big Data Technology
**\n", 24 | "\n", 25 | "**
(2021)
**\n", 26 | "\n", 27 | "
\n", 28 | "\n", 29 | "**
MODULE: Intelligent Technology
**\n", 30 | "\n", 31 | "**
Homework Assignment: 06
**\n", 32 | "\n", 33 | "**
Modules
**\n", 34 | "\n", 35 | "**
11/11/2021
**\n", 36 | "\n", 37 | "
\n", 38 | "\n", 39 | "**
Submitted by:
**\n", 40 | "\n", 41 | "**
Milan(米兰) 0318021907632 (2005)
**\n", 42 | "**
QQ: 3086215265 | Github ID: milaan9
**" 43 | ] 44 | }, 45 | { 46 | "cell_type": "markdown", 47 | "metadata": {}, 48 | "source": [ 49 | "# Instructions: \n", 50 | "\n", 51 | "\n", 52 | "1. I have added tips and required learning resources for each question, which helps you to solve the problems. \n", 53 | "\n", 54 | "2. Finish the assignment on your **OWN**. **Any student find copying/sharing from classmates or internet will get '0' points!!!**\n", 55 | "\n", 56 | "3. After Accepting this assignment from ➞ **[GitHub Clasroom link](https://classroom.github.com/a/QtweKsi5)**, Github will create private repository of the assignment in your GitHub Classroom account.\n", 57 | "\n", 58 | "4. In your repository CloneDownload ZIP in your computer.\n", 59 | "\n", 60 | "5. Change your ➞ **College**, **Major**, **Name**, **Student number**, **Class number**, **QQ number** and **GitHub ID**\n", 61 | "\n", 62 | "6. Once you finish the Assignment **[convert your .ipynb file into PDF](https://github.com/milaan9/91_Python_Mini_Projects/tree/main/001_Convert_IPython_to_PDF)** (both **.ipynb** and **.pdf** file will be required!)\n", 63 | "\n", 64 | "7. To submit your assignment, go to GitHub Classroom repository and Add fileUpload filesCommit changes\n", 65 | " 1. Replace the question (**.ipynb**) file with your solution (**.ipynb**) file.\n", 66 | " 2. Also, upload (**.pdf**) converted file of your solution (**.ipynb**) file." 67 | ] 68 | }, 69 | { 70 | "cell_type": "markdown", 71 | "metadata": {}, 72 | "source": [ 73 | "# Python Assignment 06" 74 | ] 75 | }, 76 | { 77 | "cell_type": "markdown", 78 | "metadata": {}, 79 | "source": [ 80 | "# Modules ➞ Level 1, 2 & 3\n", 81 | "\n", 82 | ">**Note:** Please create new cell for each question" 83 | ] 84 | }, 85 | { 86 | "cell_type": "markdown", 87 | "metadata": {}, 88 | "source": [ 89 | "### Part A ➞ Level 1\n", 90 | ">**Note:** Please create new cell for each question\n", 91 | "\n", 92 | "1. Writ a function which generates a six digit/character **`random_user_id`**.\n", 93 | " - ```py\n", 94 | " print(random_user_id());\n", 95 | " '1ee33d'\n", 96 | " ```\n", 97 | "2. Modify the previous task. Declare a function named **`user_id_gen_by_user`**. It doesn’t take any parameters but it takes two inputs using **`input()`**. One of the inputs is the number of characters and the second input is the number of IDs which are supposed to be generated.\n", 98 | " \n", 99 | " - ```py\n", 100 | "print(user_id_gen_by_user()) # user input: 5 5\n", 101 | "#output:\n", 102 | "#kcsy2\n", 103 | "#SMFYb\n", 104 | "#bWmeq\n", 105 | "#ZXOYh\n", 106 | "#2Rgxf\n", 107 | " ``` \n", 108 | " \n", 109 | " - ```py\n", 110 | "print(user_id_gen_by_user()) # 16 5\n", 111 | "#1GCSgPLMaBAVQZ26\n", 112 | "#YD7eFwNQKNs7qXaT\n", 113 | "#ycArC5yrRupyG00S\n", 114 | "#UbGxOFI7UXSWAyKN\n", 115 | "#dIV0SSUTgAdKwStr\n", 116 | " ```\n", 117 | "\n", 118 | "3. Write a function named **`rgb_color_gen`**. It will generate rgb colors (3 values ranging from 0 to 255 each).\n", 119 | " \n", 120 | " - ```py\n", 121 | "print(rgb_color_gen()) \n", 122 | "#rgb(125,244,255) - the output should be in this form\n", 123 | " ```" 124 | ] 125 | }, 126 | { 127 | "cell_type": "code", 128 | "execution_count": null, 129 | "metadata": {}, 130 | "outputs": [], 131 | "source": [ 132 | "# Solution: \n", 133 | "\n" 134 | ] 135 | }, 136 | { 137 | "cell_type": "markdown", 138 | "metadata": {}, 139 | "source": [ 140 | "### Part B ➞ Level 2\n", 141 | ">**Note:** Please create new cell for each question\n", 142 | "\n", 143 | "1. Write a function **`list_of_hexa_colors`** which returns any number of hexadecimal colors in an array (six hexadecimal numbers written after **`#`**. Hexadecimal numeral system is made out of 16 symbols, 0-9 and first 6 letters of the alphabet, a-f. Check the task 6 for output examples).\n", 144 | "2. Write a function **`list_of_rgb_colors`** which returns any number of RGB colors in an array.\n", 145 | "3. Write a function **`generate_colors`** which can generate any number of hexa or rgb colors.\n", 146 | "\n", 147 | " - ```py\n", 148 | " generate_colors('hexa', 3) # ['#a3e12f','#03ed55','#eb3d2b'] \n", 149 | " generate_colors('hexa', 1) # ['#b334ef']\n", 150 | " generate_colors('rgb', 3) # ['rgb(5, 55, 175','rgb(50, 105, 100','rgb(15, 26, 80'] \n", 151 | " generate_colors('rgb', 1) # ['rgb(33,79, 176)']\n", 152 | " ```" 153 | ] 154 | }, 155 | { 156 | "cell_type": "code", 157 | "execution_count": null, 158 | "metadata": {}, 159 | "outputs": [], 160 | "source": [ 161 | "# Solution: \n", 162 | "\n" 163 | ] 164 | }, 165 | { 166 | "cell_type": "markdown", 167 | "metadata": {}, 168 | "source": [ 169 | "### Part C ➞ Level 3\n", 170 | ">**Note:** Please create new cell for each question\n", 171 | "\n", 172 | "1. Call your function **`shuffle_list`**, it takes a list as a parameter and it returns a shuffled list\n", 173 | "2. Write a function which returns an array of seven random numbers in a range of 0-9. All the numbers must be unique." 174 | ] 175 | }, 176 | { 177 | "cell_type": "code", 178 | "execution_count": null, 179 | "metadata": {}, 180 | "outputs": [], 181 | "source": [ 182 | "# Solution: \n", 183 | "\n" 184 | ] 185 | } 186 | ], 187 | "metadata": { 188 | "hide_input": false, 189 | "kernelspec": { 190 | "display_name": "Python 3", 191 | "language": "python", 192 | "name": "python3" 193 | }, 194 | "language_info": { 195 | "codemirror_mode": { 196 | "name": "ipython", 197 | "version": 3 198 | }, 199 | "file_extension": ".py", 200 | "mimetype": "text/x-python", 201 | "name": "python", 202 | "nbconvert_exporter": "python", 203 | "pygments_lexer": "ipython3", 204 | "version": "3.8.8" 205 | }, 206 | "toc": { 207 | "base_numbering": 1, 208 | "nav_menu": {}, 209 | "number_sections": true, 210 | "sideBar": true, 211 | "skip_h1_title": false, 212 | "title_cell": "Table of Contents", 213 | "title_sidebar": "Contents", 214 | "toc_cell": false, 215 | "toc_position": {}, 216 | "toc_section_display": true, 217 | "toc_window_display": false 218 | }, 219 | "varInspector": { 220 | "cols": { 221 | "lenName": 16, 222 | "lenType": 16, 223 | "lenVar": 40 224 | }, 225 | "kernels_config": { 226 | "python": { 227 | "delete_cmd_postfix": "", 228 | "delete_cmd_prefix": "del ", 229 | "library": "var_list.py", 230 | "varRefreshCmd": "print(var_dic_list())" 231 | }, 232 | "r": { 233 | "delete_cmd_postfix": ") ", 234 | "delete_cmd_prefix": "rm(", 235 | "library": "var_list.r", 236 | "varRefreshCmd": "cat(var_dic_list()) " 237 | } 238 | }, 239 | "types_to_exclude": [ 240 | "module", 241 | "function", 242 | "builtin_function_or_method", 243 | "instance", 244 | "_Feature" 245 | ], 246 | "window_display": false 247 | } 248 | }, 249 | "nbformat": 4, 250 | "nbformat_minor": 2 251 | } 252 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # JLUFE_Python_Assignment_template 2 | -------------------------------------------------------------------------------- /happynumbers1_1000.txt: -------------------------------------------------------------------------------- 1 | 1 2 | 7 3 | 10 4 | 13 5 | 19 6 | 23 7 | 28 8 | 31 9 | 32 10 | 44 11 | 49 12 | 68 13 | 70 14 | 79 15 | 82 16 | 86 17 | 91 18 | 94 19 | 97 20 | 100 21 | 103 22 | 109 23 | 129 24 | 130 25 | 133 26 | 139 27 | 167 28 | 176 29 | 188 30 | 190 31 | 192 32 | 193 33 | 203 34 | 208 35 | 219 36 | 226 37 | 230 38 | 236 39 | 239 40 | 262 41 | 263 42 | 280 43 | 291 44 | 293 45 | 301 46 | 302 47 | 310 48 | 313 49 | 319 50 | 320 51 | 326 52 | 329 53 | 331 54 | 338 55 | 356 56 | 362 57 | 365 58 | 367 59 | 368 60 | 376 61 | 379 62 | 383 63 | 386 64 | 391 65 | 392 66 | 397 67 | 404 68 | 409 69 | 440 70 | 446 71 | 464 72 | 469 73 | 478 74 | 487 75 | 490 76 | 496 77 | 536 78 | 556 79 | 563 80 | 565 81 | 566 82 | 608 83 | 617 84 | 622 85 | 623 86 | 632 87 | 635 88 | 637 89 | 638 90 | 644 91 | 649 92 | 653 93 | 655 94 | 656 95 | 665 96 | 671 97 | 673 98 | 680 99 | 683 100 | 694 101 | 700 102 | 709 103 | 716 104 | 736 105 | 739 106 | 748 107 | 761 108 | 763 109 | 784 110 | 790 111 | 793 112 | 802 113 | 806 114 | 818 115 | 820 116 | 833 117 | 836 118 | 847 119 | 860 120 | 863 121 | 874 122 | 881 123 | 888 124 | 899 125 | 901 126 | 904 127 | 907 128 | 910 129 | 912 130 | 913 131 | 921 132 | 923 133 | 931 134 | 932 135 | 937 136 | 940 137 | 946 138 | 964 139 | 970 140 | 973 141 | 989 142 | 998 143 | 1000 -------------------------------------------------------------------------------- /nameslist.txt: -------------------------------------------------------------------------------- 1 | Darth 2 | Luke 3 | Darth 4 | Leia 5 | Darth 6 | Leia 7 | Leia 8 | Luke 9 | Darth 10 | Leia 11 | Darth 12 | Darth 13 | Leia 14 | Leia 15 | Darth 16 | Leia 17 | Darth 18 | Leia 19 | Luke 20 | Darth 21 | Leia 22 | Leia 23 | Darth 24 | Leia 25 | Darth 26 | Darth 27 | Leia 28 | Leia 29 | Luke 30 | Luke 31 | Leia 32 | Darth 33 | Darth 34 | Luke 35 | Leia 36 | Darth 37 | Darth 38 | Leia 39 | Leia 40 | Leia 41 | Leia 42 | Leia 43 | Luke 44 | Darth 45 | Luke 46 | Leia 47 | Leia 48 | Leia 49 | Leia 50 | Luke 51 | Leia 52 | Darth 53 | Leia 54 | Leia 55 | Darth 56 | Leia 57 | Leia 58 | Darth 59 | Darth 60 | Leia 61 | Darth 62 | Leia 63 | Darth 64 | Luke 65 | Leia 66 | Luke 67 | Darth 68 | Darth 69 | Luke 70 | Darth 71 | Leia 72 | Darth 73 | Leia 74 | Luke 75 | Leia 76 | Leia 77 | Leia 78 | Leia 79 | Leia 80 | Darth 81 | Leia 82 | Leia 83 | Leia 84 | Leia 85 | Leia 86 | Leia 87 | Leia 88 | Luke 89 | Leia 90 | Leia 91 | Leia 92 | Leia 93 | Leia 94 | Leia 95 | Darth 96 | Luke 97 | Darth 98 | Leia 99 | Leia 100 | Darth -------------------------------------------------------------------------------- /primenumbers1_1000.txt: -------------------------------------------------------------------------------- 1 | 2 2 | 3 3 | 5 4 | 7 5 | 11 6 | 13 7 | 17 8 | 19 9 | 23 10 | 29 11 | 31 12 | 37 13 | 41 14 | 43 15 | 47 16 | 53 17 | 59 18 | 61 19 | 67 20 | 71 21 | 73 22 | 79 23 | 83 24 | 89 25 | 97 26 | 101 27 | 103 28 | 107 29 | 109 30 | 113 31 | 127 32 | 131 33 | 137 34 | 139 35 | 149 36 | 151 37 | 157 38 | 163 39 | 167 40 | 173 41 | 179 42 | 181 43 | 191 44 | 193 45 | 197 46 | 199 47 | 211 48 | 223 49 | 227 50 | 229 51 | 233 52 | 239 53 | 241 54 | 251 55 | 257 56 | 263 57 | 269 58 | 271 59 | 277 60 | 281 61 | 283 62 | 293 63 | 307 64 | 311 65 | 313 66 | 317 67 | 331 68 | 337 69 | 347 70 | 349 71 | 353 72 | 359 73 | 367 74 | 373 75 | 379 76 | 383 77 | 389 78 | 397 79 | 401 80 | 409 81 | 419 82 | 421 83 | 431 84 | 433 85 | 439 86 | 443 87 | 449 88 | 457 89 | 461 90 | 463 91 | 467 92 | 479 93 | 487 94 | 491 95 | 499 96 | 503 97 | 509 98 | 521 99 | 523 100 | 541 101 | 547 102 | 557 103 | 563 104 | 569 105 | 571 106 | 577 107 | 587 108 | 593 109 | 599 110 | 601 111 | 607 112 | 613 113 | 617 114 | 619 115 | 631 116 | 641 117 | 643 118 | 647 119 | 653 120 | 659 121 | 661 122 | 673 123 | 677 124 | 683 125 | 691 126 | 701 127 | 709 128 | 719 129 | 727 130 | 733 131 | 739 132 | 743 133 | 751 134 | 757 135 | 761 136 | 769 137 | 773 138 | 787 139 | 797 140 | 809 141 | 811 142 | 821 143 | 823 144 | 827 145 | 829 146 | 839 147 | 853 148 | 857 149 | 859 150 | 863 151 | 877 152 | 881 153 | 883 154 | 887 155 | 907 156 | 911 157 | 919 158 | 929 159 | 937 160 | 941 161 | 947 162 | 953 163 | 967 164 | 971 165 | 977 166 | 983 167 | 991 168 | 997 --------------------------------------------------------------------------------