Small Python School #5
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:
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.
The arithmetic progression is a beautiful object, it does not need a lot of RAM. It will calculate the element as requested.
One of the typical things with an arithmatic progression is to "run" through it.
A = range(1,6); print(*A);
The for loop in Python is an access loop to an element of an iterable object. for x in A:
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.
A = [1,2,3]; type(A); #list
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.
List of tuples. A=[(1,10),(2,20),(3,30)]
Set set, dict dictionaries
Elements in sets and dictionaries are not ordered.
S={'First';
'Second'}S.add - for a set. S.append - for a list.
if 'First' in S:
print();A set can be combined, intersected, subtracted from one another
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:
- For print sep - separator
- For print always carry at the end. To prevent the transfer, you can make the end parameter. print (a, end = '')
- Basic arithmetic operations - addition, subtraction, multiplication, division / the result is a real number, // - an integer (the remainder is discarded), % remainder of division, ** degree.
- Priority of execution. The highest at the brackets. If something is taken in brackets, then it is executed first.
- Parentheses - degree - unary minus - multiplication, division - addition, subtraction
- You can calculate square roots or non-integer powers
- If we divide by an integer, then round down.
- 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!
your hashtag has been upvoted on @upvoteandresteem