Python Code for Restaurant’s Menu and Payment

Hello Coders, In this blog post, You will learn to build a code for a restaurant’s Menu and payment in Python. This code is beginners level code for all beginners. Let us learn about it:-

Python code for restaurant's menu and payment

To write this code, we have imported a numpy library that will help us generate random numbers for OTP. The card number and CVV will only accept 123456 and 123 as we have yet to attach any database for more card acceptance.

The code is made with the help of def function. 

Python Code for restaurant's Menu and payment :-

import numpy
def total(a,b):
    tot = a*b
    print(“the total of these items is:”, tot )
def Paytm():
    print(“Select your mode of payment”)
    print(“1> cc 2> dc”)
    pay = int(input(“Enter your mode of payment: “))
    if pay == 1:
        card= 123456
        cv = 123
        cc= int(input(“enter the last 6 digits:”))
        if card == cc:
            cvv  = int(input(“enter your 3 digit cvv number: “))
            if cvv == cv:
                otp = numpy.random.randint(000000,999999)
                print(“your otp is:”,otp)
                ottp = int(input(“enter the otp: “))
                if otp == ottp:
                    print(“payment is successfull”)
                    print(“Your Order will be delivered in 20 min”)
                else:
                    print(“failed transcation!!!”)
            else:
                print(“enter correct cvv”)
        else:
            print(“enter correct card number”)
   
    elif pay == 2:
        card= 123456
        cv = 123
        cc= int(input(“enter the last 6 digits:”))
        if card == cc:
            cvv  = int(input(“enter your 3 digit cvv number: “))
            if cvv == cv:
                otp = numpy.random.randint(000000,999999)
                print(“your otp is:”,otp)
                ottp = int(input(“enter the otp: “))
                if otp == ottp:
                    print(“payment is successfull”)
                    print(“Your order will be delivered in 18 min”)
                else:
                    print(“failed transcation!!!”)
            else:
                print(“enter correct cvv”)
        else:
            print(“enter correct card number”)
   
    else:
        print(“select a correct mode of payment”)
        Paytm()
def Googlepay():
    print(“Select your mode of payment”)
    print(“1> cc 2> dc”)
    pay = int(input(“Enter your mode of payment: “))
    if pay == 1:
        card= 123456
        cv = 123
        cc= int(input(“enter the last 6 digits:”))
        if card == cc:
            cvv  = int(input(“enter your 3 digit cvv number: “))
            if cvv == cv:
                otp = numpy.random.randint(000000,999999)
                print(“your otp is:”,otp)
                ottp = int(input(“enter the otp: “))
                if otp == ottp:
                    print(“payment is successfull”)
                    print(“Your order will be delivered in 15 min”)
                else:
                    print(“failed transcation!!!”)
            else:
                print(“enter correct cvv”)
        else:
            print(“enter correct card number”)
   
    elif pay == 2:
        card= 123456
        cv = 123
        cc= int(input(“enter the last 6 digits:”))
        if card == cc:
            cvv  = int(input(“enter your 3 digit cvv number: “))
            if cvv == cv:
                otp = numpy.random.randint(000000,999999)
                print(“your otp is:”,otp)
                ottp = int(input(“enter the otp: “))
                if otp == ottp:
                    print(“payment is successfull”)
                    print(“Your order will in 17 min”)
                else:
                    print(“failed transcation!!!”)
            else:
                print(“enter correct cvv”)
        else:
            print(“enter correct card number”)
   
    else:
        print(“select a correct mode of payment”)
        Googlepay()
def phonepe():
    print(“Select your mode of payment”)
    print(“1> cc 2> dc”)
    pay = int(input(“Enter your mode of payment: “))
    if pay == 1:
        card= 123456
        cv = 123
        cc= int(input(“enter the last 6 digits:”))
        if card == cc:
            cvv  = int(input(“enter your 3 digit cvv number: “))
            if cvv == cv:
                otp = numpy.random.randint(000000,999999)
                print(“your otp is:”,otp)
                ottp = int(input(“enter the otp: “))
                if otp == ottp:
                    print(“payment is successfull”)
                    print(“Your order will be delivered in 19 min”)
                else:
                    print(“failed transcation!!!”)
            else:
                print(“enter correct cvv”)
        else:
            print(“enter correct card number”)
   
    elif pay == 2:
        card= 123456
        cv = 123
        cc= int(input(“enter the last 6 digits:”))
        if card == cc:
            cvv  = int(input(“enter your 3 digit cvv number: “))
            if cvv == cv:
                otp = numpy.random.randint(000000,999999)
                print(“your otp is:”,otp)
                ottp = int(input(“enter the otp: “))
                if otp == ottp:
                    print(“payment is successfull”)
                    print(“Your order will be delivered in 26 min”)
                else:
                    print(“failed transcation!!!”)
            else:
                print(“enter correct cvv”)
        else:
            print(“enter correct card number”)
   
    else:
        print(“select a correct mode of payment”)
        phonepe()
def Cod():
    add = input(“Enter your address: “)
    print(“do you want to continue with cash on delivery(y/n):”)
    choi = input(“enter your choice: “)
    if choi== “y”:
        print(“Your order will be delivered in 25 min”)
    else:
        payment()
def payment():
    print(“Select the mode of payment”)
    print(“1> Paytm 2> GooglePay 3> PhonePe 4> Cash on Delivery”)
    paym = int(input(“select the mode of payment: “))
    if paym == 1:
        Paytm()
    elif paym==2:
        Googlepay()
    elif paym ==3:
        phonepe()
    else:
        Cod()
def menu():
    print(“sr.no. item price”)
    print(“1> Apple 45”)
    print(“2> orange 70”)
    print(“3> kiwi 130”)
    print(“4> banana 7”)
    item = int(input(“Enter the item no: “))
    quantity = int(input(“Enter the quantity required: “))
    if item == 1:
        item = 45
    elif item == 2:
        item = 70
    elif item == 3:
        item = 130
    elif item == 4:
        item = 7
    else:
        print(“NO ITEM PRESENT AT THIS INDEX”)
   
    total(item,quantity)
    more = input(“Do you want to add more items in the cart: y/n:”)
    if more == “y”:
        menu()
    else:
        payment()
menu()

OUTPUT

1. Output with paytm

sr.no. item price
1> Apple 45
2> orange 70
3> kiwi 130
4> banana 7
Enter the item no: 1
Enter the quantity required: 45
the total of these items is: 2025
Do you want to add more items in the cart: y/n:n
Select the mode of payment
1> Paytm 2> GooglePay 3> PhonePe 4> Cash on Delivery
select the mode of payment: 1
Select your mode of payment
1> cc 2> dc
Enter your mode of payment: 1
enter the last 6 digits:123456
enter your 3 digit cvv number: 123
your otp is: 805494
enter the otp: 805494
payment is successfull
Your Order will be delivered in 20 min

2. Output with cash on delivery

sr.no. item price
1> Apple 45
2> orange 70
3> kiwi 130
4> banana 7
Enter the item no: 2
Enter the quantity required: 4
the total of these items is: 280
Do you want to add more items in the cart: y/n:n
Select the mode of payment
1> Paytm 2> GooglePay 3> PhonePe 4> Cash on Delivery
select the mode of payment: 4
Enter your address: mohali, punjab
do you want to continue with cash on delivery(y/n):
enter your choice: y
Your order will be delivered in 25 min

Hope this blog post was helpful to you and you have got the answer to your question. Thank you for visiting our blog. If you have any doubts about any coding questions then let us know in the comments section we will answer them as soon as possible. Till then check out our more blog posts.

Leave a Comment

Your email address will not be published. Required fields are marked *