Структура, теория, примеры и лучшие практики — всё в одном месте
def is_palindrome(s):
clean = ''.join(c.lower() for c in s if c.isalnum())
return clean == clean[::-1]
print(is_palindrome('А роза упала на лапу Азора')) # True
def fib_gen(n):
a, b = 0, 1
for _ in range(n):
yield a
a, b = b, a + b
for num in fib_gen(10):
print(num, end=' ') # 0 1 1 2 3 5 8 13 21 34
import requests
response = requests.get('https://api.github.com')
if response.status_code == 200:
data = response.json()
print(data.get('current_user_url'))
import pandas as pd
df = pd.read_csv('data.csv')
print(df.head())
print(df.describe())
df['new_col'] = df['col1'] + df['col2']