# 1. Big Picture ## 5. What is mastery in programming? Anastasia (Uppsala): automating workflow and making it faster Anastasiia (Umeå): Competency Angelica (Uppsala): Elizabeth (Umeå): to be able to solve problems Erin (Umeå): Always trying to improve and optimize the way you program Farina (Umeå): Able to make logical solution of problem and debugg it in order to make it in workable format according to requirements Garance (Umeå): Be able to understand all the limits of the language, understand the mistakes/error messages Ghada (Uppsala): Be able to think like a computer/programming language Gustavo (Umeå): Write codes that are simple, logic and powerful Henrik (Umeå): Knowing how to do what you want to do Imke (Uppsala): Working in a team to solve large programming problems. Julia (Uppsala): understand the logic of writing codes (with one language first!) so that you can easily switch to a different language if needed. Katja (Uppsala):Solve a problem in a structured way, write reproducible codes Linglong (Uppsala): Like to make a new thing very similar to make cars that it can help us to arrive some functions or purposes. Luz María (Uppsala): mastering programing is to be able to develop a code that would help you with whatever task nothing else is able to do and understanding each step needed to solve the problem Marga (Umeå): knowing how to solve the problems Maria (Uppsala): Mariya (Uppsala): Proficiency of translating your questions into working and easy-to-read code Mattia (Uppsala): Knowing multiple languages like R,Python, C++ and use repository and other methods for code reproducibility (Docker ideally) and traceability, automation (Snakemake) Miles (Umeå): ChaGPT Nirbhay (Uppsala): can create new program Oytun (Umeå): automate to doing repetitive tasks Pallabi (Umeå): Sona (Uppsala): Problemsovling, Creativity, Simple code Sonali (Umeå): Tony (Uppsala): Applying coding langauges in order to create digital solutions to different tasks. Vishnu (Umeå): problem solving, extracting data ## 8. How to do better? Anastasia (Uppsala): if/else loop for x==0 Anastasiia (Umeå): check if the detonator is not zero before dividing Angelica (Uppsala): Elizabeth (Umeå): UseF if to specify denominator must be more than zero Erin (Umeå): Simplify by callinng x and y and use if statement to make sure the denominator is more than zero Farina (Umeå):Try if -else loop to rise exception in case of denominator=0 Garance (Umeå): why not write the values directly in the equation, instead of defining them by a variable first? Is is necessary, more useful? Are we going to use this code for other values? Ghada (Uppsala): add a line to check if denominator is not zero Gustavo (Umeå): Henrik (Umeå): Avoid error by checking not zero Imke (Uppsala): built in a checking statement that returns a specific error message. Julia (Uppsala): check that denominator is different that zero with if. if zero, return error message. Katja (Uppsala): / Luz María (Uppsala): Before calculating value add some code like: if denominator==0: print("denominator can´t be 0, try again") else: value=numerator/denominator / print(value) Marga (Umeå): if denominator and numenator is not zero: value=1 Maria (Uppsala): write in code that denominator is not 0 Maria (Uppsala): if not 0, add a condition Mariya (Uppsala): Mattia (Uppsala): check if the varibale for numerator and denominator and correct using type, to avoid using for example floats and integer together Miles (Umeå): 2. d = x == !0 Nirbhay (Uppsala): Oytun (Umeå): Checking both variables are integer or float, and checking the numerator is not zero Pallabi (Umeå): Sona (Uppsala): Tell the computer that the demonitor is not equal to zero Sonali (Umeå): check with if condition for checking if either denominator or numerator equals zero and then proceed the calculation Tony (Uppsala): Dont know Vishnu (Umeå):Provide a condition: if denominator is not zero Linglong(Uppsala): d!=0, a is numeric, a/d ## 14. Questions about `assert` Anastasia (Uppsala): Anastasiia (Umeå): Angelica (Uppsala): ChatGPT says "It's important to note that assertions are primarily used for debugging and should not be used for handling expected errors or exceptional cases in production code." could you comment on that? Elizabeth (Umeå): Erin (Umeå): What is a static_assert? Farina (Umeå): Garance (Umeå): If we do not respect our own assumptions, does it return a true/false? Does it stop running the code? Is it here to check for us? Ghada (Uppsala): The real problem is that you don't really THINK then ignore to write about your assertions but that you ASSUME them without realizing it. What are your tips about that? Gustavo (Umeå): Henrik (Umeå): Imke (Uppsala): can you save a file in which the assert is not tr Julia (Uppsala): so how do you realize that the assert is not true? Error message? Katja (Uppsala): Linglong (Uppsala): can assert define a lists or strings? store value? Luz María (Uppsala): Marga (Umeå): Maria (Uppsala): Why is it not called assume? Maria (Uppsala): if you remove assert and write only denominator!=0 will still work? Mariya (Uppsala): Do you think that assert function can be used a substitute for proper error handling? Can you rely upon in production code? What about security risks and sensitive information included in assertion? Mattia (Uppsala): Is it mandatory to make a code work? Miles (Umeå): Nirbhay (Uppsala):what is need to make assert, when should we use it? Oytun (Umeå): Pallabi (Umeå): if we remove assert and write denominator !=0? Sona (Uppsala): In what cases should assert be used? And should it be left in the final code since it is used for debugging? Sonali (Umeå): In which cases is mandatory to use assert? and in which cases it can be skipped Tony (Uppsala): Vishnu (Umeå): # 2. Express your assumptions in code ## Slide 16: Problem Anastasia (Uppsala):Define which side of the triangle is a, b, and c. ++ Anastasiia (Umeå): write a function for c Angelica (Uppsala): Elizabeth (Umeå): Erin (Umeå): Farina (Umeå): Garance (Umeå): Ghada (Uppsala): Gustavo (Umeå): Henrik (Umeå): Use a function Imke (Uppsala): don't know Julia (Uppsala): we can use a function Katja (Uppsala): use function to get euclidean distance Linglong (Uppsala): c= (a**2 +b**2)**0.5 Luz María (Uppsala): Marga (Umeå): Maria (Uppsala): use a function in python to calculate c Maria (Uppsala): euclidean function in python Mariya (Uppsala): using dist() function Mattia (Uppsala): I don't know Miles (Umeå): c = (a** + b**) **0.5 Nirbhay (Uppsala): no idea Oytun (Umeå): Pallabi (Umeå): We can define a function to calculate the euclidean distance. Sona (Uppsala): There should be a calculate function for this, but I don't know it. matplotlib? Sonali (Umeå): write a function to accept the values of a and b. write a function to calculate c Tony (Uppsala): Don't know Vishnu (Umeå): Define a function for this calculation and call it whenever necessary ## 18. Question about functions Anastasia (Uppsala):a defined calculation that can be called throughout the code (no need to write the calculations again and again) Anastasiia (Umeå): a function should be no more than 50-100 (max) lines otherwise you'll die understanding what is going on in this function Angelica (Uppsala): A fuction is used to compare or define anything of interest for analysis. A good function helps you find an answer in the easiest posible way. Elizabeth (Umeå): It is an efficient way to carry out a calculation Erin (Umeå): a defined task that is performed and can be used in many situations Farina (Umeå):Function acts a like a machine which takes input and gives the required output. A good function is clear to read and execute. Garance (Umeå): a function is an element that takes imputs and gives us outputs, a transformation of sorts. A good function is one that saves time, by doing as many "transformations" as necessary to give us the output we want. Ghada (Uppsala): Good function has meaningful name, should be generalized (take into account most cases) Gustavo (Umeå): a pre-defined operation Henrik (Umeå): Does ONE thing in a readable way Imke (Uppsala): a function is a block of code that can be called on some input and performs a specific task. a good function is readable and efficient Julia (Uppsala): it is used to calculate something. A good function is described in english first to be understood easily. Katja (Uppsala): a piece of code with a clear name, needs input Linglong (Uppsala): Function is to arrive some results , a good function should be easily understandable and simpified. Luz María (Uppsala): a function is a piece of code that gets some input variables, does something to them and returns an output(s). A good function should be efficient? Marga (Umeå): Maria (Uppsala): function = an equation that can calculate a specific variable when given any integer or float. A good function = fast and efficient Maria (Uppsala): is a chunck of code that you can reuse and later on you can input the values for the variables and get one output. A good function needs to be easy to be clear. Mariya (Uppsala):the best and simplest way to solve mathematical problem with less number of steps (good function). Functions should include more generalized manner. Mattia (Uppsala): A function is a summary of a series of operation in just one line. A good manual is necessary to understand how it works and to debug errors Miles (Umeå): common, repetitive task with name that functions as comment Nirbhay (Uppsala): to execute calculation for input Oytun (Umeå): series of codes that can be used in different parts of a program Pallabi (Umeå): Function is a kind of operation that can read the inputs provided in a given problem and provide a solution in the output. A good function should be simple, intuitive. Sona (Uppsala): Collective thing, built in, easy Sonali (Umeå): function name should imply what it does and of course a good function is the one that outputs correctly the required value Tony (Uppsala):relationship between inputs making one output Vishnu (Umeå): A set of code that can take input(data structures) from main script and do a specific task ## 24. Question about functions Anastasia (Uppsala): examples of tests? how are the tests documented to show to someone? Anastasiia (Umeå): Angelica (Uppsala): There are probably functions developed by others that you may use, where are a good sources to find them? Elizabeth (Umeå): Erin (Umeå): Farina (Umeå): Garance (Umeå): why would we use methods? Functions should be all we need, no? We have talked a bit about the difference between them but I still do not know when it is better to use one over the other. Can we write our own methods? Ghada (Uppsala): Gustavo (Umeå): Henrik (Umeå): Imke (Uppsala): 1) in your definition of a function, you mentioned "optional" inputs. Why optional? 2)can you have nested functions, like one function calling another? Julia (Uppsala): Katja (Uppsala): Linglong (Uppsala): In what situations to make a function is useful and what situations is not good? Luz María (Uppsala): Marga (Umeå): Maria (Uppsala): Maria (Uppsala):what do you mean by tests? that there is a correct output? Mariya (Uppsala): how do you test the validity of the fucntion especially you are using someone else's functions? Any advice for the beginners on how to test the function you want to use? Mattia (Uppsala): Is a library in python compose by function like an R package? Miles (Umeå): How do you know when tests are sufficient Nirbhay (Uppsala): Oytun (Umeå): Pallabi (Umeå): Sona (Uppsala): When would YOU suggest to use functions? In what cases? Sonali (Umeå): can you make your own library of your own functions in python? Tony (Uppsala): Vishnu (Umeå): # 3. Express yourself in readable code ## 29. Questions 1 Anastasia (Uppsala):is_zero, is_more_than_zero, is_number, is_empty_list Anastasiia (Umeå): is_zero, is_bigger_than_zero, is_number, is_empty_list Angelica (Uppsala): zero_check(), positive_value(), Elizabeth (Umeå): Starts with a verb? Erin (Umeå): is_zero, more_than_zero, is_number, is_empty Farina (Umeå): is_zero, is_bigger_than_zero, is_number, is_a_emptylist, Cheers! Garance (Umeå): I agree with Farina! Ghada (Uppsala): test_zero, test_number_positive, test_number_type, test_empty Gustavo (Umeå): check_value_zero ; Henrik (Umeå): check_value_if_zero, check_value_if_over_zero, check_if Imke (Uppsala): determine_if_zero(), determine_if_>0(), determine_if_number(), determine_if_empty_list() Julia (Uppsala): check_if_zero;check_higher_zero; check_if_number; check_list_empty Katja (Uppsala): Linglong (Uppsala): find_zero: x == 0.0;find_above_zero: x >0.0; find_number: x is numeric; find_empty_list: list-x is empty. Luz María (Uppsala):1.check_value_equals_zero() 2.check_value_positive() 3.check_value_type() 4.check_list_content() Marga (Umeå): positive_value() Maria (Uppsala): 1. find if x = 0 x = 4 is x > 0 is x < 0 Maria (Uppsala): check_if_zero, check_if_bigger_than_0, check_if_is_number, check_if_is_emptylist Mariya (Uppsala): evaluate_numbers name 1. is_zero 2. bigger_than_0 3. is_number 4. is_list_empty Mattia (Uppsala): 1.what_is_zero, 2.bigger_than_zero, 3.is_number, 4.is_empty Miles (Umeå): divides_integer_smthg (falsifiable_test_loop) Nirbhay (Uppsala): check_if_X_is_zero, X>0; x_is_number(); x_is_a_empty_list() Oytun (Umeå):check_zero,bigger_than_zero,check_number,check_empty_list Pallabi (Umeå): check_if x==0, x>0, x_is_number(, x_an_empty_list() Sona (Uppsala): is_zero, above_zero, Sonali (Umeå): check_is_zero, is_big_than_zero,is_number,is_empty_list Tony (Uppsala): check_if_zero, check_number_higher, check_empty_list Vishnu (Umeå): check_zero, check_larg_than_zero, is_num, check_empty_list ## 31. Questions 2 Anastasia (Uppsala):is_str_list, is_int_list, is_zeros_int_list Anastasiia (Umeå): are_strings, are_integers, are_zeroes Angelica (Uppsala): is_strings, is_integers, zero_integers Elizabeth (Umeå): is_listtype_is_listpositiveintegers Erin (Umeå): is_list_of_strs, is_list_of_ints,is_list_of_ints_all_zero Farina (Umeå): is_string_list, is_integer_list, is_zero_integer_list Garance (Umeå): is_a_string_list, is_integer_list, is_0_only_list Ghada (Uppsala): is_str_list, is_int_list, is_zeros_list Gustavo (Umeå): is_list_strings; is_list_integers ; is_list_integers_zero Henrik (Umeå): is_string_list, is_int_list, is_zero_list Imke (Uppsala): is_list_of_strings(), is_list_of_integers(), is_list_of_integers_only_0() Julia (Uppsala): is_list_strings; is_list_integers; is_list_integers_zero Katja (Uppsala): is_string, is_int, is_int_only_zero Linglong (Uppsala): is_string_list, is_integer_list is_integers_onlyzeroes_list Luz María (Uppsala):is_list_str, is_list_int, is_list_zeros. Marga (Umeå): list_strings, list_integers, , list_integers_only_zeroes Maria (Uppsala): is_list_strings, is_list_integers, is_list_of_zero_integers Maria (Uppsala): is_a_list_of_str,is_a_list_of_int, is_only_0_int_list Mariya (Uppsala): 1.is_list_str 2. is_list_int 3. is_list_uniquely_0sis Mattia (Uppsala):1. is_strings_list, 2.is_integer_list, 3. is_zero_list Miles (Umeå): is_string_list; is_ int_ list; ; is_1/intlist_defined Nirbhay (Uppsala):is_str_list ; is_intg_list; is_intg_zeros_list Oytun (Umeå): is_strlist,is_intlist,is_intlist_onlyzero Pallabi (Umeå): is_list_str, is_list_int, is_list_zero_int Sona (Uppsala): is_list_str; is_list_int; intlist_only_zero Sonali (Umeå): is_list_str,is_list_int Tony (Uppsala): is_string_list, is_integer_list, is_list_int_zero Vishnu (Umeå): is_lst_of_str, is_lst_of_int, is_lst_of_int_zero Q: does it make sense to assign multiple names to the same function, depending on the use case? A: Arguably, no. The function name should be invariant of the specific use case (the function name should describe what the function does, not what it is used for) ## 34. Question 3 Anastasia (Uppsala):is_zero Anastasiia (Umeå): is_zero Angelica (Uppsala): is_zero Elizabeth (Umeå): is_zero_is_not_ Erin (Umeå): is_zero Farina (Umeå): is_zero, check_zero Garance (Umeå): is_zero Ghada (Uppsala): is_zero Gustavo (Umeå): is_zero Henrik (Umeå): is_zero Imke (Uppsala): is_zero Julia (Uppsala): is_zero Katja (Uppsala): is_zero Linglong (Uppsala): is_zero, Luz María (Uppsala):is_zero() Marga (Umeå): Maria (Uppsala): is_zero; is_ Maria (Uppsala):is_zero Mariya (Uppsala): is_zero Mattia (Uppsala): is_zero Miles (Umeå): divide_zero_number Nirbhay (Uppsala):is_equal_zero Oytun (Umeå): is_float_zero Pallabi (Umeå): Sona (Uppsala): is_zero Sonali (Umeå): is_zero Tony (Uppsala): is_zero Vishnu (Umeå): ## 36. Question 4 Anastasia (Uppsala):is_positive Anastasiia (Umeå): is_bigger_than_zero Angelica (Uppsala): is_positive Elizabeth (Umeå): is_positive_integer Erin (Umeå): is_positive Farina (Umeå): is_positive, is_greater_than_zero Garance (Umeå): is_positive Ghada (Uppsala):is_positive Gustavo (Umeå): is_positive Henrik (Umeå): is_positive Imke (Uppsala): is_positive Julia (Uppsala): (4.11) is_positive Katja (Uppsala): is_positive Linglong (Uppsala): is_above_zero or is_higher_than_0 or is_positive_number Luz María (Uppsala): is_positive() Marga (Umeå): Maria (Uppsala): is_number_positive Maria (Uppsala): is_bigger_than_zero Mariya (Uppsala): is_positive Mattia (Uppsala): is_bigger_than_zero Miles (Umeå): is_öpositive_float [R: Good joke :+1: ] Nirbhay (Uppsala): is_more_than_zero Oytun (Umeå): is_bigger_than_zero Pallabi (Umeå):is_positive Sona (Uppsala): above_zero Sonali (Umeå): is_positive Tony (Uppsala): is_positive Vishnu (Umeå): is_larger_than_zero [R: first one to use 'larger'. I like the originality of that!] I have used it for question at line:194 too ## 38. Question 5 Anastasia (Uppsala):is_empty_list Anastasiia (Umeå): is_empty_list Angelica (Uppsala): is_empty_list Elizabeth (Umeå): is_empty_list Erin (Umeå): is_empty_list Farina (Umeå): is_emptylist Garance (Umeå): sets_list_as_empty, makes_list_empty [R: this hints that the function actually does something to the list. It does not: it only checks if it is empty. I do enjoy the original verbs here -] Ghada (Uppsala): is_emplyt_list Gustavo (Umeå): is_empty_list Henrik (Umeå): is_empty_list Imke (Uppsala): is_empty_list Julia (Uppsala): (4.13)is_list_empty Katja (Uppsala): is_list_empty Linglong (Uppsala): is_mylist_empty Luz María (Uppsala): is_empty_list() Marga (Umeå): Maria (Uppsala): is_my_list_empty Maria (Uppsala): is_list_empty Mariya (Uppsala): is_list_empty Mattia (Uppsala): is_empty Miles (Umeå): will_empty_list Nirbhay (Uppsala) is_empty_list Oytun (Umeå): is_empty_list Pallabi (Umeå): empty_list Sona (Uppsala): is_empty_list Sonali (Umeå): is_empty_list Tony (Uppsala): is_empty_list Vishnu (Umeå): is_empty_list ## 40. Question 6 Anastasia (Uppsala):calc_sum Anastasiia (Umeå): calc_sum Angelica (Uppsala): calc_sum Elizabeth (Umeå): sum_list Erin (Umeå): calc_sum Farina (Umeå): calc_sum_of_list Garance (Umeå): gives_sum_list Ghada (Uppsala): calc_sum_list Gustavo (Umeå): get_sum Henrik (Umeå): sum_list Imke (Uppsala): sum_list Julia (Uppsala): (4.15) sum_list Katja (Uppsala): calc_sum_list Linglong (Uppsala): get_sum_list or calc_sum_list Luz María (Uppsala): sum_list() Marga (Umeå): Maria (Uppsala): calc_sum_my_list Maria (Uppsala): calc_sum_list Mariya (Uppsala): calculate_sum Mattia (Uppsala): sum_list Miles (Umeå): sum_list Nirbhay (Uppsala): calculate_sum Oytun (Umeå): sum_list Pallabi (Umeå): calc_sum_list Sona (Uppsala): calc_sum_list Sonali (Umeå): sum_int_in_list Tony (Uppsala): calc_sum_list Vishnu (Umeå): calc_sum_lst ## 42. Question 7 Anastasia (Uppsala):sort_list Anastasiia (Umeå): make_sorted_list Angelica (Uppsala): sort_list Elizabeth (Umeå): sort_list Erin (Umeå): sort_list Farina (Umeå): sort_list Garance (Umeå): sort_list Ghada (Uppsala): created_sorted_list Gustavo (Umeå): sort_list Henrik (Umeå): sort_list Imke (Uppsala): sort_list Julia (Uppsala): (4.17) sort_list Katja (Uppsala): sort_list Linglong (Uppsala): sort_list Luz María (Uppsala): sort_list() Marga (Umeå): reverse_list Maria (Uppsala): sort_my_list Maria (Uppsala):sort_list Mariya (Uppsala): create_sorted_list; make_sorted_list; order_list Mattia (Uppsala): sort_list Miles (Umeå): sort Nirbhay (Uppsala): sort_list Oytun (Umeå): sorted_list Pallabi (Umeå): sort_list Sona (Uppsala): sorted_list Sonali (Umeå): sort_list_of_int Tony (Uppsala): sort_list [R: it does not sort the list, does it] Vishnu (Umeå): sorted_lst ## 44. Question 8 Anastasia (Uppsala):calc_list_mean Anastasiia (Umeå): calc_mean Angelica (Uppsala): calc_mean Elizabeth (Umeå): mean_list Erin (Umeå): calc_mean Farina (Umeå): calc_mean_of_list Garance (Umeå):calc_average_list Ghada (Uppsala): calc_mean Gustavo (Umeå): calc_mean Henrik (Umeå): calculate_mean Imke (Uppsala): calc_mean, assert len(my_list)>0 Julia (Uppsala): (4.19) average_list Katja (Uppsala): calc_mean Linglong (Uppsala): get_mean_list or average_list Luz María (Uppsala): calc_mean_list Marga (Umeå): Maria (Uppsala): calc_mean_my_list Maria (Uppsala): calc_mean Mariya (Uppsala): calculate_mean Mattia (Uppsala): how_long Miles (Umeå): calc_mean Nirbhay (Uppsala): calculate_mean_list Oytun (Umeå): calc_mean_list Pallabi (Umeå): calc_mean_list Sona (Uppsala): calc_mean_list Sonali (Umeå): calc_mean Tony (Uppsala): calc_mean Vishnu (Umeå): calc_avg_list ## 46. Questions about function names? Anastasia (Uppsala): Anastasiia (Umeå): Angelica (Uppsala): Elizabeth (Umeå): Erin (Umeå): Farina (Umeå): Garance (Umeå): Ghada (Uppsala): If I name my function an existing function name in python, would it complain? would it run my function or python's? Gustavo (Umeå): What is the max lenght of a name? ;) Henrik (Umeå): Imke (Uppsala): Julia (Uppsala): Katja (Uppsala): Linglong (Uppsala): Can it make any function with any name but just make a statement let people know the purpose of function. Luz María (Uppsala): Marga (Umeå): Maria (Uppsala): Maria (Uppsala): Mariya (Uppsala): what is the most unacceptable function name (words in the name) in your opinion, besides obvious examples like function123, doing_stuff, my_function? Mattia (Uppsala): Miles (Umeå): Nirbhay (Uppsala):is there any word (or list of words) we should avoid to make function? Oytun (Umeå): Pallabi (Umeå): Can we use digits in the function? Sona (Uppsala): Sonali (Umeå): Tony (Uppsala): Vishnu (Umeå): Other: have coding affected your way of thinking and talking? Uppsala says yes! # 4. Making your code readable ## 48. We were all kids once Anastasia (Uppsala): Anastasiia (Umeå): def_prime(x): for i in range(1,x): if ... Angelica (Uppsala): def_prime_in(x) Elizabeth (Umeå): Erin (Umeå): def is_prime(number): return Farina (Umeå):def is_prime(x): for i in range(1:x): if x%i == 0: print Garance (Umeå): def check_if_prime(number): assert number>0 assert Ghada (Uppsala): Gustavo (Umeå): def_prime(x) Henrik (Umeå): def is_prime(x): if x Imke (Uppsala): def is_prime(number): for Julia (Uppsala): Katja (Uppsala): def is_nr_prime(number) Linglong (Uppsala): def is_prime(x): for i in Luz María (Uppsala): Marga (Umeå): def prime() Maria (Uppsala): def prime (x): for i in (1:x): i/x != integer or i/x ==1 or i/x ==x return(it is prime) else: reture(it is not prime) Maria (Uppsala):def is_prime() Mariya (Uppsala): def is_number_prime (x): if x <=1: return False...etc Mattia (Uppsala): is_prime(number): Miles (Umeå): x = [int], y = [int], x / y = int: true Nirbhay (Uppsala):def prime number(x): Oytun (Umeå): def prime(x): for i in range(i,x): Pallabi (Umeå): def is_prime_num(x) Sona (Uppsala): def prime(): Sonali (Umeå): Tony (Uppsala): def_prime_number(), Vishnu (Umeå): def is_num_prime() ## 49. Your first code Anastasia (Uppsala): Anastasiia (Umeå): Angelica (Uppsala): Elizabeth (Umeå): Erin (Umeå): write pseudocode first Farina (Umeå): No result like the code is incomplete to give output. If loop is not completed. Garance (Umeå):there are no assumptions, no pre or post conditions. We need to define a name for the function. We need to define what happens when conditions are not met Ghada (Uppsala): no pseudocode, No comments, no tests/asserts Gustavo (Umeå): Henrik (Umeå): Imke (Uppsala): we don't really know how we're going to tackle the actual determination of whether the number is a prime. Julia (Uppsala): there is no explanation on what the function will do Katja (Uppsala): many commands in one code Linglong (Uppsala): it has two for-loop function. Luz María (Uppsala): is incomplete, what comes after the ":" after the if. no operation with "number" Marga (Umeå): the range has numbers and wordds Maria (Uppsala): Maria (Uppsala): very confusing Mariya (Uppsala): the code is too bulky and too confusing, it can be written in more elegant way and less complicated. Mattia (Uppsala): no assertion and there is no function defined Miles (Umeå): pseudocode != ghostcode FALSE Nirbhay (Uppsala): Oytun (Umeå): Pallabi (Umeå): Incomplete Sona (Uppsala): Sonali (Umeå): Tony (Uppsala): perhaps write a scaffold with pseudocode to outline first Vishnu (Umeå): # 5. Do work in the right order ## 56. Question 1 Anastasia (Uppsala):assert file_exists('path_to_file') Anastasiia (Umeå): assert does_file_exist("/path") Angelica (Uppsala): does_file_exist('../../file.txt') Elizabeth (Umeå): does_file_exist('file') [R: So '' exists??] Erin (Umeå): assert does_file_exist('file.txt') Farina (Umeå): assert does_file_exist(file_name) [R: what is 'ftn'?] Garance (Umeå): assert file_exists(file) assert not file_exists(nofile) Ghada (Uppsala): function name: does_file_exist. tests: assert does_file_exist(path/existing_file.txt) assert not does_file_exist(path/non_existing_file.txt) [R: Don't forget to use quotes arund a filename, e.g. ""my_file.xttxund a filename, e.g. ""my_file.xttxund a filename, e.g. ""my_file.xttxund a filename, e.g. ""my_file.xttxund a filename, e.g. ""my_file.xttxund a filename, e.g. ""my_file.xttxund a filename, e.g. ""my_file.xttxund a filename, e.g. ""my_file.xttx] Gustavo (Umeå): Henrik (Umeå): assert does_file_exist('your.file.any') Imke (Uppsala): assert does_file_exist("/path_to_file/"),,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, [R: what are those commas?] Julia (Uppsala): assert file_exists ('file') Katja (Uppsala): assert does_file_exist() Linglong (Uppsala): assert does_exist_file(file name) Luz María (Uppsala): assert file_exist() Marga (Umeå): assert file_exists("file name") Maria (Uppsala): assert does_file_exist('file name') Maria (Uppsala): assert does_file_exist(filenamehere) assert not does_file_exist(wrongfilenamehere) Mariya (Uppsala): assert does_module_exist ('file.ext') assert not does_module_exist ('bcd.ext') Mattia (Uppsala): assert file_exist("file.txt"), assert file_not_exist Miles (Umeå): Nirbhay (Uppsala): assert does_file_exit('file_name.ext') assert does_not_file exit('nir_kush.ext') Oytun (Umeå): assert does_file_exist("..\file.txt") Pallabi (Umeå): do_files_exist(sample_file.txt) Sona (Uppsala): assert (not) does_file_exist('sample_file.txt') Sonali (Umeå): assert file_exist(file_name), assert not file_exist(file_name) Tony (Uppsala): assert file_exist(name), Vishnu (Umeå): assert file_exist_status("file.txt") ## 58. Question 2 Anastasia (Uppsala): Anastasiia (Umeå): assert are_strings(open_file('/path')) Angelica (Uppsala): transform_to_string_list("file.txt") Elizabeth (Umeå): open_file_convert_list_type_string Erin (Umeå): assert is_text(read_file('file.txt')) Farina (Umeå): assert read_into_text(file name) Garance (Umeå): Ghada (Uppsala): function name: read_into_str_list(). tests: assert is_string(read_into_str_list("file")) assert is_empty(read_into_str_list("empty_file")) Gustavo (Umeå): Henrik (Umeå): assert Imke (Uppsala): Julia (Uppsala): assert make_list_strings(['a','b']) assert not make_list_strings([1,2,3]) Katja (Uppsala): assert read_text() Linglong (Uppsala): assert create_list_into_str(op(file name)) Luz María (Uppsala): assert read_into_list() Marga (Umeå): read_content_string("file name") Maria (Uppsala): assert_is_string_('file name') Maria (Uppsala): assert_read_file(filename) Mariya (Uppsala):assert convert_file_into_lists Mattia (Uppsala): assert open_file==list[] Miles (Umeå): assert file__to_strlist (['1', '2']) Nirbhay (Uppsala): Oytun (Umeå): assert create_strList_from_file("file.txt"), assert not create_strList_from_file(int), assert not create_strList_from_file(float), Pallabi (Umeå):read_file_convert_str Sona (Uppsala): assert read_file('sample_file.txt') == [] Sonali (Umeå): assert read_file(file-name) Tony (Uppsala): assert is_text(read_file("filename.txt") Vishnu (Umeå): assert is_str_of_lst(read_file("file.txt")) ## 60. Question 3 Anastasia (Uppsala):assert omit_header(read_file('file')) Anastasiia (Umeå): header = read_wo_header, assert len(header('/path')) Angelica (Uppsala): read_from_2nd_line Elizabeth (Umeå): open_file_ignore_line1_convert_list_type_string Erin (Umeå): assert is_text(read_without_header('file.txt')) Farina (Umeå): assert is_text(skip_header(read_file(file_name))) Garance (Umeå): assert read_file_as_str("myfile") assert not read_file_as_str le Ghada (Uppsala): function name: read_without_header assert len(read_without_header(file_name)) == len(read_into_str_list(file_name)) - 1 Gustavo (Umeå): assert read_string(skip_hader('my.txt')) Henrik (Umeå): assert len((no_header(file.any)) == assert len(standard_function_that_reads_files(file.any)) - 1 Imke (Uppsala): Julia (Uppsala): Katja (Uppsala): data = read_file_without_first_line, assert is_text(data("file")) Linglong (Uppsala): assert is_str(skip_first_line (read_file('file name'))) Luz María (Uppsala): def read_file_no_header assert; assert is_string(read_file_no_header("blabla.txt")) Maria (Uppsala):assert is_string('file name') Maria (Uppsala): assert read_from_line_1() Mariya (Uppsala): file1 = file.loc[1:] assert is_content_string (file1) Mattia (Uppsala): assert open_file==(skip_first_line,list[]) Miles (Umeå): assert not read_file_line2([0,1,2]; ['0', '1', '2']) Nirbhay (Uppsala): Oytun (Umeå): assert read_file("test.txt") assert is_list(read_file("test.txt)") Pallabi (Umeå): list_str(red_file_skip_head) Sona (Uppsala): Sonali (Umeå): assert len(read_file_skip_header(file_name)) Tony (Uppsala): assert is_text(f("filename.txt") Vishnu (Umeå): assert exclude_first_line(read_file("file.txt")) ## 62. Question 4 Anastasia (Uppsala): assert is_str_list(create_test_table) Anastasiia (Umeå): assert len(create_test_table) == 4 assert create_test_table ('/path') [0]== 'First name|Last name' assert create_test_table ('/path') [1]== 'Alita|Colbert' and so on Angelica (Uppsala): assert is_str_list(create_test_table) Elizabeth (Umeå): Erin (Umeå): assert create_test_table[0] == 'First name|Last name' Farina (Umeå): ftn = create_test_table() assert ftn()[1] = 'Alita |Colbert' . . . Garance (Umeå): assert create_test_table("test.table")[0]== "First_name│Last_name" assert create_test_table("test_table")[1]=="Alita│Colbert" assert create_test_table("test.table")[2]=="Brandi│Lovell" assert create_test_table("test.table")[3]=="Corrina│Georgeanna" assert len(create_test_table("test.table"))== 4 Ghada (Uppsala): assert len(create_test_table()) == 4 assert create_test_table()[0] == 'Alita |Colbert' Gustavo (Umeå): f = create_test_table / assert len(f())==4/ assert f()[0] == Henrik (Umeå): assert create_test_table()[0] == "First name|Last name" assert len(create_test_table()) == 4 Imke (Uppsala): Julia (Uppsala): Katja (Uppsala): Linglong (Uppsala): assert is_str(skip_first_line (read_file('file name'))) x= create_function_table() create_list_into_str(skip_first_line(op(file name)) (op(file name))) Luz María (Uppsala): assert create_test_table[0]=="First name|Last name"/ assert create_test_table[1]=="Alita |Colbert" etc etc until [3] Marga (Umeå): assert create_test_table()[1]=="Alita" Maria (Uppsala): def create_test_table = "first name | last name" Maria (Uppsala):a=create_test_table assert a()[1]==Alita|Colbert Mariya (Uppsala): mf = create_test_table assert len(()) == 4 assert mf()[0]=='First name|Last name' assert mf()[1]== 'Alita |Colbert' assert mf()[2] =='Brandi |Lovell' assert mf()[3]=='Corrina |Georgeanna' Mattia (Uppsala): assert create_test_table=="First name|Last name Alita |Colbert Brandi |Lovell Corrina |Georgeanna" Oytun (Umeå): list = create_test_table() assert list[0] == "First Name|Last Name" assert list[1] == "Alita |Colbert" assert list[2] == "Brandi |Lovell" assert list[3] == "Corrina|Georgeanna" Pallabi (Umeå): def create_test_table(): convert_list_to_str(skip_first_line(sample.txt)) Sona (Uppsala): Sonali (Umeå): assert create_test_table()[0] == "First name|Last name" assert create_test_table()[1] == "Alita |Colbert" assert create_test_table()[2] == "Brandi |Lovell" assert create_test_table()[3] == "Corrina |Georgeanna" Tony (Uppsala): assert create_test_table("test.table") Vishnu (Umeå): def create_test_table("file.txt") assert create_test_table()[0] == "First name|Last name" assert create_test_table()[1] == "Alita |Colbert" assert create_test_table()[2] == "Brandi |Lovell" assert create_test_table()[3] == "Corrina |Georgeanna" ## 64. Question 5 Anastasia (Uppsala): Anastasiia (Umeå): Angelica (Uppsala): Elizabeth (Umeå): Erin (Umeå): Farina (Umeå): table = skip_header(create_test_table()) assert is_string(get_nth_column(table, 0))[1] = 'Brandi' Garance (Umeå): assert len(create_test_table("file"))== 1 assert create_test_table("file")=="file"[n] assert type(create_test_table("file"))== "string" Ghada (Uppsala): Gustavo (Umeå): Henrik (Umeå): Imke (Uppsala): Julia (Uppsala): Katja (Uppsala): Linglong (Uppsala): table_x = create_test_table() f= extract_nth_column_as_str extract_rows = table_x[0,] len_rows = len(table_x) extract_headings = table_x[,0] len_column = len(extract_headings) assert f()[nth]==make_table(extract_rows,table_x[,nth]) Luz María (Uppsala):f=extract_nth_column(table,position); assert f(create_test_table(table),0)[0]=="First name" Marga (Umeå): extract_cols("nth") Maria (Uppsala): f=get_nth_column assert f(create_test_table,0)[0]==first name Maria (Uppsala): table = create_test_table () x = extract_nth_col_as_strings n_rows = len(table) extract_x_from_table Mariya (Uppsala): extract_nth_col test_table = create_test_table() assert extract_nth_column(test_table, 0)[1] == 'Alita' assert extract_nth_column(test_table, 1)[0] == 'Colbert' Mattia (Uppsala): assert create_test_table(f("file.txt")) Miles (Umeå): create_test_table f = get_nth_column Nirbhay (Uppsala): Oytun (Umeå): Pallabi (Umeå): a = create_test_table n_rows = len(table) first_column = f(table, 0) n_elements = len(first_column) f = extract_nth_column Sona (Uppsala): Sonali (Umeå): Tony (Uppsala):f = get_nth_column, create_test_table() Vishnu (Umeå): assert extract_nth_column(is_lst_of_str(create_test_table("file.txt"))) ## 66. Question 6 Anastasia (Uppsala): l=['a','b','c'] assert split_string('a')=['a'] assert split_string('a,c')=['a','c'] assert split_string('a,b,c')=['a','b','c'] Anastasiia (Umeå): Angelica (Uppsala): Elizabeth (Umeå): Erin (Umeå): assert split_str('A') == ['A'] Farina (Umeå): assert split_string("A,B,C") = ['A','B','C'] Garance (Umeå): assert len(split_string())==len() Ghada (Uppsala): l = ["A,B,C"] assert split_str(l)[0] == ['A'] assert split_str(l)[1] == ['B'] assert split_str(l)[2] == ['C'] Gustavo (Umeå): Henrik (Umeå): assert strip_split_string( A, B ,C) == ["A", "B", "C"] Imke (Uppsala): Julia (Uppsala): Katja (Uppsala): Linglong (Uppsala): Luz María (Uppsala): f=split_by_comma(), assert f("A,B,C")==["A","B",#C] Marga (Umeå): assert split_str("A", "B", "c")==["A", "B", "C"] Maria (Uppsala): Maria (Uppsala): Mariya (Uppsala): Mattia (Uppsala): assert split_string(' A, B, C')=['A','B','C'] Miles (Umeå): assert len(split_strip_str(file) = 2*len(file) -1 Nirbhay (Uppsala): Oytun (Umeå): list = "A,B,C" assert split_str(list)[0] == ['A'] assert split_str(list)[1] == ['B'] aqssert split_str(list)[2] == ['C'] Pallabi (Umeå): extract_nth_col Sona (Uppsala): Sonali (Umeå): Tony (Uppsala): assert split_str("A") == ["A"] Vishnu (Umeå): ## 68. Questions about function testing? Anastasia (Uppsala): Anastasiia (Umeå): Angelica (Uppsala): Elizabeth (Umeå): Erin (Umeå): Farina (Umeå): Garance (Umeå): Ghada (Uppsala): Gustavo (Umeå): Henrik (Umeå): Imke (Uppsala): Julia (Uppsala): Katja (Uppsala): Linglong (Uppsala): Luz María (Uppsala): Marga (Umeå): Maria (Uppsala): Maria (Uppsala): Mariya (Uppsala): Mattia (Uppsala): Miles (Umeå): Nirbhay (Uppsala): Oytun (Umeå): Pallabi (Umeå): assert split_str("A,B") == ["A", "B"] Sona (Uppsala): Sonali (Umeå): Tony (Uppsala): Vishnu (Umeå): # 6. Make your function usable by others ## 71. Questions about function documentation? Anastasia (Uppsala): Anastasiia (Umeå): Angelica (Uppsala): Elizabeth (Umeå): Erin (Umeå): Farina (Umeå): Garance (Umeå): Ghada (Uppsala): Gustavo (Umeå): Henrik (Umeå): Imke (Uppsala): Julia (Uppsala): Katja (Uppsala): Linglong (Uppsala): Luz María (Uppsala): Marga (Umeå): Maria (Uppsala): Maria (Uppsala): Mariya (Uppsala): Mattia (Uppsala): Miles (Umeå): Nirbhay (Uppsala): Oytun (Umeå): Pallabi (Umeå): Sona (Uppsala): Sonali (Umeå): Tony (Uppsala): Vishnu (Umeå): # 7. Writing the function body ## 73. When is a function body good enough? Anastasia (Uppsala): Anastasiia (Umeå): Angelica (Uppsala): Elizabeth (Umeå): Erin (Umeå): Farina (Umeå): Garance (Umeå): Ghada (Uppsala): Gustavo (Umeå): Henrik (Umeå): Imke (Uppsala): Julia (Uppsala): Katja (Uppsala): Linglong (Uppsala): Luz María (Uppsala): Marga (Umeå): Maria (Uppsala): Maria (Uppsala): Mariya (Uppsala): Mattia (Uppsala): Miles (Umeå): Nirbhay (Uppsala): Oytun (Umeå): Pallabi (Umeå): Sona (Uppsala): Sonali (Umeå): Tony (Uppsala): Vishnu (Umeå): ## 76. Questions about writing a function body? Anastasia (Uppsala): Anastasiia (Umeå): Angelica (Uppsala): Elizabeth (Umeå): Erin (Umeå): Farina (Umeå): Garance (Umeå): Ghada (Uppsala): Gustavo (Umeå): Henrik (Umeå): Imke (Uppsala): Julia (Uppsala): Katja (Uppsala): Linglong (Uppsala): Luz María (Uppsala): Marga (Umeå): Maria (Uppsala): Maria (Uppsala): Mariya (Uppsala): Mattia (Uppsala): Miles (Umeå): Nirbhay (Uppsala): Oytun (Umeå): Pallabi (Umeå): Sona (Uppsala): Sonali (Umeå): Tony (Uppsala): Vishnu (Umeå): # 8. Expressing a set ## 79. What is set? Anastasia (Uppsala): Anastasiia (Umeå): Angelica (Uppsala): Elizabeth (Umeå): Erin (Umeå): Farina (Umeå): Garance (Umeå): Ghada (Uppsala): Gustavo (Umeå): Henrik (Umeå): Imke (Uppsala): Julia (Uppsala): Katja (Uppsala): Linglong (Uppsala): Luz María (Uppsala): Marga (Umeå): Maria (Uppsala): Maria (Uppsala): Mariya (Uppsala): Mattia (Uppsala): Miles (Umeå): Nirbhay (Uppsala): Oytun (Umeå): Pallabi (Umeå): Sona (Uppsala): Sonali (Umeå): Tony (Uppsala): Vishnu (Umeå): ## 81. Question Anastasia (Uppsala): Anastasiia (Umeå): Angelica (Uppsala): Elizabeth (Umeå): Erin (Umeå): Farina (Umeå): Garance (Umeå): Ghada (Uppsala): Gustavo (Umeå): Henrik (Umeå): Imke (Uppsala): Julia (Uppsala): Katja (Uppsala): Linglong (Uppsala): Luz María (Uppsala): Marga (Umeå): Maria (Uppsala): Maria (Uppsala): Mariya (Uppsala): Mattia (Uppsala): Miles (Umeå): Nirbhay (Uppsala): Oytun (Umeå): Pallabi (Umeå): Sona (Uppsala): Sonali (Umeå): Tony (Uppsala): Vishnu (Umeå): ## 83. Question Anastasia (Uppsala): Anastasiia (Umeå): Angelica (Uppsala): Elizabeth (Umeå): Erin (Umeå): Farina (Umeå): Garance (Umeå): Ghada (Uppsala): Gustavo (Umeå): Henrik (Umeå): Imke (Uppsala): Julia (Uppsala): Katja (Uppsala): Linglong (Uppsala): Luz María (Uppsala): Marga (Umeå): Maria (Uppsala): Maria (Uppsala): Mariya (Uppsala): Mattia (Uppsala): Miles (Umeå): Nirbhay (Uppsala): Oytun (Umeå): Pallabi (Umeå): Sona (Uppsala): Sonali (Umeå): Tony (Uppsala): Vishnu (Umeå): ## 86. Questions about sets? Anastasia (Uppsala): Anastasiia (Umeå): Angelica (Uppsala): Elizabeth (Umeå): Erin (Umeå): Farina (Umeå): Garance (Umeå): Ghada (Uppsala): Gustavo (Umeå): Henrik (Umeå): Imke (Uppsala): Julia (Uppsala): Katja (Uppsala): Linglong (Uppsala): Luz María (Uppsala): Marga (Umeå): Maria (Uppsala): Maria (Uppsala): Mariya (Uppsala): Mattia (Uppsala): Miles (Umeå): Nirbhay (Uppsala): Oytun (Umeå): Pallabi (Umeå): Sona (Uppsala): Sonali (Umeå): Tony (Uppsala): Vishnu (Umeå): # 9. Expressing a dictionary ## 88. Trick question Anastasia (Uppsala): Anastasiia (Umeå): Angelica (Uppsala): Elizabeth (Umeå): Erin (Umeå): Farina (Umeå): Garance (Umeå): Ghada (Uppsala): Gustavo (Umeå): Henrik (Umeå): Imke (Uppsala): Julia (Uppsala): Katja (Uppsala): Linglong (Uppsala): Luz María (Uppsala): Marga (Umeå): Maria (Uppsala): Maria (Uppsala): Mariya (Uppsala): Mattia (Uppsala): Miles (Umeå): Nirbhay (Uppsala): Oytun (Umeå): Pallabi (Umeå): Sona (Uppsala): Sonali (Umeå): Tony (Uppsala): Vishnu (Umeå): ## 91. Questions about dictionaries? Anastasia (Uppsala): Anastasiia (Umeå): Angelica (Uppsala): Elizabeth (Umeå): Erin (Umeå): Farina (Umeå): Garance (Umeå): Ghada (Uppsala): Gustavo (Umeå): Henrik (Umeå): Imke (Uppsala): Julia (Uppsala): Katja (Uppsala): Linglong (Uppsala): Luz María (Uppsala): Marga (Umeå): Maria (Uppsala): Maria (Uppsala): Mariya (Uppsala): Mattia (Uppsala): Miles (Umeå): Nirbhay (Uppsala): Oytun (Umeå): Pallabi (Umeå): Sona (Uppsala): Sonali (Umeå): Tony (Uppsala): Vishnu (Umeå): # 10. Using system arguments ## 94. Problem Anastasia (Uppsala): Anastasiia (Umeå): Angelica (Uppsala): Elizabeth (Umeå): Erin (Umeå): Farina (Umeå): Garance (Umeå): Ghada (Uppsala): Gustavo (Umeå): Henrik (Umeå): Imke (Uppsala): Julia (Uppsala): Katja (Uppsala): Linglong (Uppsala): Luz María (Uppsala): Marga (Umeå): Maria (Uppsala): Maria (Uppsala): Mariya (Uppsala): Mattia (Uppsala): Miles (Umeå): Nirbhay (Uppsala): Oytun (Umeå): Pallabi (Umeå): Sona (Uppsala): Sonali (Umeå): Tony (Uppsala): Vishnu (Umeå): ## 96. Exercise, little help Anastasia (Uppsala): Anastasiia (Umeå): Angelica (Uppsala): Elizabeth (Umeå): Erin (Umeå): Farina (Umeå): Garance (Umeå): Ghada (Uppsala): Gustavo (Umeå): Henrik (Umeå): Imke (Uppsala): Julia (Uppsala): Katja (Uppsala): Linglong (Uppsala): Luz María (Uppsala): Marga (Umeå): Maria (Uppsala): Maria (Uppsala): Mariya (Uppsala): Mattia (Uppsala): Miles (Umeå): Nirbhay (Uppsala): Oytun (Umeå): Pallabi (Umeå): Sona (Uppsala): Sonali (Umeå): Tony (Uppsala): Vishnu (Umeå): ## 99. Questions about command line arguments? Anastasia (Uppsala): Anastasiia (Umeå): Angelica (Uppsala): Elizabeth (Umeå): Erin (Umeå): Farina (Umeå): Garance (Umeå): Ghada (Uppsala): Gustavo (Umeå): Henrik (Umeå): Imke (Uppsala): Julia (Uppsala): Katja (Uppsala): Linglong (Uppsala): Luz María (Uppsala): Marga (Umeå): Maria (Uppsala): Maria (Uppsala): Mariya (Uppsala): Mattia (Uppsala): Miles (Umeå): Nirbhay (Uppsala): Oytun (Umeå): Pallabi (Umeå): Sona (Uppsala): Sonali (Umeå): Tony (Uppsala): Vishnu (Umeå): ## 101. Questions about today’s theory? Anastasia (Uppsala): Anastasiia (Umeå): Angelica (Uppsala): Elizabeth (Umeå): Erin (Umeå): Farina (Umeå): Garance (Umeå): Ghada (Uppsala): Gustavo (Umeå): Henrik (Umeå): Imke (Uppsala): Julia (Uppsala): Katja (Uppsala): Linglong (Uppsala): Luz María (Uppsala): Marga (Umeå): Maria (Uppsala): Maria (Uppsala): Mariya (Uppsala): Mattia (Uppsala): Miles (Umeå): Nirbhay (Uppsala): Oytun (Umeå): Pallabi (Umeå): Sona (Uppsala): Sonali (Umeå): Tony (Uppsala): Vishnu (Umeå): # Links * [This document](https://hackmd.io/@qfRrKmbUR9-jszg-SvdO9A/H1amxfmWa)