Small Python School #5

in Steem Schools2 years ago

Третий урок, копия.png

We continue to study Python. In touch "Small School of learning Python", lesson 5.

Course1

The daily rate is 14-15 minutes.
53-65 minute lesson.

Theses:

  1. Range is an iterable object. range - start, stop, step. We move from start to stop in "step" increments. Essentially an arithmetic progression, but range is not an arithmetic progression. It is a generator of arithmetic processes.

  2. The arithmetic progression is a beautiful object, it does not need a lot of RAM. It will calculate the element as requested.

  3. One of the typical things with an arithmatic progression is to "run" through it.

  4. A = range(1,6); print(*A);

  5. The for loop in Python is an access loop to an element of an iterable object. for x in A:

  6. If we understand the logic from point 5, then A can be replaced by any iterable object. In particular, a tuple. Moreover, this tuple can have numbers in any order.

  7. A = [1,2,3]; type(A); #list

  8. The list type, unlike a tuple, is mutable. It creates links, in each of which you can put anything you want. Only data of the same type should be put into an array. A list is a sequence of object references.

  9. List of tuples. A=[(1,10),(2,20),(3,30)]

  10. Set set, dict dictionaries

  11. Elements in sets and dictionaries are not ordered.

  12. S={'First';
    'Second'}

  13. S.add - for a set. S.append - for a list.

  14. if 'First' in S:
    print();

  15. A set can be combined, intersected, subtracted from one another

  16. dict - key + value. One of the features - you can not enter the set twice. The element is included once. The dictionary can be entered multiple times, but the key is unique.

17.D={'First':334,
'Second':34234}

18.D[third]=768768

course2

The daily rate is 1/2-1/3 lessons.

Theses:

  1. For print sep - separator
  2. For print always carry at the end. To prevent the transfer, you can make the end parameter. print (a, end = '')
  3. Basic arithmetic operations - addition, subtraction, multiplication, division / the result is a real number, // - an integer (the remainder is discarded), % remainder of division, ** degree.
  4. Priority of execution. The highest at the brackets. If something is taken in brackets, then it is executed first.
  5. Parentheses - degree - unary minus - multiplication, division - addition, subtraction
  6. You can calculate square roots or non-integer powers
  7. If we divide by an integer, then round down.
  8. It is also important to pay attention to the operation // with negative numbers. The result is quite different than with positive ones.

First lesson: https://steemit.com/hive-152587/@alexmove.witness/small-python-school-1
Second lesson:
https://steemit.com/hive-152587/@alexmove.witness/small-python-school-2
Third lesson: https://steemit.com/hive-152587/@alexmove.witness/small-python-school-3
Fourth lesson: https://steemit.com/hive-152587/@alexmove.witness/small-python-school-4

I invite you to take part in the contest:
https://steemit.com/contest/@alexmove.witness/contest-20-steem-from-a-small-school-of-learning-python

Small Python School Support Chat:
https://t.me/+lQtdzunysoxhOTgy

Thanks for studying.
Thank you for your attention.
Have a good day!