Suggestions required about my small python project "MCR(Maths Calculating Robot)"

hello everyone! Myself Anshuman Pal, and I am a student of class 11 science…an enthusiast of coding, glad to join this group as a new member…actually I was working on this project for a weeks, but I am not satisfied with the output . Therefore, I want to do some modifications in it . So please provide me some suggestions based on it…

def calculate_sum(name):
    name = name.lower()
    if name == "1":
        a = int (input ("Enter the first number: "))
        b = int (input ("Enter the second number: "))
        sum = a + b
        print ("The sum of the numbers is " + str(sum) )

    elif name == "2":
        a = int (input ("Enter the first number: "))
        b = int (input ("Enter the second number: "))
        sum = a - b
        print ("The difference of the numbers is " + str(sum))

    elif name == "3":
        a = int (input ("Enter the first number: "))
        b = int (input ("Enter the second number: "))
        sum = a * b
        print ("The product of the numbers is " + str(sum) )

    elif name == "4":
        a = int (input ("Enter the first number: "))
        b = int (input ("Enter the second number: "))
        sum = a / b
        print ("The difference of the numbers is " + str(sum) )
        
    elif name == "5":
         num = int(input('Enter a number: '))
         for i in range (1,11):
             print(num, 'X', i, '=', num*i)

    elif name == "6":
        num1 = int(input("Enter the first number:"))
        num2 = int(input("Enter the first number:"))
        if num1<num2:
            print (num2, "greater than", num1)
        elif num1>num2:
            print (num1, "greater than", num2)
        else:
            print ("Both are equal")
            
    elif name == "7":
        def calculate_peri(name):
            if name == "rectangle":
                l  = int(input("Enter rectangle's  length: "))
                b = int(input("Enter rectangle's  breadth: "))
                U = input("Enter the unit: ")
                rect_peri = 2 * ( l + b ) 
                print ("The perimeter of rectangle is: ", rect_peri, str(U))
            elif  name == "square":
                l  = int(input("Enter square's  length: "))
                U = input("Enter the unit: ")
                sqt_peri = 4 * l 
                print ("The perimeter of square is: ", sqt_peri, str(U))
            elif  name == "circle":
                r  = int(input("Enter circle's radius length: "))
                U = input("Enter the unit: ")
                pi = 22/7
                circ_peri = pi * r * r
                print ("The perimeter of circle is: ", circ_peri, str(U))
            elif  name == "triangle":
                A  = int(input("Enter triangle's first side's length: "))
                B  = int(input("Enter triangle's second side's length: "))
                C  = int(input("Enter triangle's third side's length: "))
                U = input("Enter the unit: ")
                if A == B == C:
                    trin_peri = 3 * A
                    print ("The perimeter of triangle is: ", trin_peri, str(U), "\nIt is a Equilateral triangle.")
                elif A==B or B==C or A==C:
                    trin_peri = 2 * A + C
                    print ("The perimeter of triangle is: ", trin_peri, str(U), "\nIt is a Isosceles triangle.")
                else:
                    trin_peri = A + B + C
                    print ("The perimeter of triangle is: ", trin_peri, str(U), "\nIt is a Scalene triangle.")
            else:
                print ("Sorry! The shape is not available.")
        print ("Calculate shape perimeter ")
        shape_name = input ("Enter the name of the shape you want to find(rectangle/square/circle/triangle):")
        calculate_peri(shape_name)

    elif name == "8":
        def calculate_area(name):
            if name == "rectangle":
                l  = int(input("Enter rectangle's  length: "))
                b = int(input("Enter rectangle's  breadth: "))
                U = input("Enter the unit: ")
                rect_area =  l * b 
                print ("The area of rectangle is: ", rect_area, str(U),str("\u00b2"))
            elif  name == "square":
                l  = int(input("Enter square's  length: "))
                U = input("Enter the unit: ")
                sqt_area = l * l 
                print ("The area of square is: ", sqt_area, str(U),str("\u00b2"))
            elif  name == "circle":
                r  = int(input("Enter circle's radius length: "))
                U = input("Enter the unit: ")
                pi = 3.14
                circ_area = pi * r * r
                print ("The area of circle is: ", circ_area, str(U),str("\u00b2"))
            elif  name == "triangle":
                h  = int(input("Enter triangle's side's height: "))
                b  = int(input("Enter triangle's side's base: "))
                U = input("Enter the unit: ")
                trin_area = h * b
                print ("The area of triangle is: ", trin_area, str(U),str("\u00b2"))
            else:
                print ("Sorry! The shape is not available.")
        print ("Calculate shape area")
        shape_name = input ("Enter the name of the shape you want to find(rectangle/square/circle/triangle):")
        calculate_area(shape_name)
    elif name == "9":
        P = int(input("Enter the principal: "))
        R = int(input("Enter the rate: "))
        T = int(input("Enter the time: "))
        SI = P * R * T / 100
        print ("The amount at the end of", T, "years is ₹", SI)

    elif name == "10":
        P = int(input("Enter the principal: "))
        R = int(input("Enter the rate: "))
        T = int(input("Enter the time: "))
        CI = P * ((1 + R/100)**T)
        print ("The amount at the end of", T, "years is ₹", CI)
    
    else :
        print ("Sorry! The choice you made is invalid!")
        
print("🪘" * 55)
print("🪘" * 55)
print ("🪘" * 2 + " " * 3 + "🌹" * 3 + " " * 4 + "🌹" * 3 + " " + "🌹" * 6 + " " + "🌹" * 6 + " " * 6 + "🪘" * 2)
print ("🪘" * 2 + " " * 4 + "🌹" * 2 + " " + "🌹" +  "🌹" + " " + "🌹" * 2 + " " * 2 + "🌹" * 2 + " " * 4 + "🌹" * 2 + " " * 3 + "🌹" * 2 + " " * 3 + "🌹" * 2 + " " * 5 + "🪘" * 2)
print ("🪘" * 2 +" " * 4 + "🌼" * 2 + " " * 2 + "🌼" + " " * 2 + "🌼" * 2 + " " * 2 + "🌼" * 2 + " " * 11 + "🌼" * 2 + " " * 3 + "🌼" * 2 + " " * 5 + "🪘" * 2)
print ("🪘" * 2 +" " * 4 + "🌼" * 2 + " " * 2 + "🌼" + " " * 2 + "🌼" * 2 + " " * 2 + "🌼" * 2 + " " * 11 + "🌼" * 2 + " " + "🌼" * 3 + " " * 5 + "🪘" * 2)
print ("🪘" * 2 +" " * 4 + "🍀" * 2 + " " * 6 + "🍀" * 2 + " " * 2 + "🍀" * 2 + " " * 4 + "🍀" * 2 + " " * 3 + "🍀" * 2 + " " * 2 + "🍀" * 3 + " " * 4 + "🪘" * 2)
print ("🪘" * 2 + " " * 3 + "🍀" * 3 + " " * 4 + "🍀" * 3 + " " + "🍀" * 6 + " " + "🍀" * 3 + " " * 3 + "🍀" * 4 + " " + "🪘" * 2)
print("🪘" * 55)
print("🪘" * 2 + " " * 2 + "Hi user! Welcome to MCR(Maths Calculating Robot)," + "🪘" * 2 + "\n" + "🪘" * 2 + " " * 2 + "which can calculate the following operations:" + " " * 4 + "🪘" * 2 + "\n" + "🪘" * 2 + " " * 2 + "1. Addition" + " " * 38 + "🪘" * 2 + "\n" + "🪘" * 2 + " " * 2 + "2. Substraction" + " " * 34 + "🪘" * 2 + "\n" + "🪘" * 2 + " " * 2 + "3. Multiplication" + " " * 32 + "🪘" * 2 + "\n" + "🪘" * 2 + " " * 2 + "4. Division" + " " * 38 + "🪘" * 2 + "\n" + "🪘" * 2 + " " * 2 + "5. Table of any number" + " " * 27 + "🪘" * 2 + "\n" + "🪘" * 2 + " " * 2 + "6. Greater than" + " " * 34 + "🪘" * 2 + "\n" + "🪘" * 2 + " " * 2 + "7. Perimeter of any shape" + " " * 24 + "🪘" * 2 + "\n" + "🪘" * 2 + " " * 2 + "8. Area of any shape" + " " * 29 + "🪘" * 2 + "\n" + "🪘" * 2 + " " * 2 + "9. Simple Interest" + " " * 31 + "🪘" * 2 + "\n" + "🪘" * 2 + " " * 2 + "10.Compound Interest" + " " * 29 + "🪘" * 2)
print("🪘" * 55)
print("🪘" * 2 + " " * 15 + "Made by : Anshuman Pal" + " " * 14 + "🪘" * 2)
print("🪘" * 55)
print("🪘" * 55)
operation_name = input ("Enter your choice : ")
print("\n" + "🪘" * 55)
calculate_sum(operation_name)

op_name = input("Want to Exit ? (Type Y/y/yes/Yes/YES for yes and N/n/no/No/NO for no) : ")

if op_name == "Y" or "y" or "yes" or "Yes" or "YES" :
    calculate_sum(operation_name)
elif op_name == "N" or"n" or"no" or "No" or "NO":
    exit(operation_name)
else:
    print ("Error!")
    

what are you not satisfied with, what modifications do you want to do

1 Like

sir, actually i think that my code is very much unorganised and nasty looking…so i would like to change that..

.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.