[PYTHON] Learning record 3 (7th day)

Learning record (7th day)

Start studying: Saturday, December 7th Books used: Miyuki Oshige "Details! Python3 Introductory Note ”(Sotec, 2017)

Resume from [Sort elements in the list (Ch.6 / p.170)](6th day), Finished until [Retrieving values from dictionary (Ch.9 / p.229)](7th day)

List comprehension

-Write a for-in syntax in [] and create a new list from iterable objects. (Iterable: An object that can retrieve the elements contained in the value one by one.) -You can handle two lists at the same time with zip (). The length is the same as the shorter one. ・ A conditional expression can be added with an if statement. (Expression for variable in iterable if conditional expression) Extract only those that meet the conditions in the list. (Natural numbers only, etc.) -It is also possible to insert multiple for-in statements. (Extracting the nesting list)

Search the list

-Implemented with the in operator. BIG3 = ["Bench Press", "Squat", "Deadlift"] "Bench press" in BIG3 → True, "Arm curl" in BIG3 → False Partial search is not possible as it only searches for matches "Bench" in BIG3 → False. (If implemented, for-if statement) ・ Index () → Returns the index number of the found location. ・ Count () → Returns the number found.

Tuple

-Treat multiple values as one. Separate with commas. Or the built-in function tuple () -Lists are mutable (variables that can be changed), tuples are immutable (variables that cannot be changed) The list is [] and the tuple is (). The contents cannot be changed, but can be overwritten or concatenated Mutual conversion is possible with list () ⇆ tuple ()

set

-If the numerical value to be embedded in the character string is used as the argument of format (), it will be entered in the replacement field {} in order. This code can also be written with f "{} (past review, p.90). -Create a set by separating the values you want to group with commas and enclosing them in {}. ** Unlike the list, duplicate elements cannot be included ** (Even if they are included, they can be combined into one) -Like a list, the number of elements is counted by len (). -There is also a combination technique of deleting duplicate values with set (), listing with list (), and sorting with sort (). -Add an element with add (), delete an element with remove () or discard (), and empty it with clear (). -Although you can retrieve elements with pop (), you cannot specify the index number because there is no concept of alignment in the set. -Frozenset () can be used to create a set that cannot be added or changed.

Set comprehension

The notation method is almost the same as the list comprehension notation. [] Becomes {}.

Set set operation

-Since a set treats multiple values as a ** set **, it cannot be calculated with operators like a list. Therefore, if you want to find the union, you need to use the | operator or union (). Of course, if there are duplicate values, it will be one. In terms of number A (is it?), The image is A∪B (recognized as) -The product set is the & operator, intersection (), or the intersection. A∩B ・ The difference set is the operator or difference (), (A∪B) -B (may be wrong) ・ The target difference is the ^ operator or symmetric_difference (), (A∪B)-(A∩B) (may be wrong) -Update () updates the set with the union with the element given as an argument, what is the difference from add? I know it's different, but I'm not sure. Can you write them all together? Hold for the time being

dictionary

-Same as a list, a data format that handles multiple values together By setting the "key", the value of the specified element is retrieved. ・ Notated as {key: value}. Keys can only be set to immutable values (that is, tuples can be set) ・ Dictionary with dict () -The value can be changed / added with the dictionary [key] = value. setdefault () is left as it is if there is a key, otherwise added

Recommended Posts

Learning record 4 (8th day)
Learning record 9 (13th day)
Learning record 3 (7th day)
Learning record 5 (9th day)
Learning record 6 (10th day)
Learning record 8 (12th day)
Learning record 1 (4th day)
Learning record 7 (11th day)
Learning record 2 (6th day)
Learning record 16 (20th day)
Learning record 22 (26th day)
Learning record No. 21 (25th day)
Learning record 13 (17th day) Kaggle3
Learning record No. 10 (14th day)
Learning record 12 (16th day) Kaggle2
Learning record No. 24 (28th day)
Learning record No. 23 (27th day)
Learning record No. 25 (29th day)
Learning record No. 26 (30th day)
Learning record No. 20 (24th day)
Learning record No. 14 (18th day) Kaggle4
Learning record No. 15 (19th day) Kaggle5
Learning record 11 (15th day) Kaggle participation
Programming learning record day 2
Learning record
Learning record No. 18 (22nd day)
Learning record # 3
Learning record # 1
Learning record # 2
Learning record No. 19 (23rd day)
Learning record No. 29 (33rd day)
Learning record No. 28 (32nd day)
Learning record No. 27 (31st day)
Python learning day 4
Learning record (2nd day) Scraping by #BeautifulSoup
Learning record so far
Learning record (4th day) #How to get the absolute path from the relative path
Linux learning record ① Plan
Effective Python Learning Memorandum Day 15 [15/100]
<Course> Deep Learning: Day2 CNN
Effective Python Learning Memorandum Day 6 [6/100]
Effective Python Learning Memorandum Day 12 [12/100]
Effective Python Learning Memorandum Day 9 [9/100]
Effective Python Learning Memorandum Day 8 [8/100]
Rabbit Challenge Deep Learning 1Day
<Course> Deep Learning: Day1 NN
Effective Python Learning Memorandum Day 14 [14/100]
Effective Python Learning Memorandum Day 1 [1/100]
Subjects> Deep Learning: Day3 RNN
Rabbit Challenge Deep Learning 2Day
Effective Python Learning Memorandum Day 13 [13/100]
Effective Python Learning Memorandum Day 3 [3/100]
Effective Python Learning Memorandum Day 5 [5/100]
Effective Python Learning Memorandum Day 4 [4/100]
Effective Python Learning Memorandum Day 7 [7/100]
Effective Python Learning Memorandum Day 2 [2/100]
Learning record (3rd day) #CSS selector description method #BeautifulSoup scraping
Learning record (6th day) #Set type #Dictionary type #Mutual conversion of list tuple set #ndarray type #Pandas (DataFrame type)
Thoroughly study Deep Learning [DW Day 0]
Deep Learning Specialization (Coursera) Self-study record (C3W1)
[Rabbit Challenge (E qualification)] Deep learning (day2)