Test 1 - Python - sample
Sample Test I - Python
You have 90 minutes to complete the test. The only materials that are allowed to be used are the tutorials and sites linked at http://jug.dpieczynski.pl/proj-eocst. Any attempts to cooperate or use of the Internet for any other way will result in immediate test termination for involved students.
Before the deadline the solution have to uploaded to a specified page at the Moodle course. The upload form closes automatically at the deadline, be sure to upload the solution before that time! The form only accepts files with py
extension.
The solution should consist of two files:
- task1.py
- task2.py
Task 1
Write a Python script and save it as task1.py:
Load all contents of a file called homework.txt into a variable
Divide the text into a list of separate words. You can treat punctuation marks as part of the word.
Calculate the average word length in the text
Print words that start with letter
p
in the console
Bonus: remove punctuation characters during text processing
Task 2
Write a Python script and save it as task2.py:
- Using
requests
library, download the contents of a file located under the following URL and save it into a variable:
The text contains a comma-separated array of data. Convert the text into a
numpy
array, where rows are lines of the input file. Try to make your code universal (i.e. avoid hardcoding number of columns/rows).Plot the data using
matplotlib
, treating the first column asx
values and all other columns asy
values. The plot should show three trigonometric functions if everything was done correctly.
Authors: Jakub TomczyĆski