Saturday, April 27, 2024

📑 Default Arguments

📑 Task

1) What will the program print in the last 2 lines?
2) Why do variables change or not change in this way?
3) What minimal changes can be made to the program so that the values will be increased
and the last 2 lines will be 3 [0, 1, 2, 3] and 0 [0, 1, 2, 3]?

📑 Answer

1) 1 [0, 1, 1, 1] and 0 [0, 1, 1, 1]
2) Variables with mutable and immutable objects
are used as default arguments to a function
3)

📑 Presence in the List

📑 Task

1) What does the program do?
2) Can you write a function based on the same splitting procedure
to sort letters in a word (vowels and consonants)?

📑 Answer

1) This program generates x (a list of 10 random integers between 0 and 9) and
then initializes two empty lists (not_in_x and in_x) to store digits
based on their presence in the list x.
2)