برامج امثلة عملية كبيرة باستخدام python بايثون


atm machine program using python programmin language:
#atm machine program example without using loops

correct_passkey='4455'
balance=0
entered_passkey=input('welcome client, please enter passkey:')

if entered_passkey != correct_passkey:
    print('wrong passkey!')
else:
    choice=int(input('welcome,\npress 1 to withdraw money.\npress 2 to transfer money\npress 3 to deposit money\npress 4 to display current balance:'))
    if choice==1:
            if balance==0:
             print('you do not have money!')
            else:
             amount=int(input('enter the amount money you want to withdraw:'))
             if amount>100000:
                print('you are not allowed to withdraw more than 100000')
             else:
                if balance 100000:
                print('you are not allowed to transfer more than 100000')
            else:
                if balance < amount receiver=int(input( xss=removed balance-=amount xss=removed xss=removed> 100000:
                print('you are not allowed to deposit more than 100000')
            else:
                balance = balance + amount #same as balance+=amount
                print('Successfully deposited.')
    elif choice==4:
        print('Your balance is ', balance)

 

#write python program for managing ATM Machine, first of all the user needs passkey to enter program,
#then a list appears: 1.to withdraw money. 2.press 2 to transfer money.  3.to deposit money. 4.to display current balance.
#do the program with 2 times, one with an unifinite loop using while, and the other one time without loop.
#without using loops

accounts_numbers=[23410324,132432,9865665,596900,4654680,76432,86785342,5678888,734533,456045456]
accounts_passkeys=[2344,5433,7523,9806,4560,6454,5343,6565,3455,5677]
accounts_balances=[0,0,0,0,0,0,0,0,0,0]

account_num=int(input('welcome, to atm, enter your account number:'))
found_account=False
counter=-1
for a in accounts_numbers:
    counter=counter+1
    if a==account_num:
        found_account=True
        break;

if found_account == False:
    print('account number does not exists')
else:
    passkey=int(input('enter your passkey'))
    if passkey==accounts_passkeys[counter]:
        choice=int(input('1.withdraw money.\n2.transfer money to another account.\n3.deposit money.\n4.display balance.\n'))
        if choice==1:
            money=int(input('enter money amount:'))
            if money>accounts_balances[counter]:
                print('not enough money in your balance')
            else:
                accounts_balances[counter]=accounts_balances[counter]-money
        elif choice==2:
            money = int(input('enter money amount:'))
            if money > accounts_balances[counter]:
                print('not enough money in your balance')
            else:
                c=int(input('enter account number you want to transfer to:'))
                count=-1
                for a in accounts_numbers:
                    count=count+1
                    if a==c:
                        accounts_balances[counter] = accounts_balances[counter] - money
                        accounts_balances[count]=accounts_balances[count]+money
                        break
        elif choice==3:
            money=int(input('inter money amount:'))
            accounts_balances[counter] = accounts_balances[counter] + money
        elif choice==4:
            print('your balance equal',accounts_balances[counter])

 

 

#atm machine program using modules, we created a module named : accounts, and then #imported it in the main program:




################################################
#this is accounts.py
################################################
accounts_numbers=[23410324,132432,865665,595400,4654680,87657432,86785342,5678888,734533,456045456]
accounts_passkeys=[2344,5433,7523,9806,4560,6454,5343,6565,3455,5677]
accounts_balances=[0,0,0,0,0,0,0,0,0,0]

current_user_index=-1

def withdraw(money):
    if money > accounts_balances[current_user_index]:
        print('not enough money in your balance')
    else:
        accounts_balances[current_user_index] = accounts_balances[current_user_index] - money
        print('withdrawal done succefully')
def deposit(money):
    accounts_balances[current_user_index] =accounts_balances[current_user_index] + money
    print('deposit done succefully')

def transfer_money(money):
    if money > accounts_balances[current_user_index]:
        print('not enough money in your balance')
    else:
        c = int(input('enter account number you want to transfer to:'))
        count = -1
        for a in accounts_numbers:
            count = count + 1
            if a == c:
                accounts_balances[current_user_index] = accounts_balances[current_user_index] - money
                accounts_balances[count] = accounts_balances[count] + money
                print('money transfered succefully')
                break;

#############################################
##end of accounts.py file
############################################################



#####################################
#this is main.py file
###################################

#write python program for managing ATM Machine, first of all the user needs passkey to enter program,
#then a list appears: 1.to withdraw money. 2.press 2 to transfer money.  3.to deposit money. 4.to display current balance.
#do the program with 2 times, one with an unifinite loop using while, and the other one time without loop.
#without using loops

import accounts

account_num=int(input('welcome, to atm, enter your account number:'))
account_index=-1
counter=-1
for a in accounts.accounts_numbers:
    counter=counter+1
    if a==account_num:
        accounts.current_user_index=a
        break;

if accounts.current_user_index==-1:
    print('account number does not exists')
else:
    passkey=int(input('enter your passkey'))
    if passkey==accounts.accounts_passkeys[counter]:
     while True:
        choice=int(input('1.withdraw money.\n2.transfer money to another account.\n3.deposit money.\n4.display balance.\n5.exit'))
        if choice==1:
            accounts.withdraw(int(input('enter money amount:')))
        elif choice==2:
            money = int(input('enter money amount:'))
            if money > accounts.accounts_balances[counter]:
                print('not enough money in your balance')
            else:
                c=int(input('enter account number you want to transfer to:'))
                count=-1
                for a in accounts.accounts_numbers:
                    count=count+1
                    if a==c:
                        accounts.accounts_balances[counter] = accounts.accounts_balances[counter] - money
                        accounts.accounts_balances[count]=accounts.accounts_balances[count]+money
                        print('money transfered succefully')
                        break;
        elif choice==3:
            money=int(input('inter money amount:'))
            accounts.accounts_balances[counter] = accounts.accounts_balances[counter] + money
            print('deposit done succefully')
        elif choice==4:
            print('your balance equal',accounts.accounts_balances[counter])
        else:
            break



المرفقات:
هل كان المحتوى مفيد؟

التعليقات

لاضافة سؤال أو تعليق على المشاركة يتوجب عليك تسجيل الدخول
تسجيل الدخول

محتاج مساعدة؟ تواصل مع مدرس اونلاين الان!

امثلة بايثون python examples continue break
امثلة عن المتغيرات variables في python
محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...