تجمع المبرمجين العرب️
الذهاب إلى القناة على Telegram
الجروب مخصص للنقاش في مجال البرمجة فقط، وبخلافه سيتم حظر اي شخص يتكلم في أي مجال اخر غير مجال البرمجة
إظهار المزيدالعراقالفئة غير محددة
7 902
المشتركون
لا توجد بيانات24 ساعات
لا توجد بيانات7 أيام
لا توجد بيانات30 أيام
أرشيف المشاركات
https://www.udemy.com/course/complete-flutter-arabic/?couponCode=FREE_DECEMBER
كورس فلاتر من ع يوديمي شباب
«أمْسَيْنَا عَلَى فِطْرَةِ الإسْلَامِ ، وَعَلَى كَلِمَةِ الإخْلَاصِ ، وَعَلَى دِينِ نَبِيِّنَا مُحَمَّدٍ صَلَّى اللهُ عَلَيْهِ وَسَلَّمَ ، وَعَلَى مِلَّةِ أبِينَا إبْرَاهِيمَ ، حَنِيفًا مُسْلِمًا وَمَا كَانَ مِنَ المُشْرِكِينَ»🌸
نظام ادارة المبيعات
هذا الكود يعد نظام إدارة المنتجات. يتيح الكود عدة وظائف مختلفة لإضافة وحذف وتحديث البيانات في قائمة المنتجات، وكذلك طباعة القائمة بشكل مهيأ.
- تعريف الدالة add_product(): تقوم بإضافة منتج جديد إلى قائمة المنتجات باستخدام اسم المنتج وسعره. يتم التحقق من أن الاسم المدخل صالح وأن السعر صحيح.
- تعريف الدالة remove_product(): تقوم بإزالة منتج موجود في قائمة المنتجات باستخدام اسم المنتج.
- تعريف الدالة update_product(): تقوم بتحديث سعر منتج موجود في قائمة المنتجات باستخدام اسم المنتج والسعر الجديد.
- تعريف الدالة print_products(): تطبع قائمة بجميع المنتجات في قائمة المنتجات بشكل مهيأ وتحسب الإيراد الإجمالي.
- تعريف الدالة main(): يتم تنفيذ هذه الدالة لتشغيل النظام. تطبع الدالة الخيارات المتاحة للمستخدم وتطلب منه تحديد الخيارات المطلوبة. يتم تنفيذ الوظائف المختلفة باستخدام الدوال السابقة. يتم تكرار طباعة القائمة حتى يقوم المستخدم بإنهاء البرنامج.
def add_product(name, price):
if not name:
print("Please enter a valid product name.")
return
try:
price = float(price)
except ValueError:
print("Please enter a valid price for the product.")
return
products[name] = price
print(f"{name} has been added to the product list with a price of {price}.")
# Add a new product to the product list
# Parameters: name (string) - the name of the product
# price (float) - the price of the product
def add_product(name, price):
# Remove a product from the product list
# Parameters: name (string) - the name of the product to be removed
def remove_product(name):
# Update the price of an existing product in the product list
# Parameters: name (string) - the name of the product to be updated
# price (float) - the new price of the product
def update_product(name, price):
# Print a formatted list of all products in the product list and their total revenue
def print_products():
def main():
while True:
print("Please choose an option:")
print("1. Add a product")
print("2. Remove a product")
print("3. Update a product's price")
print("4. View all products")
print("5. Quit")
choice = input()
if choice == "1":
name = input("Enter the name of the product: ")
price = input("Enter the price of the product: ")
add_product(name, price)
elif choice == "2":
name = input("Enter the name of the product to remove: ")
remove_product(name)
elif choice == "3":
name = input("Enter the name of the product to update: ")
price = input("Enter the new price of the product: ")
update_product(name, price)
elif choice == "4":
print_products()
elif choice == "5":
break
else:
print("Invalid choice. Please try again.")
Welcome to the Product Management System!
Please choose an option:
1. Add a product - Add a new product to the product list
2. Remove a product - Remove a product from the product list
3. Update a product's price - Update the price of an existing product in the product list
4. View all products - Print a formatted list of all products in the product list and their total revenue
5. Quit - Exit the program
def print_products():
total_revenue = 0
print("Product Name\tPrice")
print("-------------\t-----")
for name, price in products.items():
print(f"{name}\t\t{price:.2f}")
total_revenue += price
print("-------------\t-----")
print(f"Total Revenue:\t{total_revenue:.2f}")