Peacn I need help to write down the descri[tion of this prgramm coding for example, like you give explaination about this calculator program. Please I will appriciate your help # Program make a simple calculator from itertools import permutations,combinations import statistics # This function adds two numbers def add(x, y):     return x + y # This function subtracts two numbers def subtract(x, y):     return x - y # This function multiplies two numbers def multiply(x, y):     return x * y # This function divides two numbers def divide(x, y):     return x / y def permutationfun(arr,length):     perm = permutations(arr, length)     return perm def combinationfun(arr,length):     comb=combinations(arr,length)     return comb def stats(marks):     lengths = [x for x in marks.values()]     n = len(lengths)     get_sum = sum(lengths)     mean = get_sum / n     lengths.sort()     if n % 2 == 0:         median1 = lengths[n//2]         median2 = lengths[n//2 - 1]         median = (median1 + median2)/2     else:         median = lengths[n//2]     data = Counter(lengths)     get_mode = dict(data)     mode = [k for k, v in get_mode.items() if v == max(list(data.values()))]     if len(mode) == n:         get_mode = "No mode found"     else:         get_mode = "Mode is / are: " + ', '.join(map(str, mode))     print("Mean of the marks are",mean,end=" ")     print("Median of the marks",median,end=" ")     print("Mode of the marks",get_mode) print("Select operation.") print("1.Add") print("2.Subtract") print("3.Multiply") print("4.Divide") print("5.Permutation") print("6.Combination") print("7.Equation") print("8. Mean, Median and Mode") print("9.Power") print("10. Power with modulus ") while True:     choice = input("Enter choice(1/2/3/4/5/6/7/8/9/10): ")     # Check if choice is one of the four options     if choice in ('1', '2', '3', '4'):         num1 = float(input("Enter first number: "))         num2 = float(input("Enter second number: "))         if choice == '1':             print(num1, "+", num2, "=", add(num1, num2))         elif choice == '2':             print(num1, "-", num2, "=", subtract(num1, num2))         elif choice == '3':             print(num1, "*", num2, "=", multiply(num1, num2))         elif choice == '4':             print(num1, "/", num2, "=", divide(num1, num2))         break     elif choice in ('5','6'):         num1 = list((input("Enter array : ")))         num2 = float(input("Enter length: "))         if choice=="5":             perm=permutationfun(num1,num2)             for i in list(perm):                 print (i)         if choice=="6":             comb=combinationfun(num1,num2)             for i in list(comb):                 print (i)          elif choice=="7":         eq=(input("Enter the equation"))         print(eval(eq))     elif choice=="8":         marks = {}         n=int(input("Enter the number of students"))         for i in range(n):             student_name = input("Enter student's name: ")             student_mark = int(input("Enter student's mark: "))             marks[student_name] = student_mark         stats(marks)          elif choice in ('9','10'):         num1 = float(input("Enter first number: "))         num2 = float(input("Enter second number: "))         if choice=="9":             print(pow(num1, num2))         if choice=="10":             num3=float(input("Enter the modulus number:"))             print(pow(num1,num2,num3))     else:         print("Invalid Input")

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Peacn I need help to write down the descri[tion of this prgramm coding for example, like you give explaination about this calculator program. Please I will appriciate your help

# Program make a simple calculator
from itertools import permutations,combinations
import statistics
# This function adds two numbers
def add(x, y):
    return x + y

# This function subtracts two numbers
def subtract(x, y):
    return x - y

# This function multiplies two numbers
def multiply(x, y):
    return x * y

# This function divides two numbers
def divide(x, y):
    return x / y

def permutationfun(arr,length):
    perm = permutations(arr, length)
    return perm

def combinationfun(arr,length):
    comb=combinations(arr,length)
    return comb

def stats(marks):
    lengths = [x for x in marks.values()]
    n = len(lengths)
    get_sum = sum(lengths)
    mean = get_sum / n
    lengths.sort()
    if n % 2 == 0:
        median1 = lengths[n//2]
        median2 = lengths[n//2 - 1]
        median = (median1 + median2)/2
    else:
        median = lengths[n//2]
    data = Counter(lengths)
    get_mode = dict(data)
    mode = [k for k, v in get_mode.items() if v == max(list(data.values()))]

    if len(mode) == n:
        get_mode = "No mode found"
    else:
        get_mode = "Mode is / are: " + ', '.join(map(str, mode))

    print("Mean of the marks are",mean,end=" ")
    print("Median of the marks",median,end=" ")
    print("Mode of the marks",get_mode)

print("Select operation.")
print("1.Add")
print("2.Subtract")
print("3.Multiply")
print("4.Divide")
print("5.Permutation")
print("6.Combination")
print("7.Equation")
print("8. Mean, Median and Mode")
print("9.Power")
print("10. Power with modulus ")

while True:
    choice = input("Enter choice(1/2/3/4/5/6/7/8/9/10): ")

    # Check if choice is one of the four options
    if choice in ('1', '2', '3', '4'):
        num1 = float(input("Enter first number: "))
        num2 = float(input("Enter second number: "))

        if choice == '1':
            print(num1, "+", num2, "=", add(num1, num2))

        elif choice == '2':
            print(num1, "-", num2, "=", subtract(num1, num2))

        elif choice == '3':
            print(num1, "*", num2, "=", multiply(num1, num2))

        elif choice == '4':
            print(num1, "/", num2, "=", divide(num1, num2))
        break

    elif choice in ('5','6'):
        num1 = list((input("Enter array : ")))
        num2 = float(input("Enter length: "))
        if choice=="5":
            perm=permutationfun(num1,num2)
            for i in list(perm):
                print (i)
        if choice=="6":
            comb=combinationfun(num1,num2)
            for i in list(comb):
                print (i)
    
    elif choice=="7":
        eq=(input("Enter the equation"))
        print(eval(eq))

    elif choice=="8":
        marks = {}
        n=int(input("Enter the number of students"))
        for i in range(n):
            student_name = input("Enter student's name: ")
            student_mark = int(input("Enter student's mark: "))
            marks[student_name] = student_mark
        stats(marks)
    
    elif choice in ('9','10'):
        num1 = float(input("Enter first number: "))
        num2 = float(input("Enter second number: "))
        if choice=="9":
            print(pow(num1, num2))
        if choice=="10":
            num3=float(input("Enter the modulus number:"))
            print(pow(num1,num2,num3))
    else:
        print("Invalid Input")

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 7 steps

Blurred answer
Knowledge Booster
Declaring and Defining the Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education