Learn Python Coding
38.8K subscribers
612 photos
27 videos
24 files
369 links
Learn Python through simple, practical examples and real coding ideas. Clear explanations, useful snippets, and hands-on learning for anyone starting or improving their programming skills.

Admin: @HusseinSheikho || @Hussein_Sheikho
Download Telegram
The Python library itertools contains many useful functions. 🐍

One of them is compress(), which returns an iterator over the elements from data, for which the corresponding element in selectors is equal to True. 🔍💻

Here's an example: 📝👇

#Python #Programming #Itertools #Coding #Tech #DataScience
🔥2
Cheat sheet on the basics of Python: 🐍📚

basic syntax and language rules 📝
scalar types — basic data types (int, float, bool, str, NoneType) 🔢

datetime — working with date and time 📅

data structures — Python data structures (list, tuple, dict, set) 🗄

list — mutable lists for storing data collections 📋
tuple — immutable sequences of values 🔒
dict (hash map) — storing data in a key-value format 🗝
set — unique elements without order 🔘

slicing — obtaining parts of sequences through indices and step ✂️

module/library — connecting modules and libraries 🔌

help functions — using help() and dir() to explore the Python API 🛠

#Python #Coding #DataScience #Programming #Tech #DevCommunity
3🔥3👍2
Do you know that Python can shift sequences without slicing and creating new lists? 🤔

When you need to cyclically shift data, many use slicing:

data = data[-1:] + data[:-1]

But deque.rotate() does this at the level of the data structure and usually works more efficiently for cyclical operations. 🚀

q.rotate(1)

A negative value rotates the queue in the other direction. ⬅️

q.rotate(-2)

This is useful for ring buffers, task schedulers, cyclical queues, and round-robin algorithms. 🔄

workers.rotate(-1)

🔥 deque.rotate() allows you to implement cyclical data structures without manual index logic and without creating new lists. 💡

#Python #Programming #Deque #CodingTips #Tech #DevCommunity
3