يعطيك ألف عافية أستاذ، وهي الكود كما يلي: offersname = input("Write the name of providers (separate each name with a comma): ") offerscost = input("Write the cost of offers (separate each name with a comma): ") offersnamelist = offersname.split(",") offerscostlist = offerscost.split(",") if len(offersnamelist) != 5 and len(offerscostlist) != 5: print("The number of Providers and number of offers costs must equal 5") elif len(offersnamelist) == 5 and len(offerscostlist) != 5: print("The number of offers costs must equal 5") elif len(offersnamelist) != 5 and len(offerscostlist) == 5: print("The number of Providers must equal 5") else: offer1rate = float(input(f"Write the rate of {offersnamelist[0]}'s bid, with cost {offerscostlist[0]}: ")) offer2rate = float(input(f"Write the rate of {offersnamelist[1]}'s bid, with cost {offerscostlist[1]}: ")) offer3rate = float(input(f"Write the rate of {offersnamelist[2]}'s bid, with cost {offerscostlist[2]}: ")) offer4rate = float(input(f"Write the rate of {offersnamelist[3]}'s bid, with cost {offerscostlist[3]}: ")) offer5rate = float(input(f"Write the rate of {offersnamelist[4]}'s bid, with cost {offerscostlist[4]}: ")) acceptedoffers = int(0) acceptedofferslist =[] ratelist = [] if offer1rate >= 5: offer1degree = int(1) acceptedofferslist.append(offer1rate) ratelist.append(offer1rate) else: offer1degree = int(0) if offer2rate >= 5: offer2degree = int(1) acceptedofferslist.append(offer2rate) ratelist.append(offer2rate) else: offer2degree = int(0) if offer3rate >= 5: offer3degree = int(1) acceptedofferslist.append(offer3rate) ratelist.append(offer3rate) else: offer3degree = int(0) if offer4rate >= 5: offer4degree = int(1) acceptedofferslist.append(offer4rate) ratelist.append(offer4rate) else: offer4degree = int(0) if offer5rate >= 5: offer5degree = int(1) acceptedofferslist.append(offer5rate) ratelist.append(offer5rate) else: offer5degree = int(0) acceptedoffers = offer1degree + offer2degree + offer3degree + offer4degree + offer5degree print(f"=*=*=*=*=*=*=*=*=*=*=*=*") print(f"Number of offered bids: 5") print(f"Number of accepted offers: {acceptedoffers}") if acceptedoffers != 0: a = min(acceptedofferslist) i = ratelist.index(a) print(f"The winner offer is: {offersnamelist[ratelist.index(min(acceptedofferslist))]}, with cost {offerscostlist[ratelist.index(min(acceptedofferslist))]}, and its rate is {min(acceptedofferslist)}") else: print(f"None of the offers are accepted")
Training Code as below: Name = input("Write the names of providers (Separate each name with a comma): ") Cost = input("Write the cost of offers (Separate each amount with a comma): ") #Rates: Type[float] = list Rates = [] Accepted = [] Providers = Name.split(",") Offers = Cost.split(",") if len(Offers) != 5: print("You should Write Five Amounts of offers ") else: I = 0 Rate1 = float(input(f"Write the rate of {Providers[I]}'s bid, with cost {Offers[I]} : ")) Rates.append(Rate1) if Rate1 < 5: pass else: Accepted.append(Rate1) print(Rates) I = I + 1 Rate2 = float(input(f"Write the rate of {Providers[I]}'s bid, with cost {Offers[I]} : ")) Rates.append(Rate2) if Rate2 < 5: pass else: Accepted.append(Rate2) print(Rates) I = I + 1 Rate3 = float(input(f"Write the rate of {Providers[I]}'s bid, with cost {Offers[I]} : ")) Rates.append(Rate3) if Rate3 < 5: pass else: Accepted.append(Rate3) print(Rates) I = I + 1 Rate4 = float(input(f"Write the rate of {Providers[I]}'s bid, with cost {Offers[I]} : ")) Rates.insert(I, Rate4) if Rate4 < 5: pass else: Accepted.append(Rate4) print(Rates) I = I + 1 Rate5 = float(input(f"Write the rate of {Providers[I]}'s bid, with cost {Offers[I]} : ")) if Rate5 < 5: pass else: Accepted.append(Rate5) print(Rates) print("=============================") print("Number of offers bids:", len(Offers)) print("Number of offers Accepted:", len(Accepted)) print(Accepted) W = min(Accepted) ind = Rates.index(W) print(f"The winner offer is: {Providers[ind]}, with cost {Offers[ind]}, and its rate is {W} ")
وفقك الله استأذنا الغالي كل درس عم تزيد المتعة اكثر واكثر عذرا على التأخير #inputs print("hello world") print("This is the Tender Analysis Program") print("-------------------------------------------------") providers=input('write the name of providers (separate each name with a comma))').split(",") costs= input('write the cost offers (separate each offer with acomma))').split(",") if len(costs)!= 5 or len(providers)!=5: print('please insert 5 offers ') exit() rate=[ float( input(f"write the rate of {providers[0]}'s bid, with cost {costs[0]} : "))] rate.append(float(input(f"write the rate of {providers[1]}'s bid, with cost {costs[1]} : "))) rate.append(float(input(f"write the rate of {providers[2]}'s bid, with cost {costs[2]} : "))) rate.append(float(input(f"write the rate of {providers[3]}'s bid, with cost {costs[3]} : "))) rate.append(float(input(f"write the rate of {providers[4]}'s bid, with cost {costs[4]} : "))) #result_lists accept_p=[] accept_c=[] accept_r=[] #funtions n=0 if int(rate[n]) > 5: accept_r.append(rate[n]) accept_p.append(providers[n]) accept_c.append(costs[n]) n=n+1 if rate[n]> 5: accept_r.append(rate[n]) accept_p.append(providers[n]) accept_c.append(costs[n]) n=n+1 if rate[n] > 5 : accept_r.append(rate[n]) accept_p.append(providers[n]) accept_c.append(costs[n]) n=n+1 if rate[n] > 5: accept_r.append(rate[n]) accept_p.append(providers[n]) accept_c.append(costs[n]) n=n+1 if int(rate[n]) > 5: accept_r.append(rate[n]) accept_p.append(providers[n]) accept_c.append(costs[n]) all_offers = len(rate) good_offers = len(accept_r) win_offer_index= accept_c.index(min(accept_c)) #result print("=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*") print(f"numbers of offerd bids : {all_offers}") print(f"numbers of accepted bids : {good_offers} ") print(f"the winner offer is : {accept_p[win_offer_index]} with cost {min(accept_c)} and its rate {accept_r[win_offer_index]} ")
@@malek_10 ألف شكر اخي الغالي كانا لم نأخذ تعليمة for ولكن الحمدلله فهمتها في درس القاموس ألف شكر على اهتمامك واتشرف بردك الجميل واكون من متابعيك ألف شكر اخي الغالي
حل التمرين rates_List = [] accepted_offers = [] accepted_offers_number = 0 count = 0 providers_names = input("Write the names of the providers (Separate each name with a space and choose 5 only): ") costs = input("Write the costs of the offers (Separate each cost with a space): ") providers_list = providers_names.split() costs_list = costs.split() if len(providers_list) > 5 or len(costs_list) > 5: print("Please choose 5 offers only.") exit() print(" ") print("Rate the offers (Highest rate for the lowest cost): ") while count < 5: rate = input(f"Write the rate of {providers_list[count]}'s, with cost {costs_list[count]}: ") rates_List.insert(count, rate) count = count + 1 for i in rates_List: if float(i)
مابعرف شو فائدة انه نكتب الحل بالتعليقات اذا مافي اي تفاعل منك ولاحتى يمكن تشوف التعليقات حتى يحس المتابع انه عمل شي مفيد يعني مثلا ممكن نحلها ونخليها عندنا حتى المقطع القادم ونشوف الحل !
after alot of working >>> I did another solution for this practice >>> still feeling my self a genius providers =[] cost = [] evaluation = [] count = int(input("how many providers you want to process ? ")) x=1 for x in range(count): v=input("please enter the first provider: ").title() n = float(input("please enter the first cost for " + v + ": ")) eva1 = float(input(f"please enter your evaluation for {v} with cost {n} : ")) providers.append(v) cost.append(n) if eva1 < 5: providers.remove(v) cost.remove(n) else: evaluation.append(eva1) x = +1 print("the count of offers is " + str(count) + " and had been chosen " + str(len(providers))) the_winner = min(cost) #تعطي قيمة رقمية للقيمة الأقل في القائمة place_of_min_coast = cost.index(the_winner) #تعطي مكان القيمة الأقل في قائمة coasts place_of_min_coast1 = providers[place_of_min_coast] #تعطي قيمة المقابلة للقيمة الأقل في قائمة المزودين place_of_rate = evaluation[place_of_min_coast] print(providers) print(cost) print(evaluation) print("====================================================================") the_last_print = (f"the best offer you can approve it is {place_of_min_coast1} with coast {the_winner} his rate is {place_of_rate}").title() print(the_last_print) print("====================================================================")
حل التمرين a =input("Write the names of Providers separated by commas : ") providers= a.split(',') b = input("Write the cost of the offers separated by commas : ") offers = b.split(",") if len(providers) != 5 or len(offers) != 5 : print("you have to enter exact 5 providers & 5 Offers ") exit() selected_Providers=[] selected_offers=[] selected_rates =[] '''''''''''''''''''''''' r0 = int(input(f"input the Rate of {providers[0]} with cost {offers[0]} : ")) if r0 >= 5: selected_Providers.append(providers[0]) selected_offers.append(offers[0]) selected_rates.append(r0) r1 = int(input(f"input the Rate of {providers[1]} with cost {offers[1]} : ")) if r1 >= 5: selected_Providers.append(providers[1]) selected_offers.append(offers[1]) selected_rates.append(r1) r2 = int(input(f"input the Rate of {providers[2]} with cost {offers[2]} : ")) if r2 >= 5: selected_Providers.append(providers[2]) selected_offers.append(offers[2]) selected_rates.append(r2) r3 = int(input(f"input the Rate of {providers[3]} with cost {offers[3]} : ")) if r3 >= 5: selected_Providers.append(providers[3]) selected_offers.append(offers[3]) selected_rates.append(r3) r4 = int(input(f"input the Rate of {providers[4]} with cost {offers[4]} : ")) if r4 >= 5: selected_Providers.append(providers[4]) selected_offers.append(offers[4]) selected_rates.append(r4) '''''''''''''''''''''''' #mm= (max(selected_offers)) m= selected_offers.index((max(selected_offers))) if len(selected_Providers)< 3 : print(f'''f' selected offers is less than 3 , however the winner in such case is {selected_Providers[m] } with cost {selected_offers[m]} and rate {selected_rates[m]} ' ''' ) else: print(f''' a total sum of 5 offers were examined , {len(selected_offers)} of them were accepted the winner is {selected_Providers[m]} with cost {selected_offers[m]} and rate {selected_rates[m]} ' ''')
from array import * Names = str(input("Write the names of providers (Separate each name with a comma): ")).split(',') Costs = input("Write the cost of offers (Separate each amount with a comma): ").split(',') Accepted_Names = [] RateList = [] Accepted_Cost = [] if len(Names) and len(Costs) != 5: print("it is wrong") exit() # RateList = rate1 + rate2 + rate3 + rate4 + rate5 i = 0 rate1 =input(f"Write the rate {Names[i]}'s bid, with cost {Costs[i]}: ") if rate1 >= "5": RateList.append(rate1) Accepted_Names.append(Names[i]) Accepted_Cost.append(Costs[i]) i = i + 1 rate2 =input(f"Write the rate {Names[i]}'s bid, with cost {Costs[i]}: ") if rate2 >= "5": RateList.append(rate2) Accepted_Names.append(Names[i]) Accepted_Cost.append(Costs[i]) i = i + 1 rate3 =input(f"Write the rate {Names[i]}'s bid, with cost {Costs[i]}: ") if rate3 >= "5": RateList.append(rate3) Accepted_Names.append(Names[i]) Accepted_Cost.append(Costs[i]) i = i + 1 rate4 =input(f"Write the rate {Names[i]}'s bid, with cost {Costs[i]}: ") if rate4 >= "5": RateList.append(rate4) Accepted_Names.append(Names[i]) Accepted_Cost.append(Costs[i]) i = i + 1 rate5 =input(f"Write the rate {Names[i]}'s bid, with cost {Costs[i]}: ") if rate5 >= "5": RateList.append(rate5) Accepted_Names.append(Names[i]) Accepted_Cost.append(Costs[i]) w = min(Accepted_Cost) p = Accepted_Cost.index(w) print(f"Number of offered: {len(Names)}") print(f"Number of accepted {len(Accepted_Names)}") #print(f"cost is: {w} ") print(f"The winner is:{Accepted_Names[p]}, with cost {Accepted_Cost[p]}, and its rate is {RateList[p]} ")
حل آخر باستخدام for a =input("Write the names of Providers separated by commas : ") providers= a.split(',') b = input("Write the cost of the offers separated by commas : ") offers = b.split(",") if len(providers) != 5 or len(offers) != 5 : print("you have to enter exact 5 providers & 5 Offers ") exit() selected_Providers=[] selected_offers=[] selected_rates =[] '''''''''''''''''''''''' for i in range( 0,4 ): r = int(input(f"input the Rate of {providers[i]} with cost {offers[i]} : ")) if r(i) >= 5: selected_Providers.append(providers[i]) selected_offers.append(offers[i]) selected_rates.append(i) next(i) '''''''''''''''''''''''' #mm= (max(selected_offers)) m= selected_offers.index((max(selected_offers))) if len(selected_Providers)< 3 : print(f'''f' selected offers is less than 3 , however the winner in such case is {selected_Providers[m] } with cost {selected_offers[m]} and rate {selected_rates[m]} ' ''' ) else: print(f''' a total sum of 5 offers were examined , {len(selected_offers)} of them were accepted the winner is {selected_Providers[m]} with cost {selected_offers[m]} and rate {selected_rates[m]}
اسال الله تعالى ان يحفظ ويرعاك ويبعد عنك كل سوء ويرزقنا واياك الجنة
شكرا اخى المنذر على علمك النافع و الجميل.
شرحك مره حيلو ومفهوم❤❤❤❤ شكرا
تم حل التمرين.. شكرا جزيلا ❤
يعطيك ألف عافية أستاذ، وهي الكود كما يلي:
offersname = input("Write the name of providers (separate each name with a comma): ")
offerscost = input("Write the cost of offers (separate each name with a comma): ")
offersnamelist = offersname.split(",")
offerscostlist = offerscost.split(",")
if len(offersnamelist) != 5 and len(offerscostlist) != 5:
print("The number of Providers and number of offers costs must equal 5")
elif len(offersnamelist) == 5 and len(offerscostlist) != 5:
print("The number of offers costs must equal 5")
elif len(offersnamelist) != 5 and len(offerscostlist) == 5:
print("The number of Providers must equal 5")
else:
offer1rate = float(input(f"Write the rate of {offersnamelist[0]}'s bid, with cost {offerscostlist[0]}: "))
offer2rate = float(input(f"Write the rate of {offersnamelist[1]}'s bid, with cost {offerscostlist[1]}: "))
offer3rate = float(input(f"Write the rate of {offersnamelist[2]}'s bid, with cost {offerscostlist[2]}: "))
offer4rate = float(input(f"Write the rate of {offersnamelist[3]}'s bid, with cost {offerscostlist[3]}: "))
offer5rate = float(input(f"Write the rate of {offersnamelist[4]}'s bid, with cost {offerscostlist[4]}: "))
acceptedoffers = int(0)
acceptedofferslist =[]
ratelist = []
if offer1rate >= 5:
offer1degree = int(1)
acceptedofferslist.append(offer1rate)
ratelist.append(offer1rate)
else:
offer1degree = int(0)
if offer2rate >= 5:
offer2degree = int(1)
acceptedofferslist.append(offer2rate)
ratelist.append(offer2rate)
else:
offer2degree = int(0)
if offer3rate >= 5:
offer3degree = int(1)
acceptedofferslist.append(offer3rate)
ratelist.append(offer3rate)
else:
offer3degree = int(0)
if offer4rate >= 5:
offer4degree = int(1)
acceptedofferslist.append(offer4rate)
ratelist.append(offer4rate)
else:
offer4degree = int(0)
if offer5rate >= 5:
offer5degree = int(1)
acceptedofferslist.append(offer5rate)
ratelist.append(offer5rate)
else:
offer5degree = int(0)
acceptedoffers = offer1degree + offer2degree + offer3degree + offer4degree + offer5degree
print(f"=*=*=*=*=*=*=*=*=*=*=*=*")
print(f"Number of offered bids: 5")
print(f"Number of accepted offers: {acceptedoffers}")
if acceptedoffers != 0:
a = min(acceptedofferslist)
i = ratelist.index(a)
print(f"The winner offer is: {offersnamelist[ratelist.index(min(acceptedofferslist))]}, with cost {offerscostlist[ratelist.index(min(acceptedofferslist))]}, and its rate is {min(acceptedofferslist)}")
else:
print(f"None of the offers are accepted")
جزاكم الله خيراً , شرح ممتاز
شرح ممتاز جزاكم الله خيرا
شكرا استاذنا القدير .. اظن ان التمارين صعبة نوعا ما للمبتدئين
مشكور استاذنا الكبير المنذر ❤
احسنت يا استاذ
بارك الله فيك استاذ المنذز
احلي شخص في البرمجه
هل انت جديد في البرمجة صديقي ؟
هل انت جديد في البرمجة
بارك الله فيك ، جهد عظيم تشكر عليه
شرحك رائع شكرا جزيلا
بارك الله فيك استاذ
جزاكم الله خيرا
اقتراح لتسهيل الشرح في الدقيقة 06:17
هو يستدعي ابتداء من القيمة اليسرى (0) والعدد الذي يستدعيه هي القيمة اليمنى (2)
رائع وفقك الله ❤️
ألف شكر يا غالي
رااائع بارك الله فيك
انا خلصت مذاكره البايثون لكن رجعتلها بسب تمارين حضرتك ..ياريت تعمم هذه الطريقة بالتطبيق في اي شيء يدرس
my_list = [1, 2, 3, 4]
print("Popped element:", my_list.pop())
print("List after pop():", my_list)
Training Code as below:
Name = input("Write the names of providers (Separate each name with a comma): ")
Cost = input("Write the cost of offers (Separate each amount with a comma): ")
#Rates: Type[float] = list
Rates = []
Accepted = []
Providers = Name.split(",")
Offers = Cost.split(",")
if len(Offers) != 5:
print("You should Write Five Amounts of offers ")
else:
I = 0
Rate1 = float(input(f"Write the rate of {Providers[I]}'s bid, with cost {Offers[I]} : "))
Rates.append(Rate1)
if Rate1 < 5:
pass
else:
Accepted.append(Rate1)
print(Rates)
I = I + 1
Rate2 = float(input(f"Write the rate of {Providers[I]}'s bid, with cost {Offers[I]} : "))
Rates.append(Rate2)
if Rate2 < 5:
pass
else:
Accepted.append(Rate2)
print(Rates)
I = I + 1
Rate3 = float(input(f"Write the rate of {Providers[I]}'s bid, with cost {Offers[I]} : "))
Rates.append(Rate3)
if Rate3 < 5:
pass
else:
Accepted.append(Rate3)
print(Rates)
I = I + 1
Rate4 = float(input(f"Write the rate of {Providers[I]}'s bid, with cost {Offers[I]} : "))
Rates.insert(I, Rate4)
if Rate4 < 5:
pass
else:
Accepted.append(Rate4)
print(Rates)
I = I + 1
Rate5 = float(input(f"Write the rate of {Providers[I]}'s bid, with cost {Offers[I]} : "))
if Rate5 < 5:
pass
else:
Accepted.append(Rate5)
print(Rates)
print("=============================")
print("Number of offers bids:", len(Offers))
print("Number of offers Accepted:", len(Accepted))
print(Accepted)
W = min(Accepted)
ind = Rates.index(W)
print(f"The winner offer is: {Providers[ind]}, with cost {Offers[ind]}, and its rate is {W} ")
ممكن حل تمارين على ال list
حياك الله نزلنا الفيديوهات
وفقك الله استأذنا الغالي كل درس عم تزيد المتعة اكثر واكثر
عذرا على التأخير
#inputs
print("hello world")
print("This is the Tender Analysis Program")
print("-------------------------------------------------")
providers=input('write the name of providers (separate each name with a comma))').split(",")
costs= input('write the cost offers (separate each offer with acomma))').split(",")
if len(costs)!= 5 or len(providers)!=5:
print('please insert 5 offers ')
exit()
rate=[ float( input(f"write the rate of {providers[0]}'s bid, with cost {costs[0]} : "))]
rate.append(float(input(f"write the rate of {providers[1]}'s bid, with cost {costs[1]} : ")))
rate.append(float(input(f"write the rate of {providers[2]}'s bid, with cost {costs[2]} : ")))
rate.append(float(input(f"write the rate of {providers[3]}'s bid, with cost {costs[3]} : ")))
rate.append(float(input(f"write the rate of {providers[4]}'s bid, with cost {costs[4]} : ")))
#result_lists
accept_p=[]
accept_c=[]
accept_r=[]
#funtions
n=0
if int(rate[n]) > 5:
accept_r.append(rate[n])
accept_p.append(providers[n])
accept_c.append(costs[n])
n=n+1
if rate[n]> 5:
accept_r.append(rate[n])
accept_p.append(providers[n])
accept_c.append(costs[n])
n=n+1
if rate[n] > 5 :
accept_r.append(rate[n])
accept_p.append(providers[n])
accept_c.append(costs[n])
n=n+1
if rate[n] > 5:
accept_r.append(rate[n])
accept_p.append(providers[n])
accept_c.append(costs[n])
n=n+1
if int(rate[n]) > 5:
accept_r.append(rate[n])
accept_p.append(providers[n])
accept_c.append(costs[n])
all_offers = len(rate)
good_offers = len(accept_r)
win_offer_index= accept_c.index(min(accept_c))
#result
print("=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*")
print(f"numbers of offerd bids : {all_offers}")
print(f"numbers of accepted bids : {good_offers}
")
print(f"the winner offer is : {accept_p[win_offer_index]} with cost {min(accept_c)} and its rate {accept_r[win_offer_index]} ")
استاذ منذر هلا اصبح الانتساب شرط لمشاهدة الكورس!؟
كيف يتم الانتساب لقناة
ممكن اتنزل التمارين واي شيء تبرمجة pdf ارجوك نتعب بالكتابة
بارك الله بجهودك لكن الفديوهات الاخيره لايمكن مشاهدتها مع العلم انا من المشتركين في قناتكم . ماهو الحل استاذ؟
لماذا عندما ا قوم بدمج القائمتين بهذه الطريقة يبعتلي ال error console
سؤال لو سمحت استاذ منذر
بأى دالة ممكن افحص قيم داخل القوائم كى اعرف إن كانت أكبر أو أصغر من المعامل المطلوب
list = [1,2,3,5]
a = input("enter number")
for i in list:
if list[i] > a:
print("thanks")
هذه هي الطريقة
@@malek_10 ألف شكر اخي الغالي كانا لم نأخذ تعليمة for ولكن الحمدلله فهمتها في درس القاموس ألف شكر على اهتمامك واتشرف بردك الجميل واكون من متابعيك ألف شكر اخي الغالي
@@esamnada عفوا
ولكن ظالة sort لم تظهر عندي
شكرا معليييييييم. يا أستاذة البرمجة تعالو تعلموا طريقة التدريس. كل فيديو متخص بجزء فقط. مش كل البرامج في فيديوا واحد!
استاذنا الكريم ،، هل الانتساب ب50$ للجلسات متاح حاليا ،، مع الشكر
❤️
حل التمرين
rates_List = []
accepted_offers = []
accepted_offers_number = 0
count = 0
providers_names = input("Write the names of the providers (Separate each name with a space and choose 5 only): ")
costs = input("Write the costs of the offers (Separate each cost with a space): ")
providers_list = providers_names.split()
costs_list = costs.split()
if len(providers_list) > 5 or len(costs_list) > 5:
print("Please choose 5 offers only.")
exit()
print("
")
print("Rate the offers (Highest rate for the lowest cost):
")
while count < 5:
rate = input(f"Write the rate of {providers_list[count]}'s, with cost {costs_list[count]}: ")
rates_List.insert(count, rate)
count = count + 1
for i in rates_List:
if float(i)
بدي انتساب و مافي حساب
عندك وكيل بادلب ؟
+REP
مابعرف شو فائدة انه نكتب الحل بالتعليقات اذا مافي اي تفاعل منك ولاحتى يمكن تشوف التعليقات حتى يحس المتابع انه عمل شي مفيد يعني مثلا ممكن نحلها ونخليها عندنا حتى المقطع القادم ونشوف الحل !
❤️🫡
after alot of working >>> I did another solution for this practice >>> still feeling my self a genius
providers =[]
cost = []
evaluation = []
count = int(input("how many providers you want to process ? "))
x=1
for x in range(count):
v=input("please enter the first provider: ").title()
n = float(input("please enter the first cost for " + v + ": "))
eva1 = float(input(f"please enter your evaluation for {v} with cost {n} : "))
providers.append(v)
cost.append(n)
if eva1 < 5:
providers.remove(v)
cost.remove(n)
else:
evaluation.append(eva1)
x = +1
print("the count of offers is " + str(count) + " and had been chosen " + str(len(providers)))
the_winner = min(cost) #تعطي قيمة رقمية للقيمة الأقل في القائمة
place_of_min_coast = cost.index(the_winner) #تعطي مكان القيمة الأقل في قائمة coasts
place_of_min_coast1 = providers[place_of_min_coast] #تعطي قيمة المقابلة للقيمة الأقل في قائمة المزودين
place_of_rate = evaluation[place_of_min_coast]
print(providers)
print(cost)
print(evaluation)
print("====================================================================")
the_last_print = (f"the best offer you can approve it is {place_of_min_coast1} with coast {the_winner} his rate is {place_of_rate}").title()
print(the_last_print)
print("====================================================================")
حل التمرين
a =input("Write the names of Providers separated by commas : ")
providers= a.split(',')
b = input("Write the cost of the offers separated by commas : ")
offers = b.split(",")
if len(providers) != 5 or len(offers) != 5 :
print("you have to enter exact 5 providers & 5 Offers ")
exit()
selected_Providers=[]
selected_offers=[]
selected_rates =[]
''''''''''''''''''''''''
r0 = int(input(f"input the Rate of {providers[0]} with cost {offers[0]} : "))
if r0 >= 5:
selected_Providers.append(providers[0])
selected_offers.append(offers[0])
selected_rates.append(r0)
r1 = int(input(f"input the Rate of {providers[1]} with cost {offers[1]} : "))
if r1 >= 5:
selected_Providers.append(providers[1])
selected_offers.append(offers[1])
selected_rates.append(r1)
r2 = int(input(f"input the Rate of {providers[2]} with cost {offers[2]} : "))
if r2 >= 5:
selected_Providers.append(providers[2])
selected_offers.append(offers[2])
selected_rates.append(r2)
r3 = int(input(f"input the Rate of {providers[3]} with cost {offers[3]} : "))
if r3 >= 5:
selected_Providers.append(providers[3])
selected_offers.append(offers[3])
selected_rates.append(r3)
r4 = int(input(f"input the Rate of {providers[4]} with cost {offers[4]} : "))
if r4 >= 5:
selected_Providers.append(providers[4])
selected_offers.append(offers[4])
selected_rates.append(r4)
''''''''''''''''''''''''
#mm= (max(selected_offers))
m= selected_offers.index((max(selected_offers)))
if len(selected_Providers)< 3 :
print(f'''f' selected offers is less than 3 , however
the winner in such case is
{selected_Providers[m] } with cost {selected_offers[m]} and rate {selected_rates[m]}
'
''' )
else:
print(f''' a total sum of 5 offers were examined ,
{len(selected_offers)} of them were accepted
the winner is
{selected_Providers[m]} with cost {selected_offers[m]} and rate {selected_rates[m]}
'
''')
from array import *
Names = str(input("Write the names of providers (Separate each name with a comma): ")).split(',')
Costs = input("Write the cost of offers (Separate each amount with a comma): ").split(',')
Accepted_Names = []
RateList = []
Accepted_Cost = []
if len(Names) and len(Costs) != 5:
print("it is wrong")
exit()
# RateList = rate1 + rate2 + rate3 + rate4 + rate5
i = 0
rate1 =input(f"Write the rate {Names[i]}'s bid, with cost {Costs[i]}: ")
if rate1 >= "5":
RateList.append(rate1)
Accepted_Names.append(Names[i])
Accepted_Cost.append(Costs[i])
i = i + 1
rate2 =input(f"Write the rate {Names[i]}'s bid, with cost {Costs[i]}: ")
if rate2 >= "5":
RateList.append(rate2)
Accepted_Names.append(Names[i])
Accepted_Cost.append(Costs[i])
i = i + 1
rate3 =input(f"Write the rate {Names[i]}'s bid, with cost {Costs[i]}: ")
if rate3 >= "5":
RateList.append(rate3)
Accepted_Names.append(Names[i])
Accepted_Cost.append(Costs[i])
i = i + 1
rate4 =input(f"Write the rate {Names[i]}'s bid, with cost {Costs[i]}: ")
if rate4 >= "5":
RateList.append(rate4)
Accepted_Names.append(Names[i])
Accepted_Cost.append(Costs[i])
i = i + 1
rate5 =input(f"Write the rate {Names[i]}'s bid, with cost {Costs[i]}: ")
if rate5 >= "5":
RateList.append(rate5)
Accepted_Names.append(Names[i])
Accepted_Cost.append(Costs[i])
w = min(Accepted_Cost)
p = Accepted_Cost.index(w)
print(f"Number of offered: {len(Names)}")
print(f"Number of accepted {len(Accepted_Names)}")
#print(f"cost is: {w} ")
print(f"The winner is:{Accepted_Names[p]}, with cost {Accepted_Cost[p]}, and its rate is {RateList[p]} ")
حل آخر باستخدام for
a =input("Write the names of Providers separated by commas : ")
providers= a.split(',')
b = input("Write the cost of the offers separated by commas : ")
offers = b.split(",")
if len(providers) != 5 or len(offers) != 5 :
print("you have to enter exact 5 providers & 5 Offers ")
exit()
selected_Providers=[]
selected_offers=[]
selected_rates =[]
''''''''''''''''''''''''
for i in range( 0,4 ):
r = int(input(f"input the Rate of {providers[i]} with cost {offers[i]} : "))
if r(i) >= 5:
selected_Providers.append(providers[i])
selected_offers.append(offers[i])
selected_rates.append(i)
next(i)
''''''''''''''''''''''''
#mm= (max(selected_offers))
m= selected_offers.index((max(selected_offers)))
if len(selected_Providers)< 3 :
print(f'''f' selected offers is less than 3 , however
the winner in such case is
{selected_Providers[m] } with cost {selected_offers[m]} and rate {selected_rates[m]}
'
''' )
else:
print(f''' a total sum of 5 offers were examined ,
{len(selected_offers)} of them were accepted
the winner is
{selected_Providers[m]} with cost {selected_offers[m]} and rate {selected_rates[m]}
معلومات قيمة.. شكرا جزيلا..❤
جزاكم الله خيرا