Tags:
create new tag
view all tags

Programming lab, log of the lectures

Lecture 24 Offline lecture (recovery)

Read and write json files: https://drive.google.com/file/d/1zYY_0FKsusB0aF8D0woNxN4G59su3awn/view?usp=sharing

Exercises with json files:

NOTE: the json module will not be an argument of the exam.

Lecture 23 23/12/2020 (recovery)

Exam simulation! Zip of the exam folder: esercitazione-23-12-2020.zip (solutions: program.sol.py)

Lecture 22 18/12/2020

Exercise done in class: https://drive.google.com/file/d/1oeXrg9CNCBJSS1ZaBWZK4tz-Kxgynh_Y/view?usp=sharing

Code seen in class: prog_lab_lect22.zip

Lecture recording (only accessible to registered students): https://drive.google.com/file/d/1pNRTA8fFHqBd6t7FRbAtMeQ1nzPX6ZtP/view?usp=sharing Chat-transcript-20201218-090858_Programming_lab.txt

Lecture 21 16/12/2020

Exercises about recursion, trees and filesystem. Examples: 66.zip 12.zip

Code seen in class: prog_lab_lect21.zip

Lecture recording (only accessible to registered students): https://drive.google.com/file/d/1_4Dg9bBl00wZ0RgBfBV1R93xTFbFU8MZ/view?usp=sharing Chat-transcript-20201216-124127_Programming_Lab.txt

Lecture 20 11/12/2020

Exercises on recursion, recursion limits. Filesystem trees (directory trees). The os module and the os.path module to access the functionalities of the Operating System.

Code seen in class: prog_lab_lect20.zip

Lecture recording (only accessible to registered students): https://drive.google.com/file/d/1lj4cn7oX-N3BDYN0onYfufboE0vzASfJ/view?usp=sharing Chat-transcript-20201211-093625_Programming_Lab.txt

Lecture 19 09/12/2020

Homework 8. Binary trees. N-ary trees.

Code seen in class: prog_lab_lect19.zip

Lecture recording (only accessible to registered students): https://drive.google.com/file/d/11lPMsvIKCqWJHQ-MyLEItjeoWCIyK9pw/view?usp=sharing Chat-transcript-20201209-124222_Programming_Lab.txt

Lecture 18 04/12/2020

Binary trees.

Code seen in class: prog_lab_lect18.zip

Lecture recording (only accessible to registered students): https://drive.google.com/file/d/1khGav7kS_wNvceWZ21AZ3qjslLNo32tt/view?usp=sharing Chat-transcript-20201204-091149_Programming_lab.txt

Additional exercises

  1. Write a recursive function that receives a string and a letter as input and counts how many times the letter is repeated in the string, without using string methods.
  2. Write a recursive function that receives a string as input and returns a pair in which the first value is the number of vowels and the second value is the number of consonants present in the string.
  3. Write a recursive function that receives two integers as input and returns their product using only additions and subtractions.
  4. Write a recursive function that receives an integer as input and returns True if the number is prime, False, otherwise.
  5. Write a recursive function that receives a list of integers and returns the minimum value among all the values in the list.
  6. Write a recursive function that receives a list of integers and returns a new list in which only the positive values of the original list are present.
  7. Write a recursive function that takes a binary tree as input and returns the minimum value among all the values of the nodes of the tree.
  8. Write a recursive function that takes a binary tree as input and returns the minimum value among all the values of the tree leaves.
  9. Write a recursive function that takes a binary tree as input and prints the values of all leaves from the right to the left.
  10. Write a recursive function that takes a binary tree and a level L as input, and returns the sum of the values in the nodes to the L level.

Lecture 17 02/12/2020

Exercises about recursion.

Code seen in class: prog_lab_lect17.zip

Lecture recording (only accessible to registered students): https://drive.google.com/file/d/10vKlTmddJh39PDgPBudAH8wAqtGVZ_vc/view?usp=sharing Chat-transcript-20201202-124026_Programming_lab.txt

Lecture 16 27/11/2020

Exercises on images.

Try debugging our class code: turtle.py.txt (remember to rename it in .py)

Lecture recording (only accessible to registered students): https://drive.google.com/file/d/1R4spLdpAjhwm60mS3M_Wbx97Zye0s1NF/view?usp=sharing Chat-transcript-20201127-091451_Programming_lab.txt

Json example files: https://jsonplaceholder.typicode.com/posts https://jsonplaceholder.typicode.com/users https://jsonplaceholder.typicode.com/comments

Lecture 15 25/11/2020

Example images: test.png test2.png

Discussions about HW6-req. Exercises on images, with recursive and iterative solutions.

Code seen in class: prog_lab_lect15.zip

Lecture recording (only accessible to registered students): https://drive.google.com/file/d/1Px82mwsbQb6iVnnDja2YCzjHj1uoKsDq/view?usp=sharing Chat-transcript-GMT20201125-124010_Programming_lab.txt

Lecture 14 20/11/2020

Classes and images.

Code seen in class:Prog_lab_lect14.zip

Lecture recording (only accessible to registered students): https://drive.google.com/file/d/16GCmZjnMxz_NbPlbkJtkdhUZvvqXPhN8/view?usp=sharing Chat-transcript-20201120-091312_Programming_lab.txt

Lecture 13 18/11/2020

Classes and images.

Code seen in class: Prog_lab_lect13.zip

Lecture recording (only accessible to registered students): https://drive.google.com/file/d/1v64pZR0Sqix6Tija0NgaJtA-2oXZdJp-/view?usp=sharing Chat-transcript-20201118-124113_Programming_lab.txt

Lecture 12 13/11/2020

Classes. Example: Point and Rectangle classes. Matrices.

Code seen in class: Prog_lab_lect12.zip

Lecture recording (only accessible to registered students): https://drive.google.com/file/d/1jqws-hqrrHAxYp1R85qdD0No05ZPqcn4/view?usp=sharing Chat-transcript-20201113-092109_Programmin_lab.txt

Lecture 11 11/11/2020

Classes. Example: Point class.

Code seen in class: Prog_lab_lect11.zip

Lecture recording (only accessible to registered students): https://drive.google.com/file/d/1jdS4kaeizD0cEvuaWOZjE0Udgchwphjk/view?usp=sharing Chat-transcript-20201111-124710_Programming_lab.txt

Additional exercise

Complete the Rectangle class with the required methods.

Lecture 10 6/11/2020

Introduction to HW4-req. Solution of the additional exercise of lecture 9.

Code seen in class: Prog_lab_lect10.zip

Lecture recording (only accessible to registered students): https://drive.google.com/file/d/1g-Hpe6jVazGuEjpT9e0uI9bfVacYFuaK/view?usp=sharing Chat-transcript-20201106-091602_Programming_lab.txt

Lecture 9 4/11/2020

Understanding the key parameter for the sorting functions. Reading and writing text files.

Code seen in class (examples and exercises): Prog_lab_lect09.zip

Lecture recording (only accessible to registered students): https://drive.google.com/file/d/1yOkpQNocvRf03M4CNyH3mpiYz7zehyfZ/view?usp=sharing Chat-transcript-20201104-123542_Programming_lab.txt

Additional exercise

Write a function that reads the four files in the books.zip file and evaluates the relative frequency of the 26 letters, ignoring the distinction between lower and capital letters. The result has to be a dictionary of dictionaries: for each letter there should be a dictionary associated in which there are the filenames of the books as keys and the relative frequency of the letter for each book.

The relative frequency of a letter in a book can be evaluated as the ratio between the occurrences of that letter and the total number of letters in the book.

Lecture 8 30/10/2020

Homework assignment 3 (optional). Reading and writing text files.

Code seen in class (examples and exercises): Prog_lab_lect08.zip

Lecture recording (only accessible to registered students): https://drive.google.com/file/d/1OZY37ENpM0SXCaG2guHKBjBCKvSlCdmz/view?usp=sharing Chat-transcript-20201030-091035_Programming_lab.txt

Additional exercises

  1. Write a function that takes as an input a string containing a series of words separated by spaces and builds a dictionary where the keys are the last letters of the words in the string and the associated values are lists with the words ending with that letter. The lists must be ordered lexicographically.
    For example, for the string "the only impossible journey is the one you never begin" must return {'e':['the', 'impossible', 'the', 'one'], 'y':['only', 'journey'], 's':['is'], 'u':['you'], 'r':['never'], 'n':['begin']}.
  2. Write a function that takes as an input a dictionary in which each key is a string and the value is an integer and returns the ordered list of all keys with a even value.
    For example, {'mickey mouse':12, 'pluto':3, 'minnie':7, 'goofy':4, 'donald duck':3 } -> ['mickey mouse','goofy'].
  3. Write a function that takes as an input a dictionary of the type {key:integer list} and returns a new dictionary with the same keys but as a value the average of the integers in the original dictionary list.
  4. Write a function that takes as input two key:list dictionaries and returns a new dictionary with the keys present in both input dictionaries and with values the list given by the merging of the two input lists, associated with the same key.
  5. Write a function that takes as an input a string of words separated by spaces and builds a dictionary where the keys are the word lengths and the values are sets with the words that have exactly that length in numbers of characters.

Lecture 7 28/10/2020

Dictionaries, strings and sets.

Code seen in class (examples and exercises): Prog_lab_lect07.zip

Lecture recording (only accessible to registered students): https://drive.google.com/file/d/1G1s9xWXM9Zz9ydtxpfzvcSX2KFtOONNz/view?usp=sharing

Lecture 6 23/10/2020

Cyclomatic complexity (aka intricacy), past homework solution (see classroom exercise zip), deleting elements from a list while visiting the list.

Classroom exercise (solutions in Prog_lab_lect06.zip file): classroom_ex06.zip

Code seen in class (examples and exercise solutions): Prog_lab_lect06.zip

  • past_hw1_1.py: solution where for each grade we count how many students are admitted
  • past_hw1_2.py: solution where for each grade we sum 1 for the threshold <= than grade
  • past_hw1_3.py: solution where for exploit that students admitted for threshold t will be admitted also for any threshold < t
Lecture recording (only accessible to registered students): https://drive.google.com/file/d/1yepMH4y8RsBX3RMiBqokQvWhje39U0W1/view?usp=sharing

Lecture 5 21/10/2020

Timeit magic, string and list methods, map function, random, for vs while, recursion.

Code seen in class (examples and exercises): Prog_lab_lect05.zip

Lecture recording (only accessible to registered students): https://drive.google.com/file/d/1Td7fJ4AwKr1b-TXgZSqPrLTSDcmzWgGu/view?usp=sharing

Lecture 4 16/10/2020

For statement, operations on strings, lists, operations on lists. Homework assignment 1.

Code seen in class (examples and exercises): programming_lab_4.zip

Lecture recording (only accessible to registered students): https://drive.google.com/file/d/1gGZYCXK4d9JftcX3_fF5U2nIkWI1rEKm/view?usp=sharing

Additional exercises

For exercises with lists, if possible, write both the WITH and WITHOUT "range" version.

  • Write a function that gets three integers as an input d, m, a (it is assumed that a is always an odd number to avoid leap years) and returns True or False depending on whether the three numbers form a valid date in the "d/m/a" format. Ex: 30/2/2017 False, 1/1/1111 True.
  • Write a function that gets a list of integers as an input and returns the sum of all even numbers minus the sum of all odd numbers.
  • Write a function that gets as an input a string of words separated by spaces and returns a list with the lengths of words in the string.
  • Write a function that checks if a list is sorted in ascending order (<=) (let's suppose that the list contains sortable objects) and, in case, returns True, False otherwise.

Lecture 3 14/10/2020

Comparison operators, if and for statements, lists.

Code seen in class (examples and exercises): Prog_lab_lect03.zip

Lecture recording (only accessible to registered students): https://drive.google.com/file/d/1COb6LzKCzUfRJboUbxEzpFZ_MwkA0EAA/view?usp=sharing

Lecture 2 9/10/2020

Variable, names, integers, floats, strings, functions. Some exercises.

Code seen in class (examples and exercises): Prog_lab_lect02.zip

Lecture recording (only accessible to registered students): https://drive.google.com/file/d/1oZzVo71_P5aJ3sUHRecyvACYw9t05P0v/view?usp=sharing

Lecture 1 7/10/2020

Course introduction, computer science to solve problems with computing, terminal and GUI (Graphical User Interface), raw text files and binary files, binary and hexadecimal numeric representation, ASCII and UTF-8 encoding, python interpreter and IDLE, arithmetic expressions, difference between interactive mode and script mode.

Lecture recording (only accessible to registered students): https://drive.google.com/file/d/1QvnYhQEHP0IKnft5KricZXu8LFYwDxwY/view?usp=sharing

Additional exercises

  • Write a python script that takes in input a float number, calculates its cube root and prints it on screen
  • Write a python script that takes a person name (name) and the name of a fruit (fruit) and prints: "(name) loves to eat (fruit)".
  • Write a python script that takes in input two floats a and b and calculates and prints c, corresponding to the hypotenuse of the rectangle triangle having for cathets two sides of length a and b, respectively
  • Write a python script that takes in input three floats a, b, c, and calculates and prints the expression: CodeCogsEqn.gif
  • Write a python script that takes three floats a, b, c, and calculates and prints the two x roots of the equation:CodeCogsEqn1.gif

Lecture 0: getting started.

Getting started guide.

-- Angelo Spognardi - 2020-09-28

Comments

*

Topic attachments
I Attachment History Action Size DateSorted ascending Who Comment
Compressed Zip archivezip Prog_lab_lect02.zip r1 manage 2.7 K 2020-10-12 - 15:04 AngeloSpognardi  
Compressed Zip archivezip Prog_lab_lect03.zip r1 manage 1.9 K 2020-10-14 - 21:58 AngeloSpognardi  
Compressed Zip archivezip programming_lab_4.zip r1 manage 3.8 K 2020-10-16 - 11:03 AngeloSpognardi  
Compressed Zip archivezip Prog_lab_lect05.zip r1 manage 2.0 K 2020-10-22 - 17:07 AngeloSpognardi  
Compressed Zip archivezip Prog_lab_lect06.zip r1 manage 7.0 K 2020-10-23 - 16:13 AngeloSpognardi  
Compressed Zip archivezip classroom_ex06.zip r2 r1 manage 9.4 K 2020-10-23 - 16:28 AngeloSpognardi  
Compressed Zip archivezip Prog_lab_lect07.zip r1 manage 2.2 K 2020-10-29 - 08:57 AngeloSpognardi  
Compressed Zip archivezip Prog_lab_lect08.zip r1 manage 6.3 K 2020-10-30 - 12:21 AngeloSpognardi  
Compressed Zip archivezip books.zip r1 manage 551.4 K 2020-11-04 - 14:33 AngeloSpognardi  
Texttxt Chat-transcript-20201104-123542_Programming_lab.txt r1 manage 3.3 K 2020-11-05 - 10:21 AngeloSpognardi  
Compressed Zip archivezip Prog_lab_lect09.zip r1 manage 2.7 K 2020-11-05 - 10:25 AngeloSpognardi Lecture 04/11/2020
Texttxt Chat-transcript-20201106-091602_Programming_lab.txt r1 manage 9.4 K 2020-11-06 - 17:41 AngeloSpognardi  
Compressed Zip archivezip Prog_lab_lect10.zip r1 manage 531.3 K 2020-11-06 - 17:39 AngeloSpognardi  
Texttxt Chat-transcript-20201111-124710_Programming_lab.txt r1 manage 7.1 K 2020-11-11 - 21:38 AngeloSpognardi  
Compressed Zip archivezip Prog_lab_lect11.zip r1 manage 1.4 K 2020-11-11 - 21:35 AngeloSpognardi  
Texttxt Chat-transcript-20201113-092109_Programmin_lab.txt r1 manage 9.1 K 2020-11-13 - 23:23 AngeloSpognardi  
Compressed Zip archivezip Prog_lab_lect12.zip r1 manage 3.8 K 2020-11-13 - 23:21 AngeloSpognardi  
Texttxt images.py.txt r1 manage 3.3 K 2020-11-18 - 12:59 AngeloSpognardi  
Texttxt png.py.txt r1 manage 97.9 K 2020-11-18 - 12:59 AngeloSpognardi  
Texttxt Chat-transcript-20201118-124113_Programming_lab.txt r1 manage 4.4 K 2020-11-20 - 10:52 AngeloSpognardi  
Texttxt Chat-transcript-20201120-091312_Programming_lab.txt r1 manage 4.2 K 2020-11-20 - 23:15 AngeloSpognardi  
Compressed Zip archivezip Prog_lab_lect13.zip r1 manage 32.4 K 2020-11-20 - 08:52 AngeloSpognardi  
Compressed Zip archivezip Prog_lab_lect14.zip r1 manage 68.5 K 2020-11-20 - 11:56 AngeloSpognardi  
Texttxt Chat-transcript-GMT20201125-124010_Programming_lab.txt r1 manage 13.6 K 2020-11-25 - 23:18 AngeloSpognardi  
Compressed Zip archivezip prog_lab_lect15.zip r1 manage 2.8 K 2020-11-25 - 23:15 AngeloSpognardi  
PNGpng test.png r1 manage 23.6 K 2020-11-25 - 13:22 AngeloSpognardi  
PNGpng test2.png r1 manage 69.3 K 2020-11-25 - 14:10 AngeloSpognardi  
Texttxt console_history.py.txt r1 manage 2.4 K 2020-11-27 - 12:15 AngeloSpognardi  
Texttxt turtle.py.txt r1 manage 3.4 K 2020-11-27 - 12:14 AngeloSpognardi  
Texttxt Chat-transcript-20201127-091451_Programming_lab.txt r1 manage 9.3 K 2020-11-28 - 11:17 AngeloSpognardi  
Compressed Zip archivezip prog_lab_lect17.zip r1 manage 10.7 K 2020-12-02 - 14:38 AngeloSpognardi  
Texttxt Chat-transcript-20201202-124026_Programming_lab.txt r1 manage 6.8 K 2020-12-03 - 22:30 AngeloSpognardi  
Texttxt Chat-transcript-20201204-091149_Programming_lab.txt r1 manage 4.1 K 2020-12-04 - 22:27 AngeloSpognardi  
Compressed Zip archivezip prog_lab_lect18.zip r1 manage 3.2 K 2020-12-04 - 12:05 AngeloSpognardi  
Texttxt Chat-transcript-20201209-124222_Programming_Lab.txt r1 manage 4.6 K 2020-12-09 - 21:54 AngeloSpognardi  
Compressed Zip archivezip prog_lab_lect19.zip r1 manage 1.9 K 2020-12-09 - 21:43 AngeloSpognardi  
Compressed Zip archivezip prog_lab_lect20.zip r1 manage 7.4 K 2020-12-11 - 12:04 AngeloSpognardi  
Texttxt Chat-transcript-20201211-093625_Programming_Lab.txt r1 manage 4.2 K 2020-12-12 - 12:24 AngeloSpognardi  
Compressed Zip archivezip 12.zip r1 manage 7.4 K 2020-12-16 - 12:36 AngeloSpognardi  
Compressed Zip archivezip 66.zip r2 r1 manage 11.2 K 2020-12-16 - 13:32 AngeloSpognardi  
Texttxt Chat-transcript-20201216-124127_Programming_Lab.txt r1 manage 3.6 K 2020-12-16 - 23:04 AngeloSpognardi  
Compressed Zip archivezip prog_lab_lect21.zip r1 manage 4.6 K 2020-12-16 - 23:01 AngeloSpognardi  
Texttxt Chat-transcript-20201218-090858_Programming_lab.txt r1 manage 7.5 K 2020-12-18 - 17:59 AngeloSpognardi  
Compressed Zip archivezip prog_lab_lect23.zip r1 manage 2.7 K 2020-12-18 - 12:08 AngeloSpognardi  
Compressed Zip archivezip esercitazione-23-12-2020.zip r1 manage 135.0 K 2020-12-23 - 13:56 AngeloSpognardi  
Texttxt program.sol.py.txt r1 manage 9.5 K 2020-12-23 - 22:45 AngeloSpognardi  
Edit | Attach | Watch | Print version | History: r48 < r47 < r46 < r45 < r44 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r48 - 2021-01-08 - AngeloSpognardi






 
Questo sito usa cookies, usandolo ne accettate la presenza. (CookiePolicy)
Torna al Dipartimento di Informatica
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2021 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback