مشاركة حلول: مهمة سحب الأموال آلياً


#1

مرحباً جميعاً

المهمة المطلوبة

بإمكانك الإطلاع على المهمة المطلوبة من هنا

كيفية كتابة الأكواد في المنتدى


#2
# allowed papers: 100, 50, 10, 5, and rest of request

money = 500
request = 277

if request <= money:
	if request > 0 :
		while request > 0 :
			if request >= 100 :
				request -= 100
				print("give 100")
			elif request < 100 and request >= 50 :
				request -= 50
				print("give 50")
			elif request < 50 and request >= 10 :
				request -= 10
				print("give 10")
			elif request < 10 and request >= 5 :
				request -= 5
				print("give 5")
			else:
				print("give",request)
				break
	else:
		print("please try again")
else:
	print("not enough money")
Summary

This text will be hidden


#3
money = 500
def bank(request):
    if request <= money:
        if request > 0:
            while request > 0:
                if request >= 100:
                    request -= 100
                    print("donner 100")
                elif request < 100 and request >= 50:
                    request -= 50
                    print("donner 50")
                elif request < 50 and request >= 10:
                    request -= 10
                    print("donner 10")
                elif request < 10 and request >= 5:
                    request -= 5
                    print("donner 5")
                else:
                    print("donner" , request)
                    break
        else:
            print("impossible de retirer ",request,"$ veuillez réessayer")
    else:
        print("votre solde est insuffisant pour effectuer cette operation. veuillez recharger votre compte")
        
bank(277)

#4
money = 500
def bank(request):
    if (request <= money):
        if (request > 0):
            while request > 0:
                if (request >= 100):
                    request -= 100
                    print("donner 100")
                elif (request < 100) & (request >= 50):
                    request -= 50
                    print("donner 50")
                elif (request < 50) & (request >= 10):
                    request -= 10
                    print("donner 10")
                elif (request < 10 )& (request >= 5):
                    request -= 5
                    print("donner 5")
                else:
                    print("donner" , request)
                    break
        else:
            print("impossible de retirer ",request,"$ veuillez réessayer")
    else:
        print("votre solde est insuffisant pour effectuer cette operation. veuillez recharger votre compte")
        
bank(0)

#5

@kaabi_otman
@yahya-alshammout

عمل رائع :+1:


#6
money = 500
request = 277
if money > request:
	while request >0:
		if request >= 100:
			request -= 100
			print("give "+str(100))
		elif request >= 50:
			request -= 50
			print("give " + str(50))	
		elif request >= 10:
			request -= 10
			print("give " + str(10))
		elif request >= 5:
			request -= 5
			print("give " + str(5))
		else :
			request -= 2
			print("give " + str(2))			
else:
	print("Not avalible")

#7

السلام عليكم
إليكم مشاركتي

money = 500
blacknotes = [100, 50, 10, 5, 2]
def giveMoney(request):
    if request > money:
        print('Sorry! You have\'nt enough money')
    elif request < 0:
        print("Please, Enter more than 0!")

    else:
        while request > 0:
            if request >= blacknotes[0]:
                print('give '+str(blacknotes[0]))
                request-= blacknotes[0]
            elif request < blacknotes[0] and request >= blacknotes[1]:
                print('give '+str(blacknotes[1]))
                request-= blacknotes[1]
            elif request < blacknotes[1] and request >= blacknotes[2]:
                print('give '+str(blacknotes[2]))
                request-= blacknotes[2]
            elif request < blacknotes[2] and request >= blacknotes[3]:
                print('give '+str(blacknotes[3]))
                request-= blacknotes[3]
            elif request < blacknotes[3] and request >= blacknotes[4]:
                print('give '+str(blacknotes[4]))
                request-= blacknotes[4]
            elif request < blacknotes[4]:
                break

giveMoney(277)

#8

عمل ممتاز @asmaa_salih @Adetech :+1:


#9
money = 500
request=277

def subtract(request):
    while request >= 100:
        request =request-100
        print("give 100")

    while request<100 and request>=50:
        request=request-50
        print ("give 50")

    while request<50 and request>=10:
        request=request -10
        print("give 10")

    while request<10 and request>=5:
        request=request-5
        print("give 5")
    if request!=0:
        print ("give "+str(request))


subtract(request)
subtract(100)
subtract(2120)
subtract(10)


#10

here is mine

money = 500
request=358
allowed = [100, 50, 10, 5]

if request <=500:
    while request > 5:
        for i in allowed :
            while request >= i:
                print (i)
                request -= i
    if request >0:
        print (request)

else:
    print('Sorry, no enough money')