◀️اینجا با تمرین و چالش با هم پایتون رو یاد می گیریم
⏮بانک اطلاعاتی پایتون
پروژه / code/ cheat sheet
+ویدیوهای آموزشی
+کتابهای پایتون
تبلیغات:
@alloadv
🔁ادمین :
@maryam3771
Post #1971
2.42K
پا @python4all_pro
Showing posts older than #1972 · Back to latest






Forwarded from FaraDars_Course

Here's your comprehensive guide to understanding and building Model Context Protocol (MCP) Servers for Python developers through interactive learning experiences.
Forwarded from FaraDars_Course

a, b = 5, 10
a, b = b, a
result = "Even" if x % 2 == 0 else "Odd"
squares = [x**2 for x in range(10)]
evens = [x for x in range(10) if x % 2 == 0]
unique = {x for x in [1,2,2,3]} # remove duplicates
squares = {x: x**2 for x in range(5)} # dict comprehensionfrom collections import Counter
most_common = Counter(['a','b','a','c']).most_common(1)[0][0]
a = {'x': 1}
b = {'y': 2}
merged = a | bdef stats(x):
return max(x), min(x), sum(x)
high, low, total = stats([1, 2, 3])
names = ['a', 'b']
scores = [90, 85]
for n, s in zip(names, scores):
print(f"{n}: {s}")
nested = [[1,2], [3,4]]
flat = [item for sublist in nested for item in sublist]
from collections import defaultdict
d = defaultdict(int)
d['apple'] += 1 # no KeyError
square = lambda x: x**2
print(square(4))
for i, v in enumerate(['a', 'b', 'c']):
print(i, v)
d = {'a': 3, 'b': 1, 'c': 2}
sorted_by_val = sorted(d.items(), key=lambda x: x[1])with open('file.txt') as f:
lines = f.read().splitlines()def add(x: int, y: int) -> int:
return x + y

Forwarded from تهران دیتا-دانشگاه تهران
