├── .gitignore ├── img ├── author_image.png └── shield_image.png ├── course.yml ├── README.md └── chapter1.md /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_STORE 2 | .cache 3 | .ipynb_checkpoints 4 | .spyderproject 5 | -------------------------------------------------------------------------------- /img/author_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunalj101/Python_advanced_Hackathon/master/img/author_image.png -------------------------------------------------------------------------------- /img/shield_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunalj101/Python_advanced_Hackathon/master/img/shield_image.png -------------------------------------------------------------------------------- /course.yml: -------------------------------------------------------------------------------- 1 | title : Python advanced Hackathon 2 | instructors : 3 | - kunal.jain@analyticsvidhya.com 4 | description : This is an automatically generated demo course which will help you on your way to create an awesome DataCamp course. 5 | university : DataCamp 6 | difficulty_level : 2 7 | time_needed : 1 hour 8 | programming_language : python 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DataCamp Template Course 2 | 3 | 4 | 5 | This an automatically generated DataCamp course. You can start from these template files to create your own course. 6 | 7 | Changes you make to this GitHub repository are automatically reflected in the linked DataCamp course. This means that you can enjoy all the advantages of version control, collaboration, issue handling ... of GitHub. 8 | 9 | ## Workflow 10 | 11 | 1. Edit the markdown and yml files in this repository. You can use GitHub's online editor or use git locally and push your changes. 12 | 2. Check out your build attempts on the Dashboard. 13 | 3. Check out your automatically updated course on DataCamp 14 | 15 | ## Getting Started 16 | 17 | A DataCamp course consists of two types of files: 18 | 19 | - `course.yml`, a YAML-formatted file that's prepopulated with some general course information. 20 | - `chapterX.md`, a markdown file with: 21 | - a YAML header containing chapter information. 22 | - markdown chunks representing DataCamp Exercises. 23 | 24 | To learn more about the structure of a DataCamp course, check out the documentation. 25 | 26 | Every DataCamp exercise consists of different parts, read up about them here. A very important part about DataCamp exercises is to provide automated personalized feedback to students. In R, these so-called Submission Correctness Tests (SCTs) are written with the `testwhat` package. SCTs for Python exercises are coded up with `pythonwhat`. Check out the GitHub repositories' wiki pages for more information and examples. 27 | 28 | Want to learn more? Check out the documentation on teaching at DataCamp. 29 | 30 | *Happy teaching!* 31 | -------------------------------------------------------------------------------- /chapter1.md: -------------------------------------------------------------------------------- 1 | --- 2 | title : Advanced Hackathon 3 | description : Insert the chapter description here 4 | attachments : 5 | slides_link : https://s3.amazonaws.com/assets.datacamp.com/course/teach/slides_example.pdf 6 | 7 | --- type:MultipleChoiceExercise lang:python xp:50 skills:1 key:ac16974427 8 | ## A really bad movie 9 | 10 | Have a look at the plot that showed up in the viewer to the right. Which type of movies have the worst rating assigned to them? 11 | 12 | *** =instructions 13 | - Long movies, clearly 14 | - Short movies, clearly 15 | - Long movies, but the correlation seems weak 16 | - Short movies, but the correlation seems weak 17 | 18 | *** =hint 19 | Have a look at the plot. Do you see a trend in the dots? 20 | 21 | *** =pre_exercise_code 22 | ```{r} 23 | # The pre exercise code runs code to initialize the user's workspace. 24 | # You can use it to load packages, initialize datasets and draw a plot in the viewer 25 | 26 | import pandas as pd 27 | import matplotlib.pyplot as plt 28 | 29 | movies = pd.read_csv("http://s3.amazonaws.com/assets.datacamp.com/course/introduction_to_r/movies.csv") 30 | 31 | plt.scatter(movies.runtime, movies.rating) 32 | plt.show() 33 | ``` 34 | 35 | *** =sct 36 | ```{r} 37 | # SCT written with pythonwhat: https://github.com/datacamp/pythonwhat/wiki 38 | 39 | msg_bad = "That is not correct!" 40 | msg_success = "Exactly! The correlation is very weak though." 41 | test_mc(4, [msg_bad, msg_bad, msg_bad, msg_success]) 42 | ``` 43 | 44 | --- type:NormalExercise lang:python xp:100 skills:1 key:2b713165d0 45 | ## Plot the movies yourself 46 | 47 | Do you remember the plot of the last exercise? Let's make an even cooler plot! 48 | 49 | A dataset of movies, `movies`, is available in the workspace. 50 | 51 | *** =instructions 52 | - The first function, `np.unique()`, uses the `unique()` function of the `numpy` package to get integer values for the movie genres. You don't have to change this code, just have a look! 53 | - Import `pyplot` in the `matplotlib` package. Set an alias for this import: `plt`. 54 | - Use `plt.scatter()` to plot `movies.runtime` onto the x-axis, `movies.rating` onto the y-axis and use `ints` for the color of the dots. You should use the first and second positional argument, and the `c` keyword. 55 | - Show the plot using `plt.show()`. 56 | 57 | *** =hint 58 | - You don't have to program anything for the first instruction, just take a look at the first line of code. 59 | - Use `import ___ as ___` to import `matplotlib.pyplot` as `plt`. 60 | - Use `plt.scatter(___, ___, c = ___)` for the third instruction. 61 | - You'll always have to type in `plt.show()` to show the plot you created. 62 | 63 | *** =pre_exercise_code 64 | ```{python} 65 | import pandas as pd 66 | movies = pd.read_csv("http://s3.amazonaws.com/assets.datacamp.com/course/introduction_to_r/movies.csv") 67 | 68 | import numpy as np 69 | ``` 70 | 71 | *** =sample_code 72 | ```{python} 73 | # Get integer values for genres 74 | _, ints = np.unique(movies.genre, return_inverse = True) 75 | 76 | # Import matplotlib.pyplot 77 | 78 | 79 | # Make a scatter plot: runtime on x-axis, rating on y-axis and set c to ints 80 | 81 | 82 | # Show the plot 83 | 84 | ``` 85 | 86 | *** =solution 87 | ```{python} 88 | # Get integer values for genres 89 | _, ints = np.unique(movies.genre, return_inverse = True) 90 | 91 | # Import matplotlib.pyplot 92 | import matplotlib.pyplot as plt 93 | 94 | # Make a scatter plot: runtime on x-axis, rating on y-axis and set c to ints 95 | plt.scatter(movies.runtime, movies.rating, c=ints) 96 | 97 | # Show the plot 98 | plt.show() 99 | ``` 100 | 101 | *** =sct 102 | ```{python} 103 | # SCT written with pythonwhat: https://github.com/datacamp/pythonwhat/wiki 104 | 105 | test_function("numpy.unique", 106 | not_called_msg = "Don't remove the call of `np.unique` to define `ints`.", 107 | incorrect_msg = "Don't change the call of `np.unique` to define `ints`.") 108 | 109 | test_object("ints", 110 | undefined_msg = "Don't remove the definition of the predefined `ints` object.", 111 | incorrect_msg = "Don't change the definition of the predefined `ints` object.") 112 | 113 | test_import("matplotlib.pyplot", same_as = True) 114 | 115 | test_function("matplotlib.pyplot.scatter", 116 | incorrect_msg = "You didn't use `plt.scatter()` correctly, have another look at the instructions.") 117 | 118 | test_function("matplotlib.pyplot.show") 119 | 120 | success_msg("Great work!") 121 | ``` 122 | --------------------------------------------------------------------------------