print("שלום עולם!")
name = input("מה שמך? ")
print(f"נעים להכיר, {name}!")python main.pypython -m venv venvvenv\Scripts\activatesource venv/bin/activate Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSignedage = 25
name = "דני"
height = 1.75
is_student = True
grades = [90, 85, 95, 88]
person = {"name": "דני", "age": 25}for i in range(5):
print(f"מספר {i}")
numbers = [1, 2, 3, 4, 5]
for num in numbers:
if num % 2 == 0:
print(f"{num} זוגי")
else:
print(f"{num} אי-זוגי")
count = 0
while count < 3:
print("חוזר...")
count += 1def calculate_average(numbers):
"""מחשבת ממוצע של רשימת מספרים"""
if len(numbers) == 0:
return 0
return sum(numbers) / len(numbers)
def greet_user(name, greeting="שלום"):
"""מברכת משתמש עם ברכה מותאמת אישית"""
return f"{greeting}, {name}!"
# שימוש בפונקציות
grades = [85, 90, 78, 92, 88]
avg = calculate_average(grades)
print(f"הממוצע: {avg}")
message = greet_user("שרה", "בוקר טוב")
print(message)__init__ לאתחול תכונות ואת מתודת greet. שימו לב איך 'self' משמש לגישה והגדרה של התכונות self.name ו-self.age בתוך המחלקה.class Person:
def __init__(self, name, age):
self.name = name # הגדרת תכונה name עבור המופע הנוכחי
self.age = age # הגדרת תכונה age עבור המופע הנוכחי
def greet(self):
return f"שלום, שמי {self.name}." # גישה לתכונה name של המופע הנוכחי
# יצירת אובייקט ושימוש בו
MOSHE = Person("משה", 45)
print(MOSHE.greet())
YOSSI= Person("יוסי כליכליכלי", 35)
print(YOSSI.greet())src/
├── main.py
├── models/
├── utils/
└── config/from src.models import User
from src.utils.validators import validate_emailpip install requests
pip install pandas
pip install flask
pip install pytestpip freeze > requirements.txt
pip install -r requirements.txtimport numpy as np
# יצירת מערכים
arr = np.array([1, 2, 3, 4, 5])
print(f"מערך: {arr}")
# פעולות בסיסיות
squared = arr ** 2
print(f"בריבוע: {squared}")
mean_val = arr.mean()
print(f"ממוצע: {mean_val}")
# יצירת מטריצה
matrix = np.zeros((2, 3))
print(f"מטריצה אפסים:\n{matrix}")
# אינדקס וחתך
data = np.array([[1, 2], [3, 4]])
print(f"איבר: {data[0, 1]}") # 2
print(f"שורה ראשונה: {data[0, :]}") # [1 2]
import matplotlib.pyplot as plt
import numpy as np
# גרף קווי בסיסי עם עיצוב
x = np.linspace(0, 10, 100)
y1 = np.sin(x)
y2 = np.cos(x)
plt.figure(figsize=(10, 6))
plt.plot(x, y1, label='sin(x)', linewidth=2, color='blue')
plt.plot(x, y2, label='cos(x)', linewidth=2, color='red', linestyle='--')
plt.title('פונקציות טריגונומטריות', fontsize=16)
plt.xlabel('ערך X', fontsize=12)
plt.ylabel('ערך Y', fontsize=12)
plt.legend()
plt.grid(True, alpha=0.3)
plt.show()
i == 5len(my_list)
user.name
total_sum / count# כתוב פונקציה שמקבלת רשימת מספרים ומחזירה את הממוצע שלהם
def calculate_average(numbers):
return sum(numbers) / len(numbers)